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
2 changes: 1 addition & 1 deletion .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ modules.xml

coverage
/.php-cs-fixer.cache
/.phpunit.result.cache
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions src/AbstractCycleAwareWalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -23,15 +23,19 @@ abstract class AbstractCycleAwareWalker extends AbstractWalker
* infinite loop.
*
* {@inheritDoc}
*
* @return Collection<int, static>
*
* @psalm-return Collection<int, static>
*/
public function getChildren(): Collection
{
$root = $this->getRoot();
if ($root->registerItem($this->getItem())) {
return parent::getChildren();
} else {
return new ArrayCollection();
}

return new ArrayCollection();
}

/**
Expand Down
18 changes: 12 additions & 6 deletions src/AbstractWalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -24,18 +24,16 @@ abstract class AbstractWalker implements WalkerInterface
private WalkerInterface $root;

/**
* @var Collection<static>|null
* @var Collection<int, static>|null
*/
#[Serializer\Groups(['children'])]
private ?Collection $children = null;

/**
* @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'])]
Expand Down Expand Up @@ -140,6 +138,10 @@ public function getItem(): ?object
}

/**
* @return Collection<int, static>
*
* @psalm-return Collection<int, static>
*
* @throws \RuntimeException
* @throws InvalidArgumentException
*/
Expand All @@ -153,6 +155,10 @@ public function getChildren(): Collection
}

/**
* @return Collection<int, static>
*
* @psalm-return Collection<int, static>
*
* @throws InvalidArgumentException
*/
private function doGetChildren(): Collection
Expand Down
10 changes: 4 additions & 6 deletions src/Serializer/TreeWalkerNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down Expand Up @@ -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);
}

/**
Expand Down