diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index 8ec0be8..76531a0 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: ['8.1', '8.2', '8.3', '8.4'] + php-version: ['8.2', '8.3', '8.4', '8.5'] steps: - uses: shivammathur/setup-php@v2 with: diff --git a/.gitignore b/.gitignore index f4a98a5..dd601e8 100644 --- a/.gitignore +++ b/.gitignore @@ -107,3 +107,4 @@ modules.xml coverage /.php-cs-fixer.cache +/.phpunit.result.cache diff --git a/Makefile b/Makefile index 29a6055..abf3852 100644 --- a/Makefile +++ b/Makefile @@ -2,5 +2,5 @@ test: php vendor/bin/rector php vendor/bin/php-cs-fixer fix --ansi -vvv - php vendor/bin/phpunit php vendor/bin/phpstan analyse -c phpstan.neon + php vendor/bin/phpunit diff --git a/composer.json b/composer.json index d09c151..ea42424 100644 --- a/composer.json +++ b/composer.json @@ -10,16 +10,16 @@ } ], "require": { - "php": ">=8.1", + "php": ">=8.2", "psr/cache": "^1.0 || ^2.0 || ^3.0", - "symfony/serializer": ">=5.4", - "symfony/cache": ">=5.4", + "symfony/serializer": ">=6.4", + "symfony/cache": ">=6.4", "doctrine/collections": ">=1.6" }, "require-dev": { "phpstan/phpstan": "^2.1.4", "phpunit/phpunit": "^9.5", - "symfony/property-access": ">=5.4", + "symfony/property-access": ">=6.4", "friendsofphp/php-cs-fixer": "^3.68", "rector/rector": "^2.1" }, diff --git a/rector.php b/rector.php index 71f22d2..b61f05b 100644 --- a/rector.php +++ b/rector.php @@ -9,7 +9,7 @@ __DIR__ . '/src', __DIR__ . '/tests', ]) - ->withPhpSets(php81: true) + ->withPhpSets(php82: true) ->withComposerBased(doctrine: true, phpunit: true, symfony: true) ->withTypeCoverageLevel(0) ->withDeadCodeLevel(0) diff --git a/src/AbstractCycleAwareWalker.php b/src/AbstractCycleAwareWalker.php index 5c0f866..9e84ccc 100644 --- a/src/AbstractCycleAwareWalker.php +++ b/src/AbstractCycleAwareWalker.php @@ -6,7 +6,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use Symfony\Component\Serializer\Annotation as Serializer; +use Symfony\Component\Serializer\Attribute as Serializer; abstract class AbstractCycleAwareWalker extends AbstractWalker { @@ -23,15 +23,19 @@ abstract class AbstractCycleAwareWalker extends AbstractWalker * infinite loop. * * {@inheritDoc} + * + * @return Collection + * + * @psalm-return Collection */ public function getChildren(): Collection { $root = $this->getRoot(); if ($root->registerItem($this->getItem())) { return parent::getChildren(); - } else { - return new ArrayCollection(); } + + return new ArrayCollection(); } /** diff --git a/src/AbstractWalker.php b/src/AbstractWalker.php index 8133f06..5726be8 100644 --- a/src/AbstractWalker.php +++ b/src/AbstractWalker.php @@ -11,7 +11,7 @@ use RZ\TreeWalker\Definition\StoppableDefinition; use RZ\TreeWalker\Exception\WalkerDefinitionNotFound; use Symfony\Component\Cache\Adapter\ArrayAdapter; -use Symfony\Component\Serializer\Annotation as Serializer; +use Symfony\Component\Serializer\Attribute as Serializer; abstract class AbstractWalker implements WalkerInterface { @@ -24,7 +24,7 @@ abstract class AbstractWalker implements WalkerInterface private WalkerInterface $root; /** - * @var Collection|null + * @var Collection|null */ #[Serializer\Groups(['children'])] private ?Collection $children = null; @@ -32,10 +32,8 @@ abstract class AbstractWalker implements WalkerInterface /** * @var int<0,max>|null */ - #[ - Serializer\Groups(['children_count']), - Serializer\SerializedName(serializedName: 'childrenCount') - ] + #[Serializer\Groups(['children_count'])] + #[Serializer\SerializedName(serializedName: 'childrenCount')] private ?int $count = null; #[Serializer\Groups(['walker_metadata'])] @@ -140,6 +138,10 @@ public function getItem(): ?object } /** + * @return Collection + * + * @psalm-return Collection + * * @throws \RuntimeException * @throws InvalidArgumentException */ @@ -153,6 +155,10 @@ public function getChildren(): Collection } /** + * @return Collection + * + * @psalm-return Collection + * * @throws InvalidArgumentException */ private function doGetChildren(): Collection diff --git a/src/Serializer/TreeWalkerNormalizer.php b/src/Serializer/TreeWalkerNormalizer.php index ae3ca00..a675772 100644 --- a/src/Serializer/TreeWalkerNormalizer.php +++ b/src/Serializer/TreeWalkerNormalizer.php @@ -11,9 +11,9 @@ use Symfony\Component\Serializer\SerializerAwareInterface; use Symfony\Component\Serializer\SerializerInterface; -final class TreeWalkerNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface +final readonly class TreeWalkerNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface { - public function __construct(private readonly DenormalizerInterface&NormalizerInterface $decorated) + public function __construct(private DenormalizerInterface&NormalizerInterface $decorated) { } @@ -59,14 +59,12 @@ public function normalize(mixed $object, ?string $format = null, array $context public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool { - // Symfony 5.4 BC - return $this->decorated->supportsNormalization($data, $format); + return $this->decorated->supportsNormalization($data, $format, $context); } public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool { - // Symfony 5.4 BC - return $this->decorated->supportsDenormalization($data, $type, $format); + return $this->decorated->supportsDenormalization($data, $type, $format, $context); } /**