Skip to content

Commit 0a2863c

Browse files
feat!: Removed jms/serializer dependency and attributes.
1 parent fc65151 commit 0a2863c

18 files changed

+131
-255
lines changed

.github/workflows/run-test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
strategy:
1919
matrix:
20-
php-version: ['8.1', '8.2', '8.3']
20+
php-version: ['8.1', '8.2', '8.3', '8.4']
2121
steps:
2222
- uses: shivammathur/setup-php@v2
2323
with:
@@ -33,8 +33,8 @@ jobs:
3333
${{ runner.os }}-php-${{ matrix.php-version }}-
3434
- name: Install Dependencies
3535
run: composer install --no-scripts --no-ansi --no-interaction --no-progress
36-
- name: Run PHP Code Sniffer
37-
run: vendor/bin/phpcs -p ./src
36+
- name: Run PHP Code Style Fixer
37+
run: vendor/bin/php-cs-fixer check --ansi -vvv
3838
- name: Run unit tests
3939
run: vendor/bin/phpunit
4040
- name: Run PHPStan

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,4 @@ modules.xml
106106
# End of https://www.gitignore.io/api/composer,phpstorm+all
107107

108108
coverage
109+
/.php-cs-fixer.cache

.php-cs-fixer.dist.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
$finder = (new PhpCsFixer\Finder())
4+
->in([
5+
__DIR__.'/tests',
6+
__DIR__.'/src',
7+
])
8+
;
9+
10+
return (new PhpCsFixer\Config())
11+
->setRules([
12+
'@Symfony' => true,
13+
'blank_line_after_opening_tag' => true,
14+
'declare_strict_types' => true,
15+
])
16+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
17+
->setRiskyAllowed(true)
18+
->setFinder($finder)
19+
;

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MIT License
22
-----------
33

4-
Copyright (c) 2024 Rezo Zero
4+
Copyright (c) 2025 Rezo Zero
55
Permission is hereby granted, free of charge, to any person
66
obtaining a copy of this software and associated documentation
77
files (the "Software"), to deal in the Software without

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

22
test:
3-
php vendor/bin/phpcbf -p
3+
php vendor/bin/php-cs-fixer fix --ansi -vvv
44
php vendor/bin/phpunit
55
php vendor/bin/phpstan analyse -c phpstan.neon

composer.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@
1212
"require": {
1313
"php": ">=8.1",
1414
"psr/cache": "^1.0 || ^2.0 || ^3.0",
15-
"jms/serializer": "^3.7",
1615
"symfony/serializer": ">=5.4",
1716
"symfony/cache": ">=5.4",
1817
"doctrine/collections": ">=1.6"
1918
},
2019
"require-dev": {
21-
"squizlabs/php_codesniffer": "^3.3",
22-
"phpstan/phpstan": "^1.8.2",
20+
"phpstan/phpstan": "^2.1.4",
2321
"phpunit/phpunit": "^9.5",
24-
"symfony/property-access": ">=5.4"
22+
"symfony/property-access": ">=5.4",
23+
"friendsofphp/php-cs-fixer": "^3.68"
2524
},
2625
"autoload": {
2726
"psr-4": {

phpstan.neon

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ parameters:
66
- identifier: missingType.iterableValue
77
- identifier: missingType.generics
88
reportUnmatchedIgnoredErrors: false
9+
treatPhpDocTypesAsCertain: false

src/AbstractCycleAwareWalker.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,23 @@
66

77
use Doctrine\Common\Collections\ArrayCollection;
88
use Doctrine\Common\Collections\Collection;
9-
use JMS\Serializer\Annotation as Serializer;
10-
use Symfony\Component\Serializer\Annotation as SymfonySerializer;
9+
use Symfony\Component\Serializer\Annotation as Serializer;
1110

1211
abstract class AbstractCycleAwareWalker extends AbstractWalker
1312
{
1413
public const MAX_CALL = 99;
1514

16-
#[
17-
Serializer\Exclude,
18-
SymfonySerializer\Ignore
19-
]
15+
/**
16+
* @var array<int, int>
17+
*/
18+
#[Serializer\Ignore]
2019
private array $itemIds = [];
2120

2221
/**
2322
* Prevent Walker to collect duplicate objects and enter into
2423
* infinite loop.
2524
*
26-
* @inheritDoc
25+
* {@inheritDoc}
2726
*/
2827
public function getChildren(): Collection
2928
{
@@ -36,7 +35,6 @@ public function getChildren(): Collection
3635
}
3736

3837
/**
39-
* @param object|null $item
4038
* @return bool Return TRUE if item has not overpassed the MAX_CALL limit
4139
*/
4240
protected function registerItem(?object $item): bool
@@ -47,12 +45,14 @@ protected function registerItem(?object $item): bool
4745
$itemId = \spl_object_id($item);
4846
if (!array_key_exists($itemId, $this->itemIds)) {
4947
$this->itemIds[$itemId] = 1;
48+
5049
return true;
5150
}
52-
$this->itemIds[$itemId]++;
51+
++$this->itemIds[$itemId];
5352
if ($this->itemIds[$itemId] <= self::MAX_CALL) {
5453
return true;
5554
}
55+
5656
return false;
5757
}
5858
}

0 commit comments

Comments
 (0)