Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
# https://php.watch/articles/composer-gitattributes

# Exclude build/test files from archive
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.scrutinizer.yml export-ignore
/.travis.yml export-ignore
/codecov.yml export-ignore
/phpcs.xml export-ignore
/phpmd.xml export-ignore
/phpstan.neon export-ignore
/phpunit.xml.dist export-ignore
/.github export-ignore
/tests export-ignore
/tests-pecl-ext export-ignore
/tests-php8 export-ignore
/src-files export-ignore
/vendor-bin export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/CLAUDE.md export-ignore
/codecov.yml export-ignore
/composer-require-checker.json export-ignore
/phpcs.xml export-ignore
/phpmd.xml export-ignore
/phpstan.neon export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml export-ignore

# Configure diff output for .php and .phar files.
*.php diff=php
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ jobs:
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
matrix:
operating-system:
- ubuntu-latest
- windows-latest
php-version:
- '8.2'
- '8.3'
Expand All @@ -36,7 +33,7 @@ jobs:
- highest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -69,7 +66,7 @@ jobs:
run: ./vendor/bin/phpunit --coverage-clover=coverage.xml

- name: Upload coverage report
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
3 changes: 2 additions & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

jobs:
sa:
uses: ray-di/.github/.github/workflows/static-analysis.yml@v2
uses: ray-di/.github/.github/workflows/static-analysis.yml@v1
with:
php_version: 8.4
has_crc_config: true
15 changes: 0 additions & 15 deletions .scrutinizer.yml

This file was deleted.

27 changes: 0 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ This package is the Ray.Di module that performs the [PSR-6](https://www.php-fig.
You can use the PSR6 cache interface in two ways: `Local` and `Public`.
`Local` is for caches that do not need to be shared among multiple web servers, and `Public` is for caches that need to be shared.

**PHP8**
```php
use Psr\Cache\CacheItemPoolInterface;
use Ray\PsrCacheModule\Annotation\Local;
Expand All @@ -25,32 +24,6 @@ class Foo
}
```

**PHP7.4**

```php
use Psr\Cache\CacheItemPoolInterface;
use Ray\PsrCacheModule\Annotation\Local;
use Ray\PsrCacheModule\Annotation\Shared;

class Foo
{
private CacheItemPoolInterface $localPool;
private CacheItemPoolInterface $sharedPool;

/**
* @Local('localPool')
* @Shared('sharedPool')
*/
public function __construct(
CacheItemPoolInterface $localPool,
CacheItemPoolInterface $sharedPool
){
$this->localPool = $localPool;
$this->sharedPool = $sharedPool;
}
}
```

Create object graph

```php
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"files": ["src-files/apcu.php"]
},
"scripts": {
"setup": "php bin/setup.php",
"test": "./vendor/bin/phpunit",
"coverage": "php -dzend_extension=xdebug.so -dxdebug.mode=coverage ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage",
"pcov": "php -dextension=pcov.so -d pcov.enabled=1 ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage --coverage-clover=coverage.xml",
Expand All @@ -52,7 +51,8 @@
],
"sa": [
"./vendor/bin/phpstan analyse -c phpstan.neon",
"psalm --show-info=true"
"./vendor/bin/psalm --show-info=false",
"./vendor/bin/phpmd analyze src --format text --ruleset ./phpmd.xml"
],
"tests": [
"@cs",
Expand Down
4 changes: 2 additions & 2 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>

<!-- Compatibility with PHP 7.3.0 -->
<config name="php_version" value="70300"/>
<!-- Minimum supported PHP version -->
<config name="php_version" value="80200"/>

<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
Expand Down
2 changes: 0 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
<directory suffix=".php">src-deprecated</directory>
</exclude>
</source>
<coverage>
</coverage>
<testsuites>
<testsuite name="Ray.PsrCacheModule test suite">
<directory>tests</directory>
Expand Down
4 changes: 3 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?xml version="1.0"?>
<!-- ensureOverrideAttribute is off: #[Override] exists only from PHP 8.3 and the floor is 8.2 -->
<psalm
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor-bin/tools/vendor/vimeo/psalm/config.xsd"
phpVersion="8.2"
findUnusedBaselineEntry="false"
findUnusedCode="false"
ensureOverrideAttribute="false"
>
<projectFiles>
<directory name="src" />
Expand Down
7 changes: 5 additions & 2 deletions src/ApcuAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@

use function func_get_args;

/** @psalm-suppress PropertyNotSetInConstructor */
/**
* @psalm-api
* @psalm-suppress PropertyNotSetInConstructor
*/
class ApcuAdapter extends OriginAdapter
{
use SerializableTrait;

public function __construct(string $namespace = '', int $defaultLifetime = 0, ?string $directory = null, ?MarshallerInterface $marshaller = null)
public function __construct(string $namespace = '', int $defaultLifetime = 0, string|null $directory = null, MarshallerInterface|null $marshaller = null)
{
$this->args = func_get_args();

Expand Down
2 changes: 1 addition & 1 deletion src/CacheDirModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

final class CacheDirModule extends AbstractModule
{
public function __construct(private readonly string $cacheDir, ?AbstractModule $module = null)
public function __construct(private readonly string $cacheDir, AbstractModule|null $module = null)
{
parent::__construct($module);
}
Expand Down
2 changes: 1 addition & 1 deletion src/CacheNamespaceModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

final class CacheNamespaceModule extends AbstractModule
{
public function __construct(private readonly string $namespace, ?AbstractModule $module = null)
public function __construct(private readonly string $namespace, AbstractModule|null $module = null)
{
parent::__construct($module);
}
Expand Down
1 change: 1 addition & 0 deletions src/Exception/LogicException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Ray\PsrCacheModule\Exception;

/** @psalm-api */
class LogicException extends \LogicException
{
}
1 change: 1 addition & 0 deletions src/Exception/RedisConnectionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use RuntimeException;

/** @psalm-api */
class RedisConnectionException extends RuntimeException
{
}
1 change: 1 addition & 0 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Ray\PsrCacheModule\Exception;

/** @psalm-api */
class RuntimeException extends \RuntimeException
{
}
9 changes: 6 additions & 3 deletions src/FilesystemAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

use function func_get_args;

/** @psalm-suppress PropertyNotSetInConstructor */
/**
* @psalm-api
* @psalm-suppress PropertyNotSetInConstructor
*/
class FilesystemAdapter extends OriginAdapter
{
use SerializableTrait;
Expand All @@ -21,8 +24,8 @@ public function __construct(
string $namespace = '',
int $defaultLifetime = 0,
#[CacheDir]
?string $directory = null,
?MarshallerInterface $marshaller = null
string|null $directory = null,
MarshallerInterface|null $marshaller = null,
) {
$this->args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/MemcachedAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@

use function func_get_args;

/** @psalm-suppress PropertyNotSetInConstructor */
/**
* @psalm-api
* @psalm-suppress PropertyNotSetInConstructor
*/
class MemcachedAdapter extends OriginAdapter
{
use SerializableTrait;

public function __construct(MemcachedProvider $provider, string $namespace = '', int $defaultLifetime = 0, ?MarshallerInterface $marshaller = null)
public function __construct(MemcachedProvider $provider, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface|null $marshaller = null)
{
$this->args = func_get_args();

Expand Down
9 changes: 6 additions & 3 deletions src/MemcachedProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
use Ray\Di\ProviderInterface;
use Ray\PsrCacheModule\Annotation\MemcacheConfig;

/** @implements ProviderInterface<Memcached> */
/**
* @psalm-api
* @implements ProviderInterface<Memcached>
*/
class MemcachedProvider implements ProviderInterface
{
/**
Expand All @@ -21,12 +24,12 @@ public function __construct(
/**
* memcached server list
*/
private readonly array $servers
private readonly array $servers,
) {
}

/**
* {@inheritdoc}
* {@inheritDoc}
*/
public function get(): Memcached
{
Expand Down
9 changes: 6 additions & 3 deletions src/PhpFileAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

use function func_get_args;

/** @psalm-suppress PropertyNotSetInConstructor */
/**
* @psalm-api
* @psalm-suppress PropertyNotSetInConstructor
*/
class PhpFileAdapter extends OriginAdapter
{
use SerializableTrait;
Expand All @@ -18,8 +21,8 @@ public function __construct(
#[CacheNamespace]
string $namespace = '',
int $defaultLifetime = 0,
?string $directory = null,
bool $appendOnly = false
string|null $directory = null,
bool $appendOnly = false,
) {
$this->args = func_get_args();

Expand Down
2 changes: 1 addition & 1 deletion src/Psr6MemcachedModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class Psr6MemcachedModule extends AbstractModule
/** @var list<list<string>> */
private $servers;

public function __construct(string $servers, ?AbstractModule $module = null)
public function __construct(string $servers, AbstractModule|null $module = null)
{
$this->servers = array_map(static fn ($serverString) => explode(':', $serverString), explode(',', $servers));

Expand Down
2 changes: 1 addition & 1 deletion src/Psr6RedisModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class Psr6RedisModule extends AbstractModule
/** @var list<string> */
private $server;

public function __construct(string $server, ?AbstractModule $module = null)
public function __construct(string $server, AbstractModule|null $module = null)
{
$this->server = explode(':', $server);

Expand Down
7 changes: 5 additions & 2 deletions src/RedisAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@

use function func_get_args;

/** @psalm-suppress PropertyNotSetInConstructor */
/**
* @psalm-api
* @psalm-suppress PropertyNotSetInConstructor
*/
class RedisAdapter extends OriginAdapter
{
use SerializableTrait;
Expand All @@ -25,7 +28,7 @@ public function __construct(
#[CacheNamespace]
string $namespace = '',
int $defaultLifetime = 0,
?MarshallerInterface $marshaller = null
MarshallerInterface|null $marshaller = null,
) {
$this->args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/RedisProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

use function sprintf;

/** @implements ProviderInterface<Redis> */
/**
* @psalm-api
* @implements ProviderInterface<Redis>
*/
class RedisProvider implements ProviderInterface
{
/** @param list<string> $server */
Expand All @@ -21,7 +24,7 @@ public function __construct(private array $server)
}

/**
* {@inheritdoc}
* {@inheritDoc}
*/
public function get(): Redis
{
Expand Down
Loading
Loading