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
29 changes: 13 additions & 16 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Ray\AnnotationBinding\Rector\ClassMethod\AnnotationBindingRector;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
return RectorConfig::configure()
->withPaths([
__DIR__ . '/demo',
__DIR__ . '/src',
__DIR__ . '/src-annotation',
__DIR__ . '/tests/*/*Test.php',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
$rectorConfig->rule(AnnotationBindingRector::class);
// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_81,
]);
};
__DIR__ . '/src-annotation-deprecated',
__DIR__ . '/tests',
__DIR__ . '/tests-pecl-ext',
__DIR__ . '/tests-php8',
])
// uncomment to reach your current PHP version
->withPhpSets()
->withTypeCoverageLevel(0)
->withDeadCodeLevel(0)
->withCodeQualityLevel(0);
8 changes: 1 addition & 7 deletions src-annotation-deprecated/CacheVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_PARAMETER), Qualifier]
final class CacheVersion
{
/**
* @var string
*/
public $value;

public function __construct(string $value)
public function __construct(public string $value)
{
$this->value = $value;
}
}
2 changes: 0 additions & 2 deletions src-annotation/Commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Attribute;
use Ray\Di\Di\Qualifier;

/**
*/
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_PARAMETER)]
#[Qualifier]
final class Commands
Expand Down
4 changes: 1 addition & 3 deletions src-annotation/RefreshCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
use Attribute;
use BEAR\QueryRepository\DonutCommandInterceptor;

/**
* @see DonutCommandInterceptor
*/
/** @see DonutCommandInterceptor */
#[Attribute(Attribute::TARGET_METHOD)]
final class RefreshCache
{
Expand Down
4 changes: 2 additions & 2 deletions src/CacheDependency.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
use function assert;
use function sprintf;

final class CacheDependency implements CacheDependencyInterface
final readonly class CacheDependency implements CacheDependencyInterface
{
public function __construct(
private readonly UriTagInterface $uriTag,
private UriTagInterface $uriTag,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/CacheInterceptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

use const E_USER_WARNING;

final class CacheInterceptor implements MethodInterceptor
final readonly class CacheInterceptor implements MethodInterceptor
{
public function __construct(
private readonly QueryRepositoryInterface $repository,
private QueryRepositoryInterface $repository,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Cdn/FastlyCachePurger.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use BEAR\QueryRepository\PurgerInterface;
use Override;

final class FastlyCachePurger implements PurgerInterface
final readonly class FastlyCachePurger implements PurgerInterface
{
public function __construct(private readonly FastlyCachePurgerInterface $fastlyCachePurger)
public function __construct(private FastlyCachePurgerInterface $fastlyCachePurger)
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/CliHttpCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

use const PHP_EOL;

final class CliHttpCache implements HttpCacheInterface
final readonly class CliHttpCache implements HttpCacheInterface
{
public function __construct(
private readonly ResourceStorageInterface $storage,
private ResourceStorageInterface $storage,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/CommandInterceptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
use Ray\Aop\MethodInterceptor;
use Ray\Aop\MethodInvocation;

final class CommandInterceptor implements MethodInterceptor
final readonly class CommandInterceptor implements MethodInterceptor
{
/** @param CommandInterface[] $commands */
public function __construct(
#[Commands]
private readonly array $commands,
private array $commands,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/CommandsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use Ray\Di\ProviderInterface;

/** @implements ProviderInterface<array<CommandInterface>> */
final class CommandsProvider implements ProviderInterface
final readonly class CommandsProvider implements ProviderInterface
{
public function __construct(
private readonly RefreshSameCommand $refreshSameCommand,
private readonly RefreshAnnotatedCommand $refreshAnnotatedCommand,
private RefreshSameCommand $refreshSameCommand,
private RefreshAnnotatedCommand $refreshAnnotatedCommand,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/DevEtagSetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

use function gmdate;

final class DevEtagSetter implements EtagSetterInterface
final readonly class DevEtagSetter implements EtagSetterInterface
{
public function __construct(
private readonly CacheDependencyInterface $cacheDeperency,
private CacheDependencyInterface $cacheDeperency,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/DonutCommandInterceptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
use function is_callable;
use function sprintf;

final class DonutCommandInterceptor implements MethodInterceptor
final readonly class DonutCommandInterceptor implements MethodInterceptor
{
public function __construct(
private readonly DonutRepositoryInterface $repository,
private readonly MatchQueryInterface $matchQuery
private DonutRepositoryInterface $repository,
private MatchQueryInterface $matchQuery
){
}

Expand Down
16 changes: 8 additions & 8 deletions src/DonutRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
use function assert;
use function explode;

final class DonutRepository implements DonutRepositoryInterface
final readonly class DonutRepository implements DonutRepositoryInterface
{
public function __construct(
private readonly QueryRepositoryInterface $queryRepository,
private readonly HeaderSetter $headerSetter,
private readonly ResourceStorageInterface $resourceStorage,
private readonly ResourceInterface $resource,
private readonly CdnCacheControlHeaderSetterInterface $cdnCacheControlHeaderSetter,
private readonly RepositoryLoggerInterface $logger,
private readonly DonutRendererInterface $renderer,
private QueryRepositoryInterface $queryRepository,
private HeaderSetter $headerSetter,
private ResourceStorageInterface $resourceStorage,
private ResourceInterface $resource,
private CdnCacheControlHeaderSetterInterface $cdnCacheControlHeaderSetter,
private RepositoryLoggerInterface $logger,
private DonutRendererInterface $renderer,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions src/DonutRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

use function sprintf;

final class DonutRequest implements Stringable
final readonly class DonutRequest implements Stringable
{
public function __construct(
private readonly AbstractRequest $request,
private readonly DonutRendererInterface $donutStorage,
private readonly SurrogateKeys $etags,
private AbstractRequest $request,
private DonutRendererInterface $donutStorage,
private SurrogateKeys $etags,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/EtagSetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
use function serialize;
use function time;

final class EtagSetter implements EtagSetterInterface
final readonly class EtagSetter implements EtagSetterInterface
{
public function __construct(
private readonly CacheDependencyInterface $cacheDeperency,
private CacheDependencyInterface $cacheDeperency,
) {
}

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

namespace BEAR\QueryRepository;

final class Expiry
final readonly class Expiry
{
/** @var array<string, int> */
private readonly array $time;
private array $time;

public function __construct(int $short = 60, int $medium = 3600, int $long = 86400, int $never = 31_536_000)
{
Expand Down
4 changes: 2 additions & 2 deletions src/HeaderSetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
use function sprintf;
use function str_contains;

final class HeaderSetter
final readonly class HeaderSetter
{
public function __construct(
private readonly EtagSetterInterface $etagSetter,
private EtagSetterInterface $etagSetter,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/HttpCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
use function http_response_code;

/** @psalm-suppress DeprecatedInterface for BC */
final class HttpCache implements HttpCacheInterface, DeprecatedHttpCacheInterface
final readonly class HttpCache implements HttpCacheInterface, DeprecatedHttpCacheInterface
{
public function __construct(
private readonly ResourceStorageInterface $storage,
private ResourceStorageInterface $storage,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/MarshallerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
*
* @implements ProviderInterface<MarshallerInterface|null>
*/
final class MarshallerProvider implements ProviderInterface
final readonly class MarshallerProvider implements ProviderInterface
{
/** @param array{enabled?: bool, type?: string, use_igbinary?: bool} $options Marshalling options */
public function __construct(
#[MarshallerOptions]
private readonly array $options = [],
private array $options = [],
) {
}

Expand Down
10 changes: 5 additions & 5 deletions src/QueryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
use function strtotime;
use function time;

final class QueryRepository implements QueryRepositoryInterface
final readonly class QueryRepository implements QueryRepositoryInterface
{
public function __construct(
private readonly RepositoryLoggerInterface $logger,
private readonly HeaderSetter $headerSetter,
private readonly ResourceStorageInterface $storage,
private readonly Expiry $expiry,
private RepositoryLoggerInterface $logger,
private HeaderSetter $headerSetter,
private ResourceStorageInterface $storage,
private Expiry $expiry,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/RedisDsnProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Symfony\Component\Cache\Adapter\RedisAdapter;

/** @implements ProviderInterface<Redis|RedisArray|RedisCluster|ClientInterface|Relay|RelayCluster> */
final class RedisDsnProvider implements ProviderInterface
final readonly class RedisDsnProvider implements ProviderInterface
{
/**
* @param string $dns Redis DSN
Expand Down
6 changes: 3 additions & 3 deletions src/RefreshAnnotatedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
use function is_array;
use function uri_template;

final class RefreshAnnotatedCommand implements CommandInterface
final readonly class RefreshAnnotatedCommand implements CommandInterface
{
public function __construct(
private readonly QueryRepositoryInterface $repository,
private readonly ResourceInterface $resource,
private QueryRepositoryInterface $repository,
private ResourceInterface $resource,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/RefreshInterceptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
use Ray\Aop\MethodInterceptor;
use Ray\Aop\MethodInvocation;

final class RefreshInterceptor implements MethodInterceptor
final readonly class RefreshInterceptor implements MethodInterceptor
{
public function __construct(
private readonly RefreshAnnotatedCommand $command,
private RefreshAnnotatedCommand $command,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/RefreshSameCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

// phpcs:ignoreFile SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing -- for call_user_func_array

final class RefreshSameCommand implements CommandInterface
final readonly class RefreshSameCommand implements CommandInterface
{
public function __construct(
private readonly QueryRepositoryInterface $repository,
private readonly MatchQueryInterface $matchQuery
private QueryRepositoryInterface $repository,
private MatchQueryInterface $matchQuery
){
}

Expand Down
2 changes: 1 addition & 1 deletion tests-pecl-ext/StorageRedisDsnModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function tearDownAfterClass(): void

protected function setUp(): void
{
$this->dsn = getenv('REDIS_SERVER') ? getenv('REDIS_SERVER') : 'localhost:6379';
$this->dsn = getenv('REDIS_SERVER') ?: 'localhost:6379';
}

public function testNew(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Fake/FakeMobileEtagSetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FakeMobileEtagSetter implements EtagSetterInterface
public static $device;

public function __construct(
private MobileEtagSetter $mobileEtagSetter
private readonly MobileEtagSetter $mobileEtagSetter
){
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BlogPostingCacheControl extends ResourceObject
];

public function __construct(
private DonutRepositoryInterface $repository
private readonly DonutRepositoryInterface $repository
){
}

Expand Down
Loading
Loading