Skip to content

Commit

Permalink
Make constructor default values consistent
Browse files Browse the repository at this point in the history
Set default value for 'value' property in multiple annotations for consistency and improve flexibility. Additionally, update PHP dependencies and requirements to align with compatibility goals.
  • Loading branch information
koriym committed Jan 9, 2025
1 parent 30e4685 commit 63bc7bd
Show file tree
Hide file tree
Showing 12 changed files with 193 additions and 515 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
}
],
"require": {
"php": "^7.3 || ^8.0",
"php": "^8.1",
"psr/cache": "^1.0.1 || ^2.0 || ^3.0",
"ray/di": "^2.13.2",
"symfony/cache": "^5.3.4 || ^6.0 || ^7.1",
"symfony/cache": "^6.0 || ^7.2",
"doctrine/annotations": "^1.13 || ^2.0",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0",
"ray/aop": "^2.10.4"
Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/CacheDir.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#[Qualifier]
final class CacheDir
{
public function __construct(public string $value)
public function __construct(public string $value = '')
{
}
}
2 changes: 1 addition & 1 deletion src/Annotation/CacheNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#[Qualifier]
final class CacheNamespace
{
public function __construct(public string $value)
public function __construct(public string $value = '')
{
}
}
2 changes: 1 addition & 1 deletion src/Annotation/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#[Qualifier]
final class Local
{
public function __construct(public string $value = 'cache')
public function __construct(public string $value = '')
{
}
}
2 changes: 1 addition & 1 deletion src/Annotation/MemcacheConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#[Qualifier]
final class MemcacheConfig
{
public function __construct(public string $value)
public function __construct(public string $value = '')
{
}
}
2 changes: 1 addition & 1 deletion src/Annotation/RedisConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#[Qualifier]
final class RedisConfig
{
public function __construct(public string $value)
public function __construct(public string $value = '')
{
}
}
6 changes: 5 additions & 1 deletion src/Annotation/RedisInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@

/**
* @Annotation
* @Qualifier()
* @Qualifier
* @NamedArgumentConstructor
*/
#[Attribute]
#[Qualifier]
final class RedisInstance
{
public function __construct(public string $value = '')
{
}
}
2 changes: 1 addition & 1 deletion src/Annotation/Shared.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#[Qualifier]
final class Shared
{
public function __construct(public string $value = 'cache')
public function __construct(public string $value = '')
{
}
}
16 changes: 8 additions & 8 deletions src/FilesystemAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class FilesystemAdapter extends OriginAdapter implements Serializable
{
use SerializableTrait;

/**
* @CacheNamespace("namespace")
* @CacheDir("directory")
*/
#[CacheNamespace('namespace')]
#[CacheDir('directory')]
public function __construct(string $namespace = '', int $defaultLifetime = 0, ?string $directory = null, ?MarshallerInterface $marshaller = null)
{
public function __construct(
#[CacheNamespace]
string $namespace = '',
int $defaultLifetime = 0,
#[CacheDir]
?string $directory = null,
?MarshallerInterface $marshaller = null
) {
$this->args = func_get_args();

parent::__construct($namespace, $defaultLifetime, $directory, $marshaller);
Expand Down
11 changes: 7 additions & 4 deletions src/PhpFileAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ class PhpFileAdapter extends OriginAdapter implements Serializable
{
use SerializableTrait;

/** @CacheNamespace("namespace") */
#[CacheNamespace('namespace')]
public function __construct(string $namespace = '', int $defaultLifetime = 0, ?string $directory = null, bool $appendOnly = false)
{
public function __construct(
#[CacheNamespace]
string $namespace = '',
int $defaultLifetime = 0,
?string $directory = null,
bool $appendOnly = false
) {
$this->args = func_get_args();

parent::__construct($namespace, $defaultLifetime, $directory, $appendOnly);
Expand Down
19 changes: 9 additions & 10 deletions src/RedisAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ class RedisAdapter extends OriginAdapter implements Serializable
{
use SerializableTrait;

/**
* @param ProviderInterface<Redis> $redisProvider
*
* @CacheNamespace("namespace")
* @Named("redisProvider=redis")
*/
#[CacheNamespace('namespace')]
#[Named('redisProvider=redis')]
public function __construct(ProviderInterface $redisProvider, string $namespace = '', int $defaultLifetime = 0, ?MarshallerInterface $marshaller = null)
{
/** @param ProviderInterface<Redis> $redisProvider */
public function __construct(
#[Named('redis')]
ProviderInterface $redisProvider,
#[CacheNamespace]
string $namespace = '',
int $defaultLifetime = 0,
?MarshallerInterface $marshaller = null
) {
$this->args = func_get_args();

parent::__construct($redisProvider->get(), $namespace, $defaultLifetime, $marshaller);
Expand Down
Loading

0 comments on commit 63bc7bd

Please sign in to comment.