diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f135f73d3cc..7475eb332a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,6 +74,45 @@ jobs: - name: Run PHP-CS-Fixer fix run: php-cs-fixer fix --dry-run --diff --ansi --show-progress=none + rector: + name: Rector (PHP ${{ matrix.php }}) + runs-on: ubuntu-latest + timeout-minutes: 20 + strategy: + matrix: + php: + - '8.3' + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v6 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: intl, bcmath, curl, openssl, mbstring, mongodb + ini-values: memory_limit=-1 + tools: composer + coverage: none + - name: Get composer cache directory + id: composercache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - name: Cache dependencies + uses: actions/cache@v5 + with: + path: ${{ steps.composercache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + - name: Update project dependencies + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . + - name: Install Rector + run: composer require --dev rector/rector + - name: Run Rector + run: ./vendor/bin/rector process --dry-run --ansi --no-progress-bar + lint-container: name: Lint Container runs-on: ubuntu-latest diff --git a/composer.json b/composer.json index 010f3445d25..5e50a3b38dc 100644 --- a/composer.json +++ b/composer.json @@ -160,6 +160,7 @@ "psr/log": "^1.0 || ^2.0 || ^3.0", "ramsey/uuid": "^4.7", "ramsey/uuid-doctrine": "^2.0", + "rector/rector": "^2.3", "soyuka/contexts": "^3.3.10", "soyuka/pmu": "^0.2.0", "soyuka/stubs-mongodb": "^1.0", diff --git a/rector.php b/rector.php new file mode 100644 index 00000000000..ae108c278ec --- /dev/null +++ b/rector.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +use Rector\Config\RectorConfig; +use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector; + +return RectorConfig::configure() + ->withPaths([ + __DIR__.'/src', + __DIR__.'/tests', + ]) + ->withSkip([ + __DIR__.'/src/Core/Bridge/Symfony/Maker/Resources/skeleton', + __DIR__.'/src/Laravel/Console/Maker/Resources/skeleton', + __DIR__.'/src/Laravel/config', + __DIR__.'/tests/Fixtures/app/var', + __DIR__.'/docs/guides', + __DIR__.'/docs/var', + __DIR__.'/src/Doctrine/Orm/Tests/var', + __DIR__.'/src/Doctrine/Odm/Tests/var', + __DIR__.'/tests/Fixtures/app/config/reference.php', + __DIR__.'/src/Symfony/Bundle/DependencyInjection/Configuration.php', + __DIR__.'/tests/Fixer/SymfonyServiceClassConstantFixer.php', + RemoveUnusedPromotedPropertyRector::class => [ + __DIR__ . '/tests/Fixtures/TestBundle/Filter/SearchTextAndDateFilter.php', + __DIR__ . '/tests/Fixtures/TestBundle/Filter/ODMSearchTextAndDateFilter.php', + ], + ]) + // uncomment to reach your current PHP version + // ->withPhpSets() + ->withPreparedSets( + typeDeclarations: true, + deadCode: true, + ) + ->withCodeQualityLevel(0); diff --git a/src/Doctrine/Common/Filter/BackedEnumFilterTrait.php b/src/Doctrine/Common/Filter/BackedEnumFilterTrait.php index 6820ed9754d..bce0d049429 100644 --- a/src/Doctrine/Common/Filter/BackedEnumFilterTrait.php +++ b/src/Doctrine/Common/Filter/BackedEnumFilterTrait.php @@ -59,7 +59,7 @@ public function getDescription(string $resourceClass): array foreach ($filterParameterNames as $filterParameterName) { $isCollection = str_ends_with($filterParameterName, '[]'); - $enumValues = array_map(static fn (\BackedEnum $case) => $case->value, $this->enumTypes[$property]::cases()); + $enumValues = array_map(static fn (\BackedEnum $case): int|string => $case->value, $this->enumTypes[$property]::cases()); $schema = $isCollection ? ['type' => 'array', 'items' => ['type' => 'string', 'enum' => $enumValues]] @@ -99,7 +99,7 @@ private function normalizeValue(mixed $value, string $property): mixed $value = (int) $value; } - $values = array_map(static fn (\BackedEnum $case) => $case->value, $this->enumTypes[$property]::cases()); + $values = array_map(static fn (\BackedEnum $case): int|string => $case->value, $this->enumTypes[$property]::cases()); if (\in_array($value, $values, true)) { return $value; diff --git a/src/Doctrine/Common/Messenger/DispatchTrait.php b/src/Doctrine/Common/Messenger/DispatchTrait.php index ece731d42ec..670c2e95d70 100644 --- a/src/Doctrine/Common/Messenger/DispatchTrait.php +++ b/src/Doctrine/Common/Messenger/DispatchTrait.php @@ -24,9 +24,6 @@ trait DispatchTrait { private ?MessageBusInterface $messageBus; - /** - * @param object|Envelope $message - */ private function dispatch(object $message): Envelope { if (!$this->messageBus instanceof MessageBusInterface) { diff --git a/src/Doctrine/Common/State/LinksHandlerLocatorTrait.php b/src/Doctrine/Common/State/LinksHandlerLocatorTrait.php index deeba0fa4b5..0f8e324f2b7 100644 --- a/src/Doctrine/Common/State/LinksHandlerLocatorTrait.php +++ b/src/Doctrine/Common/State/LinksHandlerLocatorTrait.php @@ -58,7 +58,7 @@ private function findSimilarMethod(string $className, string $methodName): ?stri { $methods = get_class_methods($className); - $similarMethods = array_filter($methods, static function ($method) use ($methodName) { + $similarMethods = array_filter($methods, static function ($method) use ($methodName): bool { return levenshtein($methodName, $method) <= 3; }); diff --git a/src/Doctrine/Common/State/PersistProcessor.php b/src/Doctrine/Common/State/PersistProcessor.php index 2afd1f368ab..f603e0cfa97 100644 --- a/src/Doctrine/Common/State/PersistProcessor.php +++ b/src/Doctrine/Common/State/PersistProcessor.php @@ -196,7 +196,7 @@ private function handleLazyObjectRelations(object $data, DoctrineObjectManager $ $identifiers = $metadata->getIdentifierValues($value); // Do not get reference for partial objects or objects with null identifiers - if (!$identifiers || \count($identifiers) !== \count(array_filter($identifiers, static fn ($v) => null !== $v))) { + if (!$identifiers || \count($identifiers) !== \count(array_filter($identifiers, static fn ($v): bool => null !== $v))) { continue; } diff --git a/src/Doctrine/Common/Tests/CollectionPaginatorTest.php b/src/Doctrine/Common/Tests/CollectionPaginatorTest.php index 18804e58632..9c0aa000af5 100644 --- a/src/Doctrine/Common/Tests/CollectionPaginatorTest.php +++ b/src/Doctrine/Common/Tests/CollectionPaginatorTest.php @@ -21,7 +21,7 @@ class CollectionPaginatorTest extends TestCase { #[DataProvider('initializeProvider')] - public function testInitialize($results, $currentPage, $itemsPerPage, $totalItems, $lastPage, $currentItems): void + public function testInitialize(array $results, int $currentPage, int $itemsPerPage, int $totalItems, int $lastPage, int $currentItems): void { $results = new ArrayCollection($results); $paginator = new CollectionPaginator($results, $currentPage, $itemsPerPage); diff --git a/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/Dummy.php b/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/Dummy.php index ffc3edf77c3..c88bda70f6c 100644 --- a/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/Dummy.php +++ b/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/Dummy.php @@ -209,7 +209,7 @@ public function getDummyDate() return $this->dummyDate; } - public function setDummyPrice($dummyPrice) + public function setDummyPrice($dummyPrice): static { $this->dummyPrice = $dummyPrice; @@ -284,10 +284,7 @@ public function isDummyBoolean(): ?bool return $this->dummyBoolean; } - /** - * @param bool $dummyBoolean - */ - public function setDummyBoolean($dummyBoolean): void + public function setDummyBoolean(?bool $dummyBoolean): void { $this->dummyBoolean = $dummyBoolean; } diff --git a/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/EmbeddableDummy.php b/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/EmbeddableDummy.php index 3947be68b3c..6efdb230ebd 100644 --- a/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/EmbeddableDummy.php +++ b/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/EmbeddableDummy.php @@ -60,10 +60,6 @@ public static function staticMethod(): void { } - public function __construct() - { - } - public function getDummyName(): ?string { return $this->dummyName; diff --git a/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/RelatedDummy.php b/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/RelatedDummy.php index 46321b04379..39f659f39ab 100644 --- a/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/RelatedDummy.php +++ b/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/RelatedDummy.php @@ -148,10 +148,7 @@ public function isDummyBoolean(): ?bool return $this->dummyBoolean; } - /** - * @param bool $dummyBoolean - */ - public function setDummyBoolean($dummyBoolean): void + public function setDummyBoolean(?bool $dummyBoolean): void { $this->dummyBoolean = $dummyBoolean; } diff --git a/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/RelatedToDummyFriend.php b/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/RelatedToDummyFriend.php index b2dfe6e6082..fc72aa2d982 100644 --- a/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/RelatedToDummyFriend.php +++ b/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/RelatedToDummyFriend.php @@ -74,10 +74,7 @@ public function getDescription(): ?string return $this->description; } - /** - * @param string|null $description - */ - public function setDescription($description): void + public function setDescription(?string $description): void { $this->description = $description; } diff --git a/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/ThirdLevel.php b/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/ThirdLevel.php index b5343eca905..ba9b4cb86a8 100644 --- a/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/ThirdLevel.php +++ b/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/ThirdLevel.php @@ -61,10 +61,7 @@ public function getLevel(): ?int return $this->level; } - /** - * @param int $level - */ - public function setLevel($level): void + public function setLevel(int $level): void { $this->level = $level; } @@ -74,10 +71,7 @@ public function isTest(): bool return $this->test; } - /** - * @param bool $test - */ - public function setTest($test): void + public function setTest(bool $test): void { $this->test = $test; } diff --git a/src/Doctrine/Common/Tests/SelectablePaginatorTest.php b/src/Doctrine/Common/Tests/SelectablePaginatorTest.php index f877c0c941a..e638601ed71 100644 --- a/src/Doctrine/Common/Tests/SelectablePaginatorTest.php +++ b/src/Doctrine/Common/Tests/SelectablePaginatorTest.php @@ -21,7 +21,7 @@ class SelectablePaginatorTest extends TestCase { #[DataProvider('initializeProvider')] - public function testInitialize($results, $currentPage, $itemsPerPage, $totalItems, $lastPage, $currentItems): void + public function testInitialize(array $results, int $currentPage, int $itemsPerPage, int $totalItems, int $lastPage, int $currentItems): void { $results = new ArrayCollection($results); $paginator = new SelectablePaginator($results, $currentPage, $itemsPerPage); diff --git a/src/Doctrine/Common/Tests/SelectablePartialPaginatorTest.php b/src/Doctrine/Common/Tests/SelectablePartialPaginatorTest.php index 0721343ffb3..028313cd148 100644 --- a/src/Doctrine/Common/Tests/SelectablePartialPaginatorTest.php +++ b/src/Doctrine/Common/Tests/SelectablePartialPaginatorTest.php @@ -21,7 +21,7 @@ class SelectablePartialPaginatorTest extends TestCase { #[DataProvider('initializeProvider')] - public function testInitialize($results, $currentPage, $itemsPerPage, $currentItems): void + public function testInitialize(array $results, int $currentPage, int $itemsPerPage, int $currentItems): void { $results = new ArrayCollection($results); $paginator = new SelectablePartialPaginator($results, $currentPage, $itemsPerPage); diff --git a/src/Doctrine/Odm/Tests/Fixtures/Document/Dummy.php b/src/Doctrine/Odm/Tests/Fixtures/Document/Dummy.php index 92eab69cfc5..811fa7774b3 100644 --- a/src/Doctrine/Odm/Tests/Fixtures/Document/Dummy.php +++ b/src/Doctrine/Odm/Tests/Fixtures/Document/Dummy.php @@ -112,7 +112,7 @@ public function getId(): ?int return $this->id; } - public function setId($id): void + public function setId(?int $id): void { $this->id = $id; } @@ -167,7 +167,7 @@ public function getDummyDate() return $this->dummyDate; } - public function setDummyPrice($dummyPrice) + public function setDummyPrice($dummyPrice): static { $this->dummyPrice = $dummyPrice; diff --git a/src/Doctrine/Odm/Tests/Fixtures/Document/DummyFriend.php b/src/Doctrine/Odm/Tests/Fixtures/Document/DummyFriend.php index d9b73088005..0dbb28db0bd 100644 --- a/src/Doctrine/Odm/Tests/Fixtures/Document/DummyFriend.php +++ b/src/Doctrine/Odm/Tests/Fixtures/Document/DummyFriend.php @@ -48,7 +48,7 @@ public function getId(): ?int * * @param int $id the value to set */ - public function setId($id): void + public function setId(?int $id): void { $this->id = $id; } diff --git a/src/Doctrine/Odm/Tests/Fixtures/Document/EmbeddableDummy.php b/src/Doctrine/Odm/Tests/Fixtures/Document/EmbeddableDummy.php index 8bd82bdbe33..fbe606c235d 100644 --- a/src/Doctrine/Odm/Tests/Fixtures/Document/EmbeddableDummy.php +++ b/src/Doctrine/Odm/Tests/Fixtures/Document/EmbeddableDummy.php @@ -56,10 +56,6 @@ public static function staticMethod(): void { } - public function __construct() - { - } - public function getDummyName(): ?string { return $this->dummyName; diff --git a/src/Doctrine/Odm/Tests/Fixtures/Document/RelatedDummy.php b/src/Doctrine/Odm/Tests/Fixtures/Document/RelatedDummy.php index ecb3cfa75a6..8db50703327 100644 --- a/src/Doctrine/Odm/Tests/Fixtures/Document/RelatedDummy.php +++ b/src/Doctrine/Odm/Tests/Fixtures/Document/RelatedDummy.php @@ -100,10 +100,7 @@ public function isDummyBoolean(): ?bool return $this->dummyBoolean; } - /** - * @param bool $dummyBoolean - */ - public function setDummyBoolean($dummyBoolean): void + public function setDummyBoolean(?bool $dummyBoolean): void { $this->dummyBoolean = $dummyBoolean; } diff --git a/src/Doctrine/Odm/Tests/Fixtures/Document/RelatedToDummyFriend.php b/src/Doctrine/Odm/Tests/Fixtures/Document/RelatedToDummyFriend.php index 81f5647d89c..875e802c549 100644 --- a/src/Doctrine/Odm/Tests/Fixtures/Document/RelatedToDummyFriend.php +++ b/src/Doctrine/Odm/Tests/Fixtures/Document/RelatedToDummyFriend.php @@ -63,10 +63,7 @@ public function getDescription(): ?string return $this->description; } - /** - * @param string|null $description - */ - public function setDescription($description): void + public function setDescription(?string $description): void { $this->description = $description; } diff --git a/src/Doctrine/Orm/Filter/AbstractUuidFilter.php b/src/Doctrine/Orm/Filter/AbstractUuidFilter.php index 5f221fdc6b2..3725d56f6c0 100644 --- a/src/Doctrine/Orm/Filter/AbstractUuidFilter.php +++ b/src/Doctrine/Orm/Filter/AbstractUuidFilter.php @@ -63,10 +63,10 @@ public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $q throw new InvalidArgumentException(\sprintf('The filter parameter with key "%s" must specify a property. Nested properties are not automatically resolved. Please provide the property explicitly.', $parameter->getKey())); } - $this->filterProperty($parameter->getProperty(), $parameter->getValue(), $queryBuilder, $queryNameGenerator, $resourceClass, $operation, $context); + $this->filterProperty($parameter->getProperty(), $parameter->getValue(), $queryBuilder, $queryNameGenerator, $resourceClass); } - private function filterProperty(string $property, mixed $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void + private function filterProperty(string $property, mixed $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass): void { $alias = $queryBuilder->getRootAliases()[0]; $field = $property; diff --git a/src/Doctrine/Orm/Filter/BackedEnumFilter.php b/src/Doctrine/Orm/Filter/BackedEnumFilter.php index ab39bd0d405..95f810af229 100644 --- a/src/Doctrine/Orm/Filter/BackedEnumFilter.php +++ b/src/Doctrine/Orm/Filter/BackedEnumFilter.php @@ -128,7 +128,7 @@ protected function filterProperty(string $property, mixed $value, QueryBuilder $ $values = \is_array($value) ? $value : [$value]; $normalizedValues = array_filter(array_map( - fn ($v) => $this->normalizeValue($v, $property), + fn ($v): mixed => $this->normalizeValue($v, $property), $values )); diff --git a/src/Doctrine/Orm/Filter/SearchFilter.php b/src/Doctrine/Orm/Filter/SearchFilter.php index a93a8c197c9..6c10c35cd51 100644 --- a/src/Doctrine/Orm/Filter/SearchFilter.php +++ b/src/Doctrine/Orm/Filter/SearchFilter.php @@ -252,7 +252,7 @@ protected function filterProperty(string $property, mixed $value, QueryBuilder $ }, $values); $expected = \count($values); - $values = array_filter($values, static fn ($value) => null !== $value); + $values = array_filter($values, static fn ($value): bool => null !== $value); if ($expected > \count($values)) { /* * Shouldn't this actually fail harder? diff --git a/src/Doctrine/Orm/Tests/Extension/FilterEagerLoadingExtensionTest.php b/src/Doctrine/Orm/Tests/Extension/FilterEagerLoadingExtensionTest.php index f1ffacda340..a650df86660 100644 --- a/src/Doctrine/Orm/Tests/Extension/FilterEagerLoadingExtensionTest.php +++ b/src/Doctrine/Orm/Tests/Extension/FilterEagerLoadingExtensionTest.php @@ -363,8 +363,7 @@ public function testFetchEagerWithNoForceEager(): void DummyCar::class, 'car', 'WITH', - 'car.id = o.car', - null + 'car.id = o.car' ); $qb->select('o') diff --git a/src/Doctrine/Orm/Tests/Fixtures/Entity/CompositeItem.php b/src/Doctrine/Orm/Tests/Fixtures/Entity/CompositeItem.php index d9dd0451a87..8db16de6e36 100644 --- a/src/Doctrine/Orm/Tests/Fixtures/Entity/CompositeItem.php +++ b/src/Doctrine/Orm/Tests/Fixtures/Entity/CompositeItem.php @@ -63,7 +63,7 @@ public function getField1(): ?string * * @param string|null $field1 the value to set */ - public function setField1($field1 = null): void + public function setField1(?string $field1 = null): void { $this->field1 = $field1; } diff --git a/src/Doctrine/Orm/Tests/Fixtures/Entity/CompositeRelation.php b/src/Doctrine/Orm/Tests/Fixtures/Entity/CompositeRelation.php index 8265ad052d0..6d859d6dcae 100644 --- a/src/Doctrine/Orm/Tests/Fixtures/Entity/CompositeRelation.php +++ b/src/Doctrine/Orm/Tests/Fixtures/Entity/CompositeRelation.php @@ -51,7 +51,7 @@ public function getValue(): ?string * * @param string|null $value the value to set */ - public function setValue($value = null): void + public function setValue(?string $value = null): void { $this->value = $value; } diff --git a/src/Doctrine/Orm/Tests/Fixtures/Entity/Dummy.php b/src/Doctrine/Orm/Tests/Fixtures/Entity/Dummy.php index f5a29cc0d03..a18a87be7d6 100644 --- a/src/Doctrine/Orm/Tests/Fixtures/Entity/Dummy.php +++ b/src/Doctrine/Orm/Tests/Fixtures/Entity/Dummy.php @@ -212,7 +212,7 @@ public function getDummyDate() return $this->dummyDate; } - public function setDummyPrice($dummyPrice) + public function setDummyPrice($dummyPrice): static { $this->dummyPrice = $dummyPrice; @@ -287,10 +287,7 @@ public function isDummyBoolean(): ?bool return $this->dummyBoolean; } - /** - * @param bool $dummyBoolean - */ - public function setDummyBoolean($dummyBoolean): void + public function setDummyBoolean(?bool $dummyBoolean): void { $this->dummyBoolean = $dummyBoolean; } diff --git a/src/Doctrine/Orm/Tests/Fixtures/Entity/DummyCar.php b/src/Doctrine/Orm/Tests/Fixtures/Entity/DummyCar.php index ba9fd297690..449ecf69544 100644 --- a/src/Doctrine/Orm/Tests/Fixtures/Entity/DummyCar.php +++ b/src/Doctrine/Orm/Tests/Fixtures/Entity/DummyCar.php @@ -97,7 +97,7 @@ public function getSecondColors(): ?iterable return $this->secondColors; } - public function setSecondColors($secondColors): void + public function setSecondColors(?iterable $secondColors): void { $this->secondColors = $secondColors; } @@ -107,7 +107,7 @@ public function getThirdColors(): ?iterable return $this->thirdColors; } - public function setThirdColors($thirdColors): void + public function setThirdColors(?iterable $thirdColors): void { $this->thirdColors = $thirdColors; } @@ -117,7 +117,7 @@ public function getUuid(): ?iterable return $this->uuid; } - public function setUuid($uuid): void + public function setUuid(?iterable $uuid): void { $this->uuid = $uuid; } diff --git a/src/Doctrine/Orm/Tests/Fixtures/Entity/DummyCarColor.php b/src/Doctrine/Orm/Tests/Fixtures/Entity/DummyCarColor.php index 816a0f8935a..bf97c009ad3 100644 --- a/src/Doctrine/Orm/Tests/Fixtures/Entity/DummyCarColor.php +++ b/src/Doctrine/Orm/Tests/Fixtures/Entity/DummyCarColor.php @@ -51,10 +51,7 @@ public function getCar(): ?DummyCar return $this->car; } - /** - * @return static - */ - public function setCar(DummyCar $car) + public function setCar(DummyCar $car): static { $this->car = $car; @@ -66,12 +63,7 @@ public function getProp(): string return $this->prop; } - /** - * @param string $prop - * - * @return static - */ - public function setProp($prop) + public function setProp(string $prop): static { $this->prop = $prop; diff --git a/src/Doctrine/Orm/Tests/Fixtures/Entity/EmbeddableDummy.php b/src/Doctrine/Orm/Tests/Fixtures/Entity/EmbeddableDummy.php index c47bed99191..01eb4e737f6 100644 --- a/src/Doctrine/Orm/Tests/Fixtures/Entity/EmbeddableDummy.php +++ b/src/Doctrine/Orm/Tests/Fixtures/Entity/EmbeddableDummy.php @@ -62,10 +62,6 @@ public static function staticMethod(): void { } - public function __construct() - { - } - public function getDummyName(): ?string { return $this->dummyName; diff --git a/src/Doctrine/Orm/Tests/Fixtures/Entity/RelatedDummy.php b/src/Doctrine/Orm/Tests/Fixtures/Entity/RelatedDummy.php index e35427b26ee..4af08821320 100644 --- a/src/Doctrine/Orm/Tests/Fixtures/Entity/RelatedDummy.php +++ b/src/Doctrine/Orm/Tests/Fixtures/Entity/RelatedDummy.php @@ -159,10 +159,7 @@ public function isDummyBoolean(): ?bool return $this->dummyBoolean; } - /** - * @param bool $dummyBoolean - */ - public function setDummyBoolean($dummyBoolean): void + public function setDummyBoolean(?bool $dummyBoolean): void { $this->dummyBoolean = $dummyBoolean; } diff --git a/src/Doctrine/Orm/Tests/Fixtures/Entity/RelatedToDummyFriend.php b/src/Doctrine/Orm/Tests/Fixtures/Entity/RelatedToDummyFriend.php index fb810987dd7..6981de64bec 100644 --- a/src/Doctrine/Orm/Tests/Fixtures/Entity/RelatedToDummyFriend.php +++ b/src/Doctrine/Orm/Tests/Fixtures/Entity/RelatedToDummyFriend.php @@ -74,10 +74,7 @@ public function getDescription(): ?string return $this->description; } - /** - * @param string|null $description - */ - public function setDescription($description): void + public function setDescription(?string $description): void { $this->description = $description; } diff --git a/src/Doctrine/Orm/Tests/Fixtures/Entity/ThirdLevel.php b/src/Doctrine/Orm/Tests/Fixtures/Entity/ThirdLevel.php index 9cbd04ab9aa..03f52ce1c61 100644 --- a/src/Doctrine/Orm/Tests/Fixtures/Entity/ThirdLevel.php +++ b/src/Doctrine/Orm/Tests/Fixtures/Entity/ThirdLevel.php @@ -71,10 +71,7 @@ public function getLevel(): ?int return $this->level; } - /** - * @param int $level - */ - public function setLevel($level): void + public function setLevel(int $level): void { $this->level = $level; } @@ -84,10 +81,7 @@ public function isTest(): bool return $this->test; } - /** - * @param bool $test - */ - public function setTest($test): void + public function setTest(bool $test): void { $this->test = $test; } diff --git a/src/Doctrine/Orm/Tests/Fixtures/Query.php b/src/Doctrine/Orm/Tests/Fixtures/Query.php index f6536af2004..42ef657ac8f 100644 --- a/src/Doctrine/Orm/Tests/Fixtures/Query.php +++ b/src/Doctrine/Orm/Tests/Fixtures/Query.php @@ -45,7 +45,7 @@ public function setParameters($parameters): self return $this; } - public function getParameters() + public function getParameters(): ArrayCollection { return new ArrayCollection(); } @@ -55,12 +55,12 @@ public function setCacheable($cacheable): self return $this; } - public function getHints() + public function getHints(): array { return []; } - public function getFetchJoinCollection() + public function getFetchJoinCollection(): bool { return false; } diff --git a/src/Doctrine/Orm/Tests/Fixtures/State/OperationResourceProcessor.php b/src/Doctrine/Orm/Tests/Fixtures/State/OperationResourceProcessor.php index 874cb2f1ca0..4f5a31fd308 100644 --- a/src/Doctrine/Orm/Tests/Fixtures/State/OperationResourceProcessor.php +++ b/src/Doctrine/Orm/Tests/Fixtures/State/OperationResourceProcessor.php @@ -30,7 +30,7 @@ public function __construct(private readonly ManagerRegistry $managerRegistry) { } - private function persist($data, array $context = []) + private function persist($data) { if (!$manager = $this->getManager($data)) { return $data; @@ -78,7 +78,7 @@ private function getManager($data): ?DoctrineObjectManager /** * Checks if doctrine does not manage data automatically. */ - private function isDeferredExplicit(DoctrineObjectManager $manager, $data): bool + private function isDeferredExplicit(DoctrineObjectManager $manager, object $data): bool { $classMetadata = $manager->getClassMetadata($this->getObjectClass($data)); if (($classMetadata instanceof ClassMetadata || $classMetadata instanceof ODMClassMetadata) && method_exists($classMetadata, 'isChangeTrackingDeferredExplicit')) { diff --git a/src/Doctrine/Orm/Tests/State/ItemProviderTest.php b/src/Doctrine/Orm/Tests/State/ItemProviderTest.php index 168939cc047..3525a6e953e 100644 --- a/src/Doctrine/Orm/Tests/State/ItemProviderTest.php +++ b/src/Doctrine/Orm/Tests/State/ItemProviderTest.php @@ -224,7 +224,7 @@ public function testCannotCreateQueryBuilder(): void /** * Gets a mocked manager registry. */ - private function getManagerRegistry(string $resourceClass, array $identifierFields, QueryBuilder $queryBuilder, array $classMetadatas = []) + private function getManagerRegistry(string $resourceClass, array $identifierFields, QueryBuilder $queryBuilder, array $classMetadatas = []): \PHPUnit\Framework\MockObject\MockObject { $classMetadataMock = $this->createMock(ClassMetadata::class); $classMetadataMock->method('getIdentifierFieldNames')->willReturn(array_keys($identifierFields)); diff --git a/src/Doctrine/Orm/Util/QueryChecker.php b/src/Doctrine/Orm/Util/QueryChecker.php index fc1bad9244a..b5b4dc5d2b7 100644 --- a/src/Doctrine/Orm/Util/QueryChecker.php +++ b/src/Doctrine/Orm/Util/QueryChecker.php @@ -169,7 +169,7 @@ public static function hasJoinedToManyAssociation(QueryBuilder $queryBuilder, Ma } foreach ($joinAliases as $joinAlias) { - foreach (QueryBuilderHelper::traverseJoins($joinAlias, $queryBuilder, $managerRegistry) as $alias => [$metadata, $association]) { + foreach (QueryBuilderHelper::traverseJoins($joinAlias, $queryBuilder, $managerRegistry) as [$metadata, $association]) { if (null !== $association && $metadata->isCollectionValuedAssociation($association)) { return true; } diff --git a/src/Elasticsearch/Tests/Util/FieldDatatypeTraitTest.php b/src/Elasticsearch/Tests/Util/FieldDatatypeTraitTest.php index fec6ba90695..e5146013fd2 100644 --- a/src/Elasticsearch/Tests/Util/FieldDatatypeTraitTest.php +++ b/src/Elasticsearch/Tests/Util/FieldDatatypeTraitTest.php @@ -88,7 +88,7 @@ public function testIsNestedField(): void self::assertFalse($fieldDatatype->isNestedField(Foo::class, 'baz')); } - private function getValidFieldDatatype() + private function getValidFieldDatatype(): object { $fooType = Type::object(Foo::class); $barType = Type::list(Type::object(Foo::class)); @@ -106,7 +106,7 @@ private function getValidFieldDatatype() $resourceClassResolverProphecy->reveal()); } - private static function createFieldDatatypeInstance(PropertyMetadataFactoryInterface $propertyMetadataFactory, ResourceClassResolverInterface $resourceClassResolver) + private static function createFieldDatatypeInstance(PropertyMetadataFactoryInterface $propertyMetadataFactory, ResourceClassResolverInterface $resourceClassResolver): object { return new class($propertyMetadataFactory, $resourceClassResolver) { use FieldDatatypeTrait { diff --git a/src/GraphQl/Action/GraphiQlAction.php b/src/GraphQl/Action/GraphiQlAction.php index ca67f91e030..94e17800404 100644 --- a/src/GraphQl/Action/GraphiQlAction.php +++ b/src/GraphQl/Action/GraphiQlAction.php @@ -13,7 +13,6 @@ namespace ApiPlatform\GraphQl\Action; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\Routing\RouterInterface; @@ -33,7 +32,7 @@ public function __construct(private readonly TwigEnvironment $twig, private read { } - public function __invoke(Request $request): Response + public function __invoke(): Response { if ($this->graphiqlEnabled) { return new Response($this->twig->render('@ApiPlatform/Graphiql/index.html.twig', [ @@ -42,7 +41,6 @@ public function __invoke(Request $request): Response 'assetPackage' => $this->assetPackage, ]), 200, ['content-type' => 'text/html']); } - throw new BadRequestHttpException('GraphiQL is not enabled.'); } } diff --git a/src/GraphQl/Metadata/RuntimeOperationMetadataFactory.php b/src/GraphQl/Metadata/RuntimeOperationMetadataFactory.php index 6b280da24cf..c14eb47871d 100644 --- a/src/GraphQl/Metadata/RuntimeOperationMetadataFactory.php +++ b/src/GraphQl/Metadata/RuntimeOperationMetadataFactory.php @@ -30,7 +30,7 @@ public function __construct(private readonly ResourceMetadataCollectionFactoryIn { } - public function create(string $uriTemplate, array $context = []): Operation + public function create(string $uriTemplate, array $context = []): Query { try { $parameters = $this->router->match($uriTemplate); diff --git a/src/GraphQl/Resolver/Factory/ResolverFactory.php b/src/GraphQl/Resolver/Factory/ResolverFactory.php index 074728a53a9..c9fc8a73cf7 100644 --- a/src/GraphQl/Resolver/Factory/ResolverFactory.php +++ b/src/GraphQl/Resolver/Factory/ResolverFactory.php @@ -65,7 +65,7 @@ public function __invoke(?string $resourceClass = null, ?string $rootClass = nul $type = $propertyMetadata?->getNativeType(); // Data already fetched and normalized (field or nested resource) - if ($body || null === $resourceClass || ($type && !$type->isSatisfiedBy(static fn ($t) => $t instanceof CollectionType))) { + if ($body || null === $resourceClass || ($type && !$type->isSatisfiedBy(static fn ($t): bool => $t instanceof CollectionType))) { return $body; } } else { @@ -83,7 +83,7 @@ public function __invoke(?string $resourceClass = null, ?string $rootClass = nul return null; } - return $this->resolve($source, $args, $info, $rootClass, $operation, null); + return $this->resolve($source, $args, $info, $rootClass, $operation); }; } diff --git a/src/GraphQl/State/Processor/NormalizeProcessor.php b/src/GraphQl/State/Processor/NormalizeProcessor.php index 29fe2b9f75a..e56ed20abc2 100644 --- a/src/GraphQl/State/Processor/NormalizeProcessor.php +++ b/src/GraphQl/State/Processor/NormalizeProcessor.php @@ -46,16 +46,15 @@ public function process(mixed $data, Operation $operation, array $uriVariables = return $data; } - return $this->getData($data, $operation, $uriVariables, $context); + return $this->getData($data, $operation, $context); } /** - * @param array $uriVariables * @param array $context * * @return array */ - private function getData(mixed $itemOrCollection, GraphQlOperation $operation, array $uriVariables = [], array $context = []): ?array + private function getData(mixed $itemOrCollection, GraphQlOperation $operation, array $context = []): ?array { if (!($operation->canSerialize() ?? true)) { if ($operation instanceof CollectionOperationInterface) { diff --git a/src/GraphQl/Tests/ExecutorTest.php b/src/GraphQl/Tests/ExecutorTest.php index e6b64c77a85..93d44aaadf9 100644 --- a/src/GraphQl/Tests/ExecutorTest.php +++ b/src/GraphQl/Tests/ExecutorTest.php @@ -27,7 +27,7 @@ class ExecutorTest extends TestCase { public function testEnableIntrospectionQuery(): void { - $executor = new Executor(true); + new Executor(true); $expected = new DisableIntrospection(DisableIntrospection::DISABLED); $this->assertEquals($expected, DocumentValidator::getRule(DisableIntrospection::class)); @@ -35,7 +35,7 @@ public function testEnableIntrospectionQuery(): void public function testDisableIntrospectionQuery(): void { - $executor = new Executor(false); + new Executor(false); $expected = new DisableIntrospection(DisableIntrospection::ENABLED); $this->assertEquals($expected, DocumentValidator::getRule(DisableIntrospection::class)); @@ -43,7 +43,7 @@ public function testDisableIntrospectionQuery(): void public function testChangeValueOfMaxQueryDepth(): void { - $executor = new Executor(true, 20); + new Executor(true, 20); $expected = new QueryComplexity(20); $this->assertEquals($expected, DocumentValidator::getRule(QueryComplexity::class)); @@ -51,7 +51,7 @@ public function testChangeValueOfMaxQueryDepth(): void public function testChangeValueOfMaxQueryComplexity(): void { - $executor = new Executor(true, maxQueryDepth: 20); + new Executor(true, maxQueryDepth: 20); $expected = new QueryDepth(20); $this->assertEquals($expected, DocumentValidator::getRule(QueryDepth::class)); diff --git a/src/GraphQl/Tests/Fixtures/ApiResource/Dummy.php b/src/GraphQl/Tests/Fixtures/ApiResource/Dummy.php index c90666c24f5..8bb9dc8be0e 100644 --- a/src/GraphQl/Tests/Fixtures/ApiResource/Dummy.php +++ b/src/GraphQl/Tests/Fixtures/ApiResource/Dummy.php @@ -158,7 +158,7 @@ public function getDummyDate() return $this->dummyDate; } - public function setDummyPrice($dummyPrice) + public function setDummyPrice($dummyPrice): static { $this->dummyPrice = $dummyPrice; @@ -195,10 +195,7 @@ public function isDummyBoolean(): ?bool return $this->dummyBoolean; } - /** - * @param bool $dummyBoolean - */ - public function setDummyBoolean($dummyBoolean): void + public function setDummyBoolean(?bool $dummyBoolean): void { $this->dummyBoolean = $dummyBoolean; } diff --git a/src/GraphQl/Tests/Fixtures/ApiResource/SecuredDummy.php b/src/GraphQl/Tests/Fixtures/ApiResource/SecuredDummy.php index 24071232d11..ab19780cb0b 100644 --- a/src/GraphQl/Tests/Fixtures/ApiResource/SecuredDummy.php +++ b/src/GraphQl/Tests/Fixtures/ApiResource/SecuredDummy.php @@ -44,10 +44,6 @@ class SecuredDummy #[ApiProperty(security: 'object == null or object.getOwner() == user', securityPostDenormalize: 'object.getOwner() == user')] private string $ownerOnlyProperty = ''; - public function __construct() - { - } - public function getId(): ?int { return $this->id; diff --git a/src/GraphQl/Tests/Resolver/Util/IdentifierTraitTest.php b/src/GraphQl/Tests/Resolver/Util/IdentifierTraitTest.php index 64b0645750e..55e5359855a 100644 --- a/src/GraphQl/Tests/Resolver/Util/IdentifierTraitTest.php +++ b/src/GraphQl/Tests/Resolver/Util/IdentifierTraitTest.php @@ -21,7 +21,7 @@ */ class IdentifierTraitTest extends TestCase { - private function getIdentifierTraitImplementation() + private function getIdentifierTraitImplementation(): object { return new class { use IdentifierTrait { diff --git a/src/GraphQl/Tests/Serializer/ItemNormalizerTest.php b/src/GraphQl/Tests/Serializer/ItemNormalizerTest.php index e528ee4e941..8324b5ec4d6 100644 --- a/src/GraphQl/Tests/Serializer/ItemNormalizerTest.php +++ b/src/GraphQl/Tests/Serializer/ItemNormalizerTest.php @@ -164,7 +164,7 @@ public function testNormalizeWithUnsafeCacheProperty(): void SecuredDummy::class, 'object == null or object.getOwner() == user', Argument::type('array') - )->will(static function (array $args) { + )->will(static function (array $args): bool { return 'hello' === $args[2]['object']->getTitle(); // Allow access only for securedDummyWithOwnerOnlyPropertyAllowed }); diff --git a/src/GraphQl/Tests/State/Processor/NormalizeProcessorTest.php b/src/GraphQl/Tests/State/Processor/NormalizeProcessorTest.php index 2d7ba11fab9..9ff49eb162d 100644 --- a/src/GraphQl/Tests/State/Processor/NormalizeProcessorTest.php +++ b/src/GraphQl/Tests/State/Processor/NormalizeProcessorTest.php @@ -44,7 +44,7 @@ protected function setUp(): void } #[DataProvider('processItems')] - public function testProcess($body, $operation): void + public function testProcess(\stdClass $body, Query|Mutation|Subscription $operation): void { $context = ['args' => []]; $serializerContext = ['resource_class' => $operation->getClass()]; @@ -66,7 +66,7 @@ public static function processItems(): array } #[DataProvider('processCollection')] - public function testProcessCollection($collection, $operation, $args, ?array $expectedResult, array $getFieldSelection, ?string $expectedExceptionClass = null, ?string $expectedExceptionMessage = null): void + public function testProcessCollection(ArrayPaginator|\Closure|array $collection, QueryCollection $operation, array $args, ?array $expectedResult, array $getFieldSelection, ?string $expectedExceptionClass = null, ?string $expectedExceptionMessage = null): void { $this->resolveInfoProphecy->getFieldSelection(1)->willReturn($getFieldSelection); $context = ['args' => $args, 'info' => $this->resolveInfoProphecy->reveal()]; diff --git a/src/GraphQl/Tests/Type/FieldsBuilderTest.php b/src/GraphQl/Tests/Type/FieldsBuilderTest.php index 268c7d56295..42ad3e07c49 100644 --- a/src/GraphQl/Tests/Type/FieldsBuilderTest.php +++ b/src/GraphQl/Tests/Type/FieldsBuilderTest.php @@ -468,7 +468,7 @@ public static function subscriptionFieldsProvider(): array public function testGetResourceObjectTypeFields(string $resourceClass, Operation $operation, array $properties, bool $input, int $depth, ?array $ioMetadata, array $expectedResourceObjectTypeFields, ?callable $advancedNameConverterFactory = null): void { $resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class); - $resourceClassResolver->method('isResourceClass')->willReturnCallback(static function ($class) use ($resourceClass) { + $resourceClassResolver->method('isResourceClass')->willReturnCallback(static function ($class) use ($resourceClass): bool { return \in_array($class, [$resourceClass, 'nestedResourceClass', 'nestedResourceNoQueryClass'], true); }); diff --git a/src/GraphQl/Tests/Type/TypeBuilderTest.php b/src/GraphQl/Tests/Type/TypeBuilderTest.php index ddef6ba5b4e..71e65158acd 100644 --- a/src/GraphQl/Tests/Type/TypeBuilderTest.php +++ b/src/GraphQl/Tests/Type/TypeBuilderTest.php @@ -54,8 +54,7 @@ class TypeBuilderTest extends TestCase use ProphecyTrait; private ObjectProphecy $typesContainerProphecy; - /** @var callable */ - private $defaultFieldResolver; + private \Closure $defaultFieldResolver; private ObjectProphecy $fieldsBuilderLocatorProphecy; private TypeBuilder $typeBuilder; diff --git a/src/GraphQl/Type/FieldsBuilder.php b/src/GraphQl/Type/FieldsBuilder.php index 458f92bb248..8b8df31961c 100644 --- a/src/GraphQl/Type/FieldsBuilder.php +++ b/src/GraphQl/Type/FieldsBuilder.php @@ -331,7 +331,6 @@ private function parameterToObjectType(array $flattenFields, string $name): Inpu $type = $this->getParameterType($type); if (\is_array($l = $field['leafs'])) { if (0 === key($l)) { - $key = $key; $type = GraphQLType::listOf($type); } else { $n = []; @@ -406,7 +405,7 @@ private function getResourceFieldConfiguration(?string $property, ?string $field } try { - $isCollectionType = $type->isSatisfiedBy(static fn ($t) => $t instanceof CollectionType) && ($v = TypeHelper::getCollectionValueType($type)) && TypeHelper::getClassName($v); + $isCollectionType = $type->isSatisfiedBy(static fn ($t): bool => $t instanceof CollectionType) && ($v = TypeHelper::getCollectionValueType($type)) && TypeHelper::getClassName($v); $valueType = $type; if ($isCollectionType) { @@ -657,7 +656,7 @@ private function mergeFilterArgs(array $args, array $parsed, ?Operation $operati if (\is_array($value)) { $value = $this->mergeFilterArgs($args[$key] ?? [], $value); if (!isset($value['#name'])) { - $name = (false === $pos = strrpos($original, '[')) ? $original : substr($original, 0, (int) $pos); + $name = (false === $pos = strrpos($original, '[')) ? $original : substr($original, 0, $pos); $value['#name'] = ($operation ? $operation->getShortName() : '').'Filter_'.strtr($name, ['[' => '_', ']' => '', '.' => '__']); } } @@ -730,7 +729,7 @@ private function convertType(Type|LegacyType $type, bool $input, Operation $reso $graphqlType = $this->typesContainer->get($graphqlType); } - if ($type->isSatisfiedBy(static fn ($t) => $t instanceof CollectionType) && ($collectionValueType = TypeHelper::getCollectionValueType($type)) && TypeHelper::getClassName($collectionValueType)) { + if ($type->isSatisfiedBy(static fn ($t): bool => $t instanceof CollectionType) && ($collectionValueType = TypeHelper::getCollectionValueType($type)) && TypeHelper::getClassName($collectionValueType)) { if (!$input && !$this->isEnumClass($resourceClass) && $this->pagination->isGraphQlEnabled($resourceOperation)) { return $this->typeBuilder->getPaginatedCollectionType($graphqlType, $resourceOperation); } diff --git a/src/GraphQl/Type/TypeBuilder.php b/src/GraphQl/Type/TypeBuilder.php index 43152f0b6dd..81a940ea395 100644 --- a/src/GraphQl/Type/TypeBuilder.php +++ b/src/GraphQl/Type/TypeBuilder.php @@ -137,7 +137,7 @@ public function getNodeInterface(): InterfaceType 'description' => 'The id of this node.', ], ], - 'resolveType' => function ($value): ?GraphQLType { + 'resolveType' => function (array $value): ?GraphQLType { if (!isset($value[ItemNormalizer::ITEM_RESOURCE_CLASS_KEY])) { return null; } @@ -204,7 +204,6 @@ public function getEnumType(Operation $operation): GraphQLType /** @var FieldsBuilderEnumInterface $fieldsBuilder */ $fieldsBuilder = $this->fieldsBuilderLocator->get('api_platform.graphql.fields_builder'); - $enumCases = []; $enumCases = $fieldsBuilder->getEnumFields($operation->getClass()); $enumConfig = [ diff --git a/src/GraphQl/Type/TypeConverter.php b/src/GraphQl/Type/TypeConverter.php index ca74645aa51..601c0dc12fc 100644 --- a/src/GraphQl/Type/TypeConverter.php +++ b/src/GraphQl/Type/TypeConverter.php @@ -137,7 +137,7 @@ public function resolveType(string $type): GraphQLType private function getResourceType(Type|LegacyType $type, bool $input, Operation $rootOperation, string $rootResource, ?string $property, int $depth): ?GraphQLType { if ($type instanceof Type) { - $isCollection = $type->isSatisfiedBy(static fn ($t) => $t instanceof CollectionType); + $isCollection = $type->isSatisfiedBy(static fn ($t): bool => $t instanceof CollectionType); if ($isCollection) { $type = TypeHelper::getCollectionValueType($type); diff --git a/src/Hal/Serializer/ItemNormalizer.php b/src/Hal/Serializer/ItemNormalizer.php index b4ff28d5ce7..e9a663519d1 100644 --- a/src/Hal/Serializer/ItemNormalizer.php +++ b/src/Hal/Serializer/ItemNormalizer.php @@ -62,7 +62,7 @@ final class ItemNormalizer extends AbstractItemNormalizer public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, IriConverterInterface $iriConverter, ResourceClassResolverInterface $resourceClassResolver, ?PropertyAccessorInterface $propertyAccessor = null, ?NameConverterInterface $nameConverter = null, ?ClassMetadataFactoryInterface $classMetadataFactory = null, array $defaultContext = [], ?ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory = null, ?ResourceAccessCheckerInterface $resourceAccessChecker = null, ?TagCollectorInterface $tagCollector = null, ?OperationResourceClassResolverInterface $operationResourceResolver = null) { - $defaultContext[AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER] = function ($object): ?array { + $defaultContext[AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER] = function (object|string $object): ?array { $iri = $this->iriConverter->getIriFromResource($object); if (null === $iri) { return null; @@ -216,7 +216,7 @@ private function getComponents(object $object, ?string $format, array $context): $isOne = $className && $this->resourceClassResolver->isResourceClass($className); } } elseif ($type instanceof Type) { - if ($type->isSatisfiedBy(static fn ($t) => $t instanceof CollectionType)) { + if ($type->isSatisfiedBy(static fn ($t): bool => $t instanceof CollectionType)) { $isMany = TypeHelper::getCollectionValueType($type)?->isSatisfiedBy($typeIsResourceClass); } else { $isOne = $type->isSatisfiedBy($typeIsResourceClass); diff --git a/src/Hal/Tests/Serializer/ItemNormalizerTest.php b/src/Hal/Tests/Serializer/ItemNormalizerTest.php index 2dfef7ad0c4..8a4abc0cfb4 100644 --- a/src/Hal/Tests/Serializer/ItemNormalizerTest.php +++ b/src/Hal/Tests/Serializer/ItemNormalizerTest.php @@ -482,9 +482,6 @@ public function testSkipNullToOneRelation(array $context, array $expected): void nameConverter: $nameConverter, classMetadataFactory: null, defaultContext: [], - resourceMetadataCollectionFactory: null, - resourceAccessChecker: null, - tagCollector: null, ); $normalizer->setSerializer($serializer); diff --git a/src/HttpCache/SouinPurger.php b/src/HttpCache/SouinPurger.php index 4fc2ff73cca..4a537e0d7c6 100644 --- a/src/HttpCache/SouinPurger.php +++ b/src/HttpCache/SouinPurger.php @@ -13,8 +13,6 @@ namespace ApiPlatform\HttpCache; -use Symfony\Contracts\HttpClient\HttpClientInterface; - /** * Purges Souin. * @@ -25,12 +23,4 @@ class SouinPurger extends SurrogateKeysPurger private const MAX_HEADER_SIZE_PER_BATCH = 1500; private const SEPARATOR = ', '; private const HEADER = 'Surrogate-Key'; - - /** - * @param HttpClientInterface[] $clients - */ - public function __construct(iterable $clients, int $maxHeaderLength = self::MAX_HEADER_SIZE_PER_BATCH) - { - parent::__construct($clients, $maxHeaderLength, self::HEADER, self::SEPARATOR); - } } diff --git a/src/HttpCache/State/AddHeadersProcessor.php b/src/HttpCache/State/AddHeadersProcessor.php index 48c431a8adb..1898dc325ca 100644 --- a/src/HttpCache/State/AddHeadersProcessor.php +++ b/src/HttpCache/State/AddHeadersProcessor.php @@ -63,7 +63,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables = $public = ($resourceCacheHeaders['public'] ?? $this->public); $options = [ - 'etag' => $this->etag && !$response->getEtag() ? hash('xxh3', (string) $content) : null, + 'etag' => $this->etag && !$response->getEtag() ? hash('xxh3', $content) : null, 'max_age' => null !== ($maxAge = $resourceCacheHeaders['max_age'] ?? $this->maxAge) && !$response->headers->hasCacheControlDirective('max-age') ? $maxAge : null, // Cache-Control "s-maxage" is only relevant is resource is not marked as "private" 's_maxage' => false !== $public && null !== ($sharedMaxAge = $resourceCacheHeaders['shared_max_age'] ?? $this->sharedMaxAge) && !$response->headers->hasCacheControlDirective('s-maxage') ? $sharedMaxAge : null, diff --git a/src/Hydra/Serializer/ConstraintViolationListNormalizer.php b/src/Hydra/Serializer/ConstraintViolationListNormalizer.php index 38df693497e..39c8e4381da 100644 --- a/src/Hydra/Serializer/ConstraintViolationListNormalizer.php +++ b/src/Hydra/Serializer/ConstraintViolationListNormalizer.php @@ -15,7 +15,6 @@ use ApiPlatform\JsonLd\Serializer\HydraPrefixTrait; use ApiPlatform\Serializer\AbstractConstraintViolationListNormalizer; -use Symfony\Component\Serializer\NameConverter\NameConverterInterface; /** * Converts {@see \Symfony\Component\Validator\ConstraintViolationListInterface} to a Hydra error representation. @@ -27,11 +26,6 @@ final class ConstraintViolationListNormalizer extends AbstractConstraintViolatio use HydraPrefixTrait; public const FORMAT = 'jsonld'; - public function __construct(?array $serializePayloadFields = null, ?NameConverterInterface $nameConverter = null) - { - parent::__construct($serializePayloadFields, $nameConverter); - } - /** * {@inheritdoc} */ diff --git a/src/Hydra/Serializer/DocumentationNormalizer.php b/src/Hydra/Serializer/DocumentationNormalizer.php index cacfc152d32..94cf910040d 100644 --- a/src/Hydra/Serializer/DocumentationNormalizer.php +++ b/src/Hydra/Serializer/DocumentationNormalizer.php @@ -368,7 +368,7 @@ private function getRange(ApiProperty $propertyMetadata): array|string|null return null; } - if ($nativeType->isSatisfiedBy(static fn ($t) => $t instanceof CollectionType)) { + if ($nativeType->isSatisfiedBy(static fn ($t): bool => $t instanceof CollectionType)) { $nativeType = TypeHelper::getCollectionValueType($nativeType); } @@ -635,7 +635,7 @@ private function getProperty(ApiProperty $propertyMetadata, string $propertyName */ private function computeDoc(Documentation $object, array $classes, string $hydraPrefix = ContextBuilder::HYDRA_PREFIX): array { - $doc = ['@context' => $this->getContext($hydraPrefix), '@id' => $this->urlGenerator->generate('api_doc', ['_format' => self::FORMAT]), '@type' => $hydraPrefix.'ApiDocumentation']; + $doc = ['@context' => $this->getContext(), '@id' => $this->urlGenerator->generate('api_doc', ['_format' => self::FORMAT]), '@type' => $hydraPrefix.'ApiDocumentation']; if ('' !== $object->getTitle()) { $doc[$hydraPrefix.'title'] = $object->getTitle(); @@ -656,7 +656,7 @@ private function computeDoc(Documentation $object, array $classes, string $hydra /** * Builds the JSON-LD context for the API documentation. */ - private function getContext(string $hydraPrefix = ContextBuilder::HYDRA_PREFIX): array + private function getContext(): array { return [ HYDRA_CONTEXT, diff --git a/src/Hydra/Serializer/PartialCollectionViewNormalizer.php b/src/Hydra/Serializer/PartialCollectionViewNormalizer.php index 52c32173777..4347d652bb2 100644 --- a/src/Hydra/Serializer/PartialCollectionViewNormalizer.php +++ b/src/Hydra/Serializer/PartialCollectionViewNormalizer.php @@ -147,7 +147,7 @@ public function setNormalizer(NormalizerInterface $normalizer): void /** * @param object $object */ - private function cursorPaginationFields(array $fields, int $direction, $object): array + private function cursorPaginationFields(array $fields, int $direction, object|array $object): array { $paginationFilters = []; diff --git a/src/Hydra/Tests/Serializer/ConstraintViolationNormalizerTest.php b/src/Hydra/Tests/Serializer/ConstraintViolationNormalizerTest.php index 43728be33e8..d015c361caa 100644 --- a/src/Hydra/Tests/Serializer/ConstraintViolationNormalizerTest.php +++ b/src/Hydra/Tests/Serializer/ConstraintViolationNormalizerTest.php @@ -96,7 +96,7 @@ public static function nameConverterAndPayloadFieldsProvider(): iterable return $nameConverterProphecy->reveal(); }; - $nullNameConverterFactory = static fn () => null; + $nullNameConverterFactory = static fn (): null => null; $expected = $nameConverterBasedExpectation; $expected[0]['payload'] = ['severity' => 'warning']; diff --git a/src/Hydra/Tests/Serializer/PartialCollectionViewNormalizerTest.php b/src/Hydra/Tests/Serializer/PartialCollectionViewNormalizerTest.php index 49b7a194a16..47555281ebb 100644 --- a/src/Hydra/Tests/Serializer/PartialCollectionViewNormalizerTest.php +++ b/src/Hydra/Tests/Serializer/PartialCollectionViewNormalizerTest.php @@ -108,7 +108,7 @@ public function testNormalizeWithCursorBasedPagination(): void ); } - private function normalizePaginator(bool $partial = false, bool $cursor = false) + private function normalizePaginator(bool $partial = false, bool $cursor = false): string|int|float|bool|\ArrayObject|array|null { $paginatorProphecy = $this->prophesize($partial ? PartialPaginatorInterface::class : PaginatorInterface::class); diff --git a/src/Hydra/Tests/State/HydraLinkProcessorTest.php b/src/Hydra/Tests/State/HydraLinkProcessorTest.php index b5ce10a1009..3985991273c 100644 --- a/src/Hydra/Tests/State/HydraLinkProcessorTest.php +++ b/src/Hydra/Tests/State/HydraLinkProcessorTest.php @@ -33,7 +33,7 @@ public function testProcess(): void $request = $this->createMock(Request::class); $request->attributes = $this->createMock(ParameterBag::class); - $request->attributes->expects($this->once())->method('set')->with('_api_platform_links', $this->callback(function ($linkProvider) { + $request->attributes->expects($this->once())->method('set')->with('_api_platform_links', $this->callback(function ($linkProvider): true { $this->assertInstanceOf(GenericLinkProvider::class, $linkProvider); $this->assertEquals($linkProvider->getLinks(), [new Link('a', 'b'), new Link(ContextBuilder::HYDRA_NS.'apiDocumentation', '/docs')]); diff --git a/src/JsonApi/JsonSchema/SchemaFactory.php b/src/JsonApi/JsonSchema/SchemaFactory.php index 3228d172386..23e4258c091 100644 --- a/src/JsonApi/JsonSchema/SchemaFactory.php +++ b/src/JsonApi/JsonSchema/SchemaFactory.php @@ -79,7 +79,7 @@ final class SchemaFactory implements SchemaFactoryInterface, SchemaFactoryAwareI /** * @var array */ - private $builtSchema = []; + private array $builtSchema = []; public function __construct(private readonly SchemaFactoryInterface $schemaFactory, private readonly PropertyMetadataFactoryInterface $propertyMetadataFactory, ResourceClassResolverInterface $resourceClassResolver, ?ResourceMetadataCollectionFactoryInterface $resourceMetadataFactory = null, private ?DefinitionNameFactoryInterface $definitionNameFactory = null) { diff --git a/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php b/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php index c20fedffd09..218b8bdc3a4 100644 --- a/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php +++ b/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php @@ -100,7 +100,7 @@ private function getSourcePointerFromViolation(ConstraintViolationInterface $vio return "data/relationships/$fieldName"; } } else { - if ($propertyMetadata->getNativeType()?->isSatisfiedBy(static fn ($t) => $t instanceof ObjectType)) { + if ($propertyMetadata->getNativeType()?->isSatisfiedBy(static fn ($t): bool => $t instanceof ObjectType)) { return "data/relationships/$fieldName"; } } diff --git a/src/JsonApi/Serializer/ItemNormalizer.php b/src/JsonApi/Serializer/ItemNormalizer.php index 046c0ee5310..44acdf90c6d 100644 --- a/src/JsonApi/Serializer/ItemNormalizer.php +++ b/src/JsonApi/Serializer/ItemNormalizer.php @@ -15,29 +15,18 @@ use ApiPlatform\Metadata\ApiProperty; use ApiPlatform\Metadata\Exception\ItemNotFoundException; -use ApiPlatform\Metadata\IriConverterInterface; -use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface; -use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface; -use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; -use ApiPlatform\Metadata\ResourceAccessCheckerInterface; -use ApiPlatform\Metadata\ResourceClassResolverInterface; use ApiPlatform\Metadata\UrlGeneratorInterface; use ApiPlatform\Metadata\Util\ClassInfoTrait; use ApiPlatform\Metadata\Util\TypeHelper; use ApiPlatform\Serializer\AbstractItemNormalizer; use ApiPlatform\Serializer\CacheKeyTrait; use ApiPlatform\Serializer\ContextTrait; -use ApiPlatform\Serializer\OperationResourceClassResolverInterface; -use ApiPlatform\Serializer\TagCollectorInterface; use Symfony\Component\ErrorHandler\Exception\FlattenException; -use Symfony\Component\PropertyAccess\PropertyAccessorInterface; use Symfony\Component\PropertyInfo\PropertyInfoExtractor; use Symfony\Component\Serializer\Exception\LogicException; use Symfony\Component\Serializer\Exception\NotNormalizableValueException; use Symfony\Component\Serializer\Exception\RuntimeException; use Symfony\Component\Serializer\Exception\UnexpectedValueException; -use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; -use Symfony\Component\Serializer\NameConverter\NameConverterInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\TypeInfo\Type; use Symfony\Component\TypeInfo\Type\CompositeTypeInterface; @@ -60,11 +49,6 @@ final class ItemNormalizer extends AbstractItemNormalizer private array $componentsCache = []; - public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, IriConverterInterface $iriConverter, ResourceClassResolverInterface $resourceClassResolver, ?PropertyAccessorInterface $propertyAccessor = null, ?NameConverterInterface $nameConverter = null, ?ClassMetadataFactoryInterface $classMetadataFactory = null, array $defaultContext = [], ?ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory = null, ?ResourceAccessCheckerInterface $resourceAccessChecker = null, protected ?TagCollectorInterface $tagCollector = null, ?OperationResourceClassResolverInterface $operationResourceResolver = null) - { - parent::__construct($propertyNameCollectionFactory, $propertyMetadataFactory, $iriConverter, $resourceClassResolver, $propertyAccessor, $nameConverter, $classMetadataFactory, $defaultContext, $resourceMetadataCollectionFactory, $resourceAccessChecker, $tagCollector, $operationResourceResolver); - } - /** * {@inheritdoc} */ @@ -102,7 +86,7 @@ public function normalize(mixed $data, ?string $format = null, array $context = $context = $this->initContext($resourceClass, $context); - $iri = $context['iri'] ??= $this->iriConverter->getIriFromResource($data, UrlGeneratorInterface::ABS_PATH, $context['operation'] ?? null, $context); + $context['iri'] ??= $this->iriConverter->getIriFromResource($data, UrlGeneratorInterface::ABS_PATH, $context['operation'] ?? null, $context); $context['object'] = $data; $context['format'] = $format; $context['api_normalize'] = true; diff --git a/src/JsonApi/Tests/Fixtures/Dummy.php b/src/JsonApi/Tests/Fixtures/Dummy.php index 3f3b9e16b05..cb0dfff00b2 100644 --- a/src/JsonApi/Tests/Fixtures/Dummy.php +++ b/src/JsonApi/Tests/Fixtures/Dummy.php @@ -162,7 +162,7 @@ public function getDummyDate() return $this->dummyDate; } - public function setDummyPrice($dummyPrice) + public function setDummyPrice($dummyPrice): static { $this->dummyPrice = $dummyPrice; diff --git a/src/JsonApi/Tests/Fixtures/RelatedDummy.php b/src/JsonApi/Tests/Fixtures/RelatedDummy.php index b0518a357c6..782b3b33345 100644 --- a/src/JsonApi/Tests/Fixtures/RelatedDummy.php +++ b/src/JsonApi/Tests/Fixtures/RelatedDummy.php @@ -52,10 +52,6 @@ class RelatedDummy implements \Stringable #[Groups(['friends'])] public ?bool $dummyBoolean = null; - public function __construct() - { - } - public function getId() { return $this->id; @@ -101,10 +97,7 @@ public function isDummyBoolean(): ?bool return $this->dummyBoolean; } - /** - * @param bool $dummyBoolean - */ - public function setDummyBoolean($dummyBoolean): void + public function setDummyBoolean(?bool $dummyBoolean): void { $this->dummyBoolean = $dummyBoolean; } diff --git a/src/JsonApi/Tests/JsonSchema/SchemaFactoryTest.php b/src/JsonApi/Tests/JsonSchema/SchemaFactoryTest.php index 4adcb6480ce..852606900c2 100644 --- a/src/JsonApi/Tests/JsonSchema/SchemaFactoryTest.php +++ b/src/JsonApi/Tests/JsonSchema/SchemaFactoryTest.php @@ -51,7 +51,7 @@ protected function setUp(): void $propertyNameCollectionFactory->create(Dummy::class, ['enable_getter_setter_extraction' => true, 'schema_type' => Schema::TYPE_OUTPUT])->willReturn(new PropertyNameCollection()); $propertyMetadataFactory = $this->prophesize(PropertyMetadataFactoryInterface::class); - $definitionNameFactory = new DefinitionNameFactory(null); + $definitionNameFactory = new DefinitionNameFactory(); $baseSchemaFactory = new BaseSchemaFactory( resourceMetadataFactory: $resourceMetadataFactory->reveal(), diff --git a/src/JsonApi/Tests/Serializer/ItemNormalizerTest.php b/src/JsonApi/Tests/Serializer/ItemNormalizerTest.php index a9af4cf4b5d..43b3e62c9ae 100644 --- a/src/JsonApi/Tests/Serializer/ItemNormalizerTest.php +++ b/src/JsonApi/Tests/Serializer/ItemNormalizerTest.php @@ -501,7 +501,7 @@ public function testNormalizeWithNullToOneAndEmptyToManyRelationships(): void ); $propertyMetadataFactory = $this->createMock(PropertyMetadataFactoryInterface::class); - $propertyMetadataFactory->method('create')->willReturnCallback(static function ($class, $property) { + $propertyMetadataFactory->method('create')->willReturnCallback(static function ($class, $property): ApiProperty { return match ($property) { 'id' => (new ApiProperty())->withReadable(true)->withIdentifier(true), 'name' => (new ApiProperty())->withReadable(true), @@ -522,10 +522,10 @@ public function testNormalizeWithNullToOneAndEmptyToManyRelationships(): void $resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class); $resourceClassResolver->method('getResourceClass')->willReturn(Dummy::class); - $resourceClassResolver->method('isResourceClass')->willReturnCallback(static fn ($class) => \in_array($class, [Dummy::class, RelatedDummy::class], true)); + $resourceClassResolver->method('isResourceClass')->willReturnCallback(static fn ($class): bool => \in_array($class, [Dummy::class, RelatedDummy::class], true)); $propertyAccessor = $this->createMock(PropertyAccessorInterface::class); - $propertyAccessor->method('getValue')->willReturnCallback(static function ($object, $property) { + $propertyAccessor->method('getValue')->willReturnCallback(static function ($object, $property): array|int|string|null { return match ($property) { 'id' => 1, 'name' => 'Dummy with relationships', diff --git a/src/JsonLd/Action/ContextAction.php b/src/JsonLd/Action/ContextAction.php index 74c144ed81b..7c09f4186fd 100644 --- a/src/JsonLd/Action/ContextAction.php +++ b/src/JsonLd/Action/ContextAction.php @@ -64,7 +64,7 @@ public function __invoke(string $shortName = 'Entrypoint', ?Request $request = n $operation = new Get( outputFormats: ['jsonld' => ['application/ld+json']], validate: false, - provider: fn () => $this->getContext($shortName), + provider: fn (): ?array => $this->getContext($shortName), serialize: false, read: true ); diff --git a/src/JsonLd/JsonStreamer/ValueTransformer/ContextValueTransformer.php b/src/JsonLd/JsonStreamer/ValueTransformer/ContextValueTransformer.php index fbf75692828..2186dde0af4 100644 --- a/src/JsonLd/JsonStreamer/ValueTransformer/ContextValueTransformer.php +++ b/src/JsonLd/JsonStreamer/ValueTransformer/ContextValueTransformer.php @@ -34,7 +34,7 @@ public function transform(mixed $value, array $options = []): mixed return $this->urlGenerator->generate('api_jsonld_context', ['shortName' => $options['operation']->getShortName()], $options['operation']->getUrlGenerationStrategy()); } - public static function getStreamValueType(): Type + public static function getStreamValueType(): Type\BuiltinType { return Type::string(); } diff --git a/src/JsonLd/JsonStreamer/ValueTransformer/IriValueTransformer.php b/src/JsonLd/JsonStreamer/ValueTransformer/IriValueTransformer.php index 383ed920c8a..24342bda4dd 100644 --- a/src/JsonLd/JsonStreamer/ValueTransformer/IriValueTransformer.php +++ b/src/JsonLd/JsonStreamer/ValueTransformer/IriValueTransformer.php @@ -45,7 +45,7 @@ public function transform(mixed $value, array $options = []): mixed ); } - public static function getStreamValueType(): Type + public static function getStreamValueType(): Type\BuiltinType { return Type::string(); } diff --git a/src/JsonLd/JsonStreamer/ValueTransformer/TypeValueTransformer.php b/src/JsonLd/JsonStreamer/ValueTransformer/TypeValueTransformer.php index 238a19d72b4..c75c3d2057e 100644 --- a/src/JsonLd/JsonStreamer/ValueTransformer/TypeValueTransformer.php +++ b/src/JsonLd/JsonStreamer/ValueTransformer/TypeValueTransformer.php @@ -54,7 +54,7 @@ public function transform(mixed $value, array $options = []): mixed return $this->getOperationType($op); } - public static function getStreamValueType(): Type + public static function getStreamValueType(): Type\BuiltinType { return Type::string(); } diff --git a/src/JsonSchema/Metadata/Property/Factory/SchemaPropertyMetadataFactory.php b/src/JsonSchema/Metadata/Property/Factory/SchemaPropertyMetadataFactory.php index 28e57b84c39..6fe3b1f93f2 100644 --- a/src/JsonSchema/Metadata/Property/Factory/SchemaPropertyMetadataFactory.php +++ b/src/JsonSchema/Metadata/Property/Factory/SchemaPropertyMetadataFactory.php @@ -201,7 +201,7 @@ private function getJsonSchemaFromType(Type $type, ?bool $readableLink = null): $isNullable = $type->isNullable(); if ($type instanceof UnionType) { - $subTypes = array_filter($type->getTypes(), static fn ($t) => !($t instanceof BuiltinType && $t->isIdentifiedBy(TypeIdentifier::NULL))); + $subTypes = array_filter($type->getTypes(), static fn (Type $t): bool => !($t instanceof BuiltinType && $t->isIdentifiedBy(TypeIdentifier::NULL))); foreach ($subTypes as $t) { $s = $this->getJsonSchemaFromType($t, $readableLink); @@ -211,7 +211,7 @@ private function getJsonSchemaFromType(Type $type, ?bool $readableLink = null): } } - $schemas = array_map(fn ($t) => $this->getJsonSchemaFromType($t, $readableLink), $subTypes); + $schemas = array_map(fn (Type $t): array => $this->getJsonSchemaFromType($t, $readableLink), $subTypes); if (0 === \count($schemas)) { $schema = []; @@ -246,7 +246,7 @@ private function getJsonSchemaFromType(Type $type, ?bool $readableLink = null): $keyType = $type->getCollectionKeyType(); // Associative array (string keys) - if ($keyType->isSatisfiedBy(static fn (Type $t) => $t instanceof BuiltinType && $t->isIdentifiedBy(TypeIdentifier::INT))) { + if ($keyType->isSatisfiedBy(static fn (Type $t): bool => $t instanceof BuiltinType && $t->isIdentifiedBy(TypeIdentifier::INT))) { $schema = [ 'type' => 'array', 'items' => $valueSchema, diff --git a/src/JsonSchema/Tests/Fixtures/ApiResource/Dummy.php b/src/JsonSchema/Tests/Fixtures/ApiResource/Dummy.php index ee45c52e851..f788e6c87ba 100644 --- a/src/JsonSchema/Tests/Fixtures/ApiResource/Dummy.php +++ b/src/JsonSchema/Tests/Fixtures/ApiResource/Dummy.php @@ -162,7 +162,7 @@ public function getDummyDate() return $this->dummyDate; } - public function setDummyPrice($dummyPrice) + public function setDummyPrice($dummyPrice): static { $this->dummyPrice = $dummyPrice; diff --git a/src/JsonSchema/Tests/Fixtures/NotAResource.php b/src/JsonSchema/Tests/Fixtures/NotAResource.php index 0ef16478cbd..4104ef2e071 100644 --- a/src/JsonSchema/Tests/Fixtures/NotAResource.php +++ b/src/JsonSchema/Tests/Fixtures/NotAResource.php @@ -47,7 +47,7 @@ public function getBar() /** * @return array> */ - public function getItems() + public function getItems(): array { return $this->items; } diff --git a/src/JsonSchema/Tests/Fixtures/NotAResourceWithUnionIntersectTypes.php b/src/JsonSchema/Tests/Fixtures/NotAResourceWithUnionIntersectTypes.php index d28cf68ac90..8d1ec1e65bf 100644 --- a/src/JsonSchema/Tests/Fixtures/NotAResourceWithUnionIntersectTypes.php +++ b/src/JsonSchema/Tests/Fixtures/NotAResourceWithUnionIntersectTypes.php @@ -33,12 +33,12 @@ public function getIgnoredProperty() return $this->ignoredProperty; } - public function getUnionType() + public function getUnionType(): string|int|float|null { return $this->unionType; } - public function getIntersectType() + public function getIntersectType(): Serializable&DummyResourceInterface { return $this->intersectType; } diff --git a/src/Laravel/ApiPlatformDeferredProvider.php b/src/Laravel/ApiPlatformDeferredProvider.php index 937e8c49dca..8fc7804c12a 100644 --- a/src/Laravel/ApiPlatformDeferredProvider.php +++ b/src/Laravel/ApiPlatformDeferredProvider.php @@ -115,26 +115,26 @@ public function register(): void } $this->autoconfigure($classes, QueryExtensionInterface::class, [FilterQueryExtension::class]); - $this->app->singleton(ItemProvider::class, static function (Application $app) { + $this->app->singleton(ItemProvider::class, static function (Application $app): ItemProvider { $tagged = iterator_to_array($app->tagged(LinksHandlerInterface::class)); return new ItemProvider(new LinksHandler($app, $app->make(ResourceMetadataCollectionFactoryInterface::class)), new ServiceLocator($tagged), $app->tagged(QueryExtensionInterface::class)); }); - $this->app->singleton(CollectionProvider::class, static function (Application $app) { + $this->app->singleton(CollectionProvider::class, static function (Application $app): CollectionProvider { $tagged = iterator_to_array($app->tagged(LinksHandlerInterface::class)); return new CollectionProvider($app->make(Pagination::class), new LinksHandler($app, $app->make(ResourceMetadataCollectionFactoryInterface::class)), $app->tagged(QueryExtensionInterface::class), new ServiceLocator($tagged)); }); - $this->app->singleton(SerializerFilterParameterProvider::class, static function (Application $app) { + $this->app->singleton(SerializerFilterParameterProvider::class, static function (Application $app): SerializerFilterParameterProvider { $tagged = iterator_to_array($app->tagged(SerializerFilterInterface::class)); return new SerializerFilterParameterProvider(new ServiceLocator($tagged)); }); $this->app->alias(SerializerFilterParameterProvider::class, 'api_platform.serializer.filter_parameter_provider'); - $this->app->singleton('filters', static function (Application $app) { + $this->app->singleton('filters', static function (Application $app): ServiceLocator { return new ServiceLocator(array_merge( iterator_to_array($app->tagged(SerializerFilterInterface::class)), iterator_to_array($app->tagged(EloquentFilterInterface::class)) @@ -143,7 +143,7 @@ public function register(): void $this->autoconfigure($classes, SerializerFilterInterface::class, [PropertyFilter::class]); - $this->app->singleton(ParameterProvider::class, static function (Application $app) { + $this->app->singleton(ParameterProvider::class, static function (Application $app): ParameterProvider { $tagged = iterator_to_array($app->tagged(ParameterProviderInterface::class)); $tagged['api_platform.serializer.filter_parameter_provider'] = $app->make(SerializerFilterParameterProvider::class); @@ -160,7 +160,7 @@ public function register(): void $this->autoconfigure($classes, ParameterProviderInterface::class, [SerializerFilterParameterProvider::class, SortFilterParameterProvider::class, SparseFieldsetParameterProvider::class]); - $this->app->bind(FilterQueryExtension::class, static function (Application $app) { + $this->app->bind(FilterQueryExtension::class, static function (Application $app): FilterQueryExtension { $tagged = iterator_to_array($app->tagged(EloquentFilterInterface::class)); return new FilterQueryExtension(new ServiceLocator($tagged)); @@ -179,7 +179,7 @@ public function register(): void SparseFieldset::class, ]); - $this->app->singleton(CallableProcessor::class, static function (Application $app) { + $this->app->singleton(CallableProcessor::class, static function (Application $app): CallableProcessor { /** @var ConfigRepository */ $config = $app['config']; $tagged = iterator_to_array($app->tagged(ProcessorInterface::class)); @@ -194,14 +194,14 @@ public function register(): void $this->autoconfigure($classes, ProcessorInterface::class, [RemoveProcessor::class, PersistProcessor::class]); - $this->app->singleton(CallableProvider::class, static function (Application $app) { + $this->app->singleton(CallableProvider::class, static function (Application $app): CallableProvider { $tagged = iterator_to_array($app->tagged(ProviderInterface::class)); return new CallableProvider(new ServiceLocator($tagged)); }); if (class_exists(ToolProvider::class)) { - $this->app->singleton(ToolProvider::class, static function (Application $app) { + $this->app->singleton(ToolProvider::class, static function (Application $app): ToolProvider { return new ToolProvider( $app->make(ObjectMapper::class) ); @@ -210,7 +210,7 @@ public function register(): void $this->autoconfigure($classes, ProviderInterface::class, [ItemProvider::class, CollectionProvider::class, ErrorProvider::class, ToolProvider::class]); - $this->app->singleton(ResourceMetadataCollectionFactoryInterface::class, function (Application $app) { + $this->app->singleton(ResourceMetadataCollectionFactoryInterface::class, function (Application $app): CacheResourceCollectionMetadataFactory { /** @var ConfigRepository $config */ $config = $app['config']; $formats = $config->get('api-platform.formats'); @@ -274,7 +274,7 @@ public function register(): void $this->app->extend( ExceptionHandler::class, - static function (ExceptionHandler $decorated, Application $app) { + static function (ExceptionHandler $decorated, Application $app): ErrorHandler { /** @var ConfigRepository */ $config = $app['config']; @@ -300,7 +300,7 @@ static function (ExceptionHandler $decorated, Application $app) { private function registerGraphQl(): void { - $this->app->singleton('api_platform.graphql.state_provider.parameter', static function (Application $app) { + $this->app->singleton('api_platform.graphql.state_provider.parameter', static function (Application $app): ParameterProvider { $tagged = iterator_to_array($app->tagged(ParameterProviderInterface::class)); $tagged['api_platform.serializer.filter_parameter_provider'] = $app->make(SerializerFilterParameterProvider::class); @@ -315,7 +315,7 @@ private function registerGraphQl(): void ); }); - $this->app->singleton(FieldsBuilderEnumInterface::class, static function (Application $app) { + $this->app->singleton(FieldsBuilderEnumInterface::class, static function (Application $app): FieldsBuilder { /** @var ConfigRepository */ $config = $app['config']; diff --git a/src/Laravel/ApiPlatformProvider.php b/src/Laravel/ApiPlatformProvider.php index 893f5406b66..3a46c0dcd92 100644 --- a/src/Laravel/ApiPlatformProvider.php +++ b/src/Laravel/ApiPlatformProvider.php @@ -224,7 +224,7 @@ public function register(): void { $this->mergeConfigFrom(__DIR__.'/config/api-platform.php', 'api-platform'); - $this->app->singleton(PropertyInfoExtractorInterface::class, static function (Application $app) { + $this->app->singleton(PropertyInfoExtractorInterface::class, static function (Application $app): PropertyInfoExtractor { $phpstanExtractor = class_exists(PhpDocParser::class) ? new PhpStanExtractor() : null; $reflectionExtractor = new ReflectionExtractor(); $eloquentExtractor = new EloquentExtractor($app->make(ModelMetadata::class)); @@ -238,12 +238,12 @@ public function register(): void ); }); - $this->app->singleton(ModelMetadata::class, static function () { + $this->app->singleton(ModelMetadata::class, static function (): ModelMetadata { return new ModelMetadata(); }); $this->app->bind(ClassMetadataFactoryInterface::class, ClassMetadataFactory::class); - $this->app->singleton(ClassMetadataFactory::class, static function (Application $app) { + $this->app->singleton(ClassMetadataFactory::class, static function (Application $app): ClassMetadataFactory { /** @var ConfigRepository */ $config = $app['config']; $nameConverter = $config->get('api-platform.name_converter', SnakeCaseToCamelCaseNameConverter::class); @@ -263,13 +263,13 @@ public function register(): void ); }); - $this->app->singleton(SerializerClassMetadataFactory::class, static function (Application $app) { + $this->app->singleton(SerializerClassMetadataFactory::class, static function (Application $app): SerializerClassMetadataFactory { return new SerializerClassMetadataFactory($app->make(ClassMetadataFactoryInterface::class)); }); $this->app->bind(PathSegmentNameGeneratorInterface::class, UnderscorePathSegmentNameGenerator::class); - $this->app->singleton(ResourceNameCollectionFactoryInterface::class, static function (Application $app) { + $this->app->singleton(ResourceNameCollectionFactoryInterface::class, static function (Application $app): ConcernsResourceNameCollectionFactory { /** @var ConfigRepository */ $config = $app['config']; $paths = $config->get('api-platform.resources') ?? []; @@ -289,16 +289,16 @@ public function register(): void }); $this->app->bind(ResourceClassResolverInterface::class, ResourceClassResolver::class); - $this->app->singleton(ResourceClassResolver::class, static function (Application $app) { + $this->app->singleton(ResourceClassResolver::class, static function (Application $app): EloquentResourceClassResolver { return new EloquentResourceClassResolver(new ResourceClassResolver($app->make(ResourceNameCollectionFactoryInterface::class))); }); $this->app->bind(OperationResourceClassResolverInterface::class, EloquentOperationResourceClassResolver::class); - $this->app->singleton(EloquentOperationResourceClassResolver::class, static function (Application $app) { + $this->app->singleton(EloquentOperationResourceClassResolver::class, static function (Application $app): EloquentOperationResourceClassResolver { return new EloquentOperationResourceClassResolver(); }); - $this->app->singleton(PropertyMetadataFactoryInterface::class, static function (Application $app) { + $this->app->singleton(PropertyMetadataFactoryInterface::class, static function (Application $app): CachePropertyMetadataFactory { /** @var ConfigRepository $config */ $config = $app['config']; $nameConverter = $config->get('api-platform.name_converter', SnakeCaseToCamelCaseNameConverter::class); @@ -329,7 +329,7 @@ public function register(): void ); }); - $this->app->singleton(PropertyNameCollectionFactoryInterface::class, static function (Application $app) { + $this->app->singleton(PropertyNameCollectionFactoryInterface::class, static function (Application $app): CachePropertyNameCollectionMetadataFactory { /** @var ConfigRepository $config */ $config = $app['config']; $nameConverter = $config->get('api-platform.name_converter', SnakeCaseToCamelCaseNameConverter::class); @@ -352,7 +352,7 @@ public function register(): void ); }); - $this->app->singleton(LinkFactoryInterface::class, static function (Application $app) { + $this->app->singleton(LinkFactoryInterface::class, static function (Application $app): LinkFactory { return new LinkFactory( $app->make(PropertyNameCollectionFactoryInterface::class), $app->make(PropertyMetadataFactoryInterface::class), @@ -360,11 +360,11 @@ public function register(): void ); }); - $this->app->bind(PropertyAccessorInterface::class, static function (Application $app) { + $this->app->bind(PropertyAccessorInterface::class, static function (Application $app): EloquentPropertyAccessor { return new EloquentPropertyAccessor(null, $app->make(ModelMetadata::class)); }); - $this->app->bind(NameConverterInterface::class, static function (Application $app) { + $this->app->bind(NameConverterInterface::class, static function (Application $app): HydraPrefixNameConverter { $config = $app['config']; $nameConverter = $config->get('api-platform.name_converter', SnakeCaseToCamelCaseNameConverter::class); if ($nameConverter && class_exists($nameConverter)) { @@ -378,7 +378,7 @@ public function register(): void // ObjectMapper metadata factory support if (interface_exists(ObjectMapperInterface::class)) { - $this->app->extend(ResourceMetadataCollectionFactoryInterface::class, static function (ResourceMetadataCollectionFactoryInterface $inner, Application $app) { + $this->app->extend(ResourceMetadataCollectionFactoryInterface::class, static function (ResourceMetadataCollectionFactoryInterface $inner, Application $app): ObjectMapperMetadataCollectionFactory { return new ObjectMapperMetadataCollectionFactory( $inner, $app->make(ObjectMapperMetadataFactoryInterface::class) @@ -387,32 +387,32 @@ public function register(): void } // Parameter metadata factory with Laravel Eloquent support - $this->app->extend(ResourceMetadataCollectionFactoryInterface::class, static function (ResourceMetadataCollectionFactoryInterface $inner, Application $app) { + $this->app->extend(ResourceMetadataCollectionFactoryInterface::class, static function (ResourceMetadataCollectionFactoryInterface $inner, Application $app): Metadata\Resource\Factory\ParameterResourceMetadataCollectionFactory { return new Metadata\Resource\Factory\ParameterResourceMetadataCollectionFactory($inner, $app->make(ModelMetadata::class), new \Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter()); }); - $this->app->singleton(OperationMetadataFactory::class, static function (Application $app) { + $this->app->singleton(OperationMetadataFactory::class, static function (Application $app): OperationMetadataFactory { return new OperationMetadataFactory($app->make(ResourceNameCollectionFactoryInterface::class), $app->make(ResourceMetadataCollectionFactoryInterface::class)); }); $this->app->bind(OperationMetadataFactoryInterface::class, OperationMetadataFactory::class); - $this->app->singleton(ReadProvider::class, static function (Application $app) { + $this->app->singleton(ReadProvider::class, static function (Application $app): ReadProvider { return new ReadProvider($app->make(CallableProvider::class)); }); - $this->app->singleton(SwaggerUiProvider::class, static function (Application $app) { + $this->app->singleton(SwaggerUiProvider::class, static function (Application $app): SwaggerUiProvider { /** @var ConfigRepository */ $config = $app['config']; return new SwaggerUiProvider($app->make(ReadProvider::class), $app->make(OpenApiFactoryInterface::class), $config->get('api-platform.swagger_ui.enabled', false)); }); - $this->app->singleton(DeserializeProvider::class, static function (Application $app) { + $this->app->singleton(DeserializeProvider::class, static function (Application $app): DeserializeProvider { return new DeserializeProvider($app->make(SwaggerUiProvider::class), $app->make(SerializerInterface::class), $app->make(SerializerContextBuilderInterface::class)); }); - $this->app->singleton(ValidateProvider::class, static function (Application $app) { + $this->app->singleton(ValidateProvider::class, static function (Application $app): ValidateProvider { $config = $app['config']; $nameConverter = $config->get('api-platform.name_converter', SnakeCaseToCamelCaseNameConverter::class); if ($nameConverter && class_exists($nameConverter)) { @@ -423,23 +423,23 @@ public function register(): void }); if (class_exists(JsonApiProvider::class)) { - $this->app->extend(DeserializeProvider::class, static function (ProviderInterface $inner, Application $app) { + $this->app->extend(DeserializeProvider::class, static function (ProviderInterface $inner, Application $app): JsonApiProvider { return new JsonApiProvider($inner); }); } - $this->app->singleton(SortFilterParameterProvider::class, static function (Application $app) { + $this->app->singleton(SortFilterParameterProvider::class, static function (Application $app): SortFilterParameterProvider { return new SortFilterParameterProvider(); }); - $this->app->singleton(AccessCheckerProvider::class, static function (Application $app) { + $this->app->singleton(AccessCheckerProvider::class, static function (Application $app): AccessCheckerProvider { return new AccessCheckerProvider($app->make(ParameterProvider::class), $app->make(ResourceAccessCheckerInterface::class)); }); - $this->app->singleton(Negotiator::class, static function (Application $app) { + $this->app->singleton(Negotiator::class, static function (Application $app): Negotiator { return new Negotiator(); }); - $this->app->singleton(ContentNegotiationProvider::class, static function (Application $app) { + $this->app->singleton(ContentNegotiationProvider::class, static function (Application $app): ContentNegotiationProvider { /** @var ConfigRepository */ $config = $app['config']; @@ -452,18 +452,18 @@ public function register(): void if (interface_exists(ObjectMapperInterface::class)) { $this->app->singleton(ObjectMapperMetadataFactoryInterface::class, ReflectionObjectMapperMetadataFactory::class); - $this->app->singleton(ObjectMapper::class, static function (Application $app) { + $this->app->singleton(ObjectMapper::class, static function (Application $app): ObjectMapper { return new ObjectMapper( $app->make(ObjectMapperMetadataFactoryInterface::class) ); }); - $this->app->extend(ProviderInterface::class, static function (ProviderInterface $inner, Application $app) { + $this->app->extend(ProviderInterface::class, static function (ProviderInterface $inner, Application $app): ObjectMapperProvider { return new ObjectMapperProvider($app->make(ObjectMapper::class), $inner); }); } - $this->app->singleton(RespondProcessor::class, static function (Application $app) { + $this->app->singleton(RespondProcessor::class, static function (Application $app): AddLinkHeaderProcessor { $decorated = new RespondProcessor( $app->make(IriConverterInterface::class), $app->make(ResourceClassResolverInterface::class), @@ -490,11 +490,11 @@ public function register(): void return new AddLinkHeaderProcessor($decorated, new HttpHeaderSerializer()); }); - $this->app->singleton(SerializeProcessor::class, static function (Application $app) { + $this->app->singleton(SerializeProcessor::class, static function (Application $app): SerializeProcessor { return new SerializeProcessor($app->make(RespondProcessor::class), $app->make(Serializer::class), $app->make(SerializerContextBuilderInterface::class)); }); - $this->app->singleton(WriteProcessor::class, static function (Application $app) { + $this->app->singleton(WriteProcessor::class, static function (Application $app): WriteProcessor { $inner = $app->make(SerializeProcessor::class); if (interface_exists(ObjectMapperInterface::class)) { @@ -504,14 +504,14 @@ public function register(): void return new WriteProcessor($inner, $app->make(CallableProcessor::class)); }); - $this->app->singleton(SerializerContextBuilder::class, static function (Application $app) { + $this->app->singleton(SerializerContextBuilder::class, static function (Application $app): SerializerContextBuilder { /** @var ConfigRepository */ $config = $app['config']; return new SerializerContextBuilder($app->make(ResourceMetadataCollectionFactoryInterface::class), $config->get('app.debug')); }); $this->app->bind(SerializerContextBuilderInterface::class, EloquentSerializerContextBuilder::class); - $this->app->singleton(EloquentSerializerContextBuilder::class, static function (Application $app) { + $this->app->singleton(EloquentSerializerContextBuilder::class, static function (Application $app): EloquentSerializerContextBuilder { /** @var ConfigRepository */ $config = $app['config']; @@ -522,7 +522,7 @@ public function register(): void ); }); - $this->app->singleton(HydraLinkProcessor::class, static function (Application $app) { + $this->app->singleton(HydraLinkProcessor::class, static function (Application $app): HydraLinkProcessor { return new HydraLinkProcessor($app->make(WriteProcessor::class), $app->make(UrlGeneratorInterface::class)); }); @@ -537,51 +537,51 @@ public function register(): void // ObjectMapperInputProcessor wraps the base processor if available if (interface_exists(ObjectMapperInterface::class)) { - $this->app->extend(ProcessorInterface::class, static function (ProcessorInterface $inner, Application $app) { + $this->app->extend(ProcessorInterface::class, static function (ProcessorInterface $inner, Application $app): ObjectMapperInputProcessor { return new ObjectMapperInputProcessor($app->make(ObjectMapper::class), $inner); }); } - $this->app->singleton(ObjectNormalizer::class, static function (Application $app) { + $this->app->singleton(ObjectNormalizer::class, static function (Application $app): ObjectNormalizer { $config = $app['config']; $defaultContext = $config->get('api-platform.serializer', []); return new ObjectNormalizer($app->make(ClassMetadataFactoryInterface::class), defaultContext: $defaultContext); }); - $this->app->singleton(DateTimeNormalizer::class, static function (Application $app) { + $this->app->singleton(DateTimeNormalizer::class, static function (Application $app): DateTimeNormalizer { $config = $app['config']; $defaultContext = $config->get('api-platform.serializer', []); return new DateTimeNormalizer(defaultContext: $defaultContext); }); - $this->app->singleton(DateTimeZoneNormalizer::class, static function () { + $this->app->singleton(DateTimeZoneNormalizer::class, static function (): DateTimeZoneNormalizer { return new DateTimeZoneNormalizer(); }); - $this->app->singleton(DateIntervalNormalizer::class, static function (Application $app) { + $this->app->singleton(DateIntervalNormalizer::class, static function (Application $app): DateIntervalNormalizer { $config = $app['config']; $defaultContext = $config->get('api-platform.serializer', []); return new DateIntervalNormalizer(defaultContext: $defaultContext); }); - $this->app->singleton(JsonEncoder::class, static function () { + $this->app->singleton(JsonEncoder::class, static function (): JsonEncoder { return new JsonEncoder('jsonld'); }); $this->app->bind(IriConverterInterface::class, IriConverter::class); - $this->app->singleton(IriConverter::class, static function (Application $app) { + $this->app->singleton(IriConverter::class, static function (Application $app): IriConverter { return new IriConverter($app->make(CallableProvider::class), $app->make(OperationMetadataFactoryInterface::class), $app->make(UrlGeneratorRouter::class), $app->make(IdentifiersExtractorInterface::class), $app->make(ResourceClassResolverInterface::class), $app->make(ResourceMetadataCollectionFactoryInterface::class), $app->make(SkolemIriConverter::class), null, $app->make(OperationResourceClassResolverInterface::class)); }); - $this->app->singleton(SkolemIriConverter::class, static function (Application $app) { + $this->app->singleton(SkolemIriConverter::class, static function (Application $app): SkolemIriConverter { return new SkolemIriConverter($app->make(UrlGeneratorRouter::class)); }); $this->app->bind(IdentifiersExtractorInterface::class, IdentifiersExtractor::class); - $this->app->singleton(IdentifiersExtractor::class, static function (Application $app) { + $this->app->singleton(IdentifiersExtractor::class, static function (Application $app): EloquentIdentifiersExtractor { return new EloquentIdentifiersExtractor( new IdentifiersExtractor( $app->make(ResourceMetadataCollectionFactoryInterface::class), @@ -594,7 +594,7 @@ public function register(): void }); $this->app->bind(UrlGeneratorInterface::class, UrlGeneratorRouter::class); - $this->app->singleton(UrlGeneratorRouter::class, static function (Application $app) { + $this->app->singleton(UrlGeneratorRouter::class, static function (Application $app): UrlGeneratorRouter { $request = $app->make('request'); // https://github.com/laravel/framework/blob/2bfb70bca53e24227a6f921f39d84ba452efd8e0/src/Illuminate/Routing/CompiledRouteCollection.php#L112 $trimmedRequest = $request->duplicate(); @@ -611,7 +611,7 @@ public function register(): void }); $this->app->bind(ContextBuilderInterface::class, JsonLdContextBuilder::class); - $this->app->singleton(JsonLdContextBuilder::class, static function (Application $app) { + $this->app->singleton(JsonLdContextBuilder::class, static function (Application $app): JsonLdContextBuilder { $config = $app['config']; $defaultContext = $config->get('api-platform.serializer', []); @@ -627,15 +627,15 @@ public function register(): void ); }); - $this->app->singleton(HydraEntrypointNormalizer::class, static function (Application $app) { + $this->app->singleton(HydraEntrypointNormalizer::class, static function (Application $app): HydraEntrypointNormalizer { return new HydraEntrypointNormalizer($app->make(ResourceMetadataCollectionFactoryInterface::class), $app->make(IriConverterInterface::class), $app->make(UrlGeneratorInterface::class)); }); - $this->app->singleton(ResourceAccessCheckerInterface::class, static function () { + $this->app->singleton(ResourceAccessCheckerInterface::class, static function (): ResourceAccessChecker { return new ResourceAccessChecker(); }); - $this->app->singleton(ItemNormalizer::class, static function (Application $app) { + $this->app->singleton(ItemNormalizer::class, static function (Application $app): ItemNormalizer { /** @var ConfigRepository */ $config = $app['config']; $defaultContext = $config->get('api-platform.serializer', []); @@ -660,7 +660,7 @@ public function register(): void $this->app->bind(AnonymousContextBuilderInterface::class, JsonLdContextBuilder::class); - $this->app->singleton(JsonLdObjectNormalizer::class, static function (Application $app) { + $this->app->singleton(JsonLdObjectNormalizer::class, static function (Application $app): JsonLdObjectNormalizer { return new JsonLdObjectNormalizer( $app->make(ObjectNormalizer::class), $app->make(IriConverterInterface::class), @@ -668,7 +668,7 @@ public function register(): void ); }); - $this->app->singleton(HalCollectionNormalizer::class, static function (Application $app) { + $this->app->singleton(HalCollectionNormalizer::class, static function (Application $app): HalCollectionNormalizer { /** @var ConfigRepository */ $config = $app['config']; @@ -679,14 +679,14 @@ public function register(): void ); }); - $this->app->singleton(HalObjectNormalizer::class, static function (Application $app) { + $this->app->singleton(HalObjectNormalizer::class, static function (Application $app): HalObjectNormalizer { return new HalObjectNormalizer( $app->make(ObjectNormalizer::class), $app->make(IriConverterInterface::class) ); }); - $this->app->singleton(HalItemNormalizer::class, static function (Application $app) { + $this->app->singleton(HalItemNormalizer::class, static function (Application $app): HalItemNormalizer { /** @var ConfigRepository */ $config = $app['config']; $defaultContext = $config->get('api-platform.serializer', []); @@ -706,7 +706,7 @@ public function register(): void ); }); - $this->app->singleton(Options::class, static function (Application $app) { + $this->app->singleton(Options::class, static function (Application $app): Options { /** @var ConfigRepository */ $config = $app['config']; @@ -715,11 +715,11 @@ public function register(): void description: $config->get('api-platform.description', ''), version: $config->get('api-platform.version', ''), oAuthEnabled: $config->get('api-platform.swagger_ui.oauth.enabled', false), - oAuthType: $config->get('api-platform.swagger_ui.oauth.type', null), - oAuthFlow: $config->get('api-platform.swagger_ui.oauth.flow', null), - oAuthTokenUrl: $config->get('api-platform.swagger_ui.oauth.tokenUrl', null), - oAuthAuthorizationUrl: $config->get('api-platform.swagger_ui.oauth.authorizationUrl', null), - oAuthRefreshUrl: $config->get('api-platform.swagger_ui.oauth.refreshUrl', null), + oAuthType: $config->get('api-platform.swagger_ui.oauth.type'), + oAuthFlow: $config->get('api-platform.swagger_ui.oauth.flow'), + oAuthTokenUrl: $config->get('api-platform.swagger_ui.oauth.tokenUrl'), + oAuthAuthorizationUrl: $config->get('api-platform.swagger_ui.oauth.authorizationUrl'), + oAuthRefreshUrl: $config->get('api-platform.swagger_ui.oauth.refreshUrl'), oAuthScopes: $config->get('api-platform.swagger_ui.oauth.scopes', []), apiKeys: $config->get('api-platform.swagger_ui.apiKeys', []), contactName: $config->get('api-platform.swagger_ui.contact.name', ''), @@ -735,7 +735,7 @@ public function register(): void ); }); - $this->app->singleton(SwaggerUiProcessor::class, static function (Application $app) { + $this->app->singleton(SwaggerUiProcessor::class, static function (Application $app): SwaggerUiProcessor { /** @var ConfigRepository */ $config = $app['config']; @@ -751,32 +751,32 @@ public function register(): void // Note: this class is not included it is used as a string alias as Errors declare this controller $this->app->alias(\ApiPlatform\Symfony\Action\NotExposedAction::class, 'api_platform.action.not_exposed'); - $this->app->singleton('api_platform.action.not_exposed', static function () { + $this->app->singleton('api_platform.action.not_exposed', static function (): NotExposedController { return new NotExposedController(); }); - $this->app->singleton(DocumentationController::class, static function (Application $app) { + $this->app->singleton(DocumentationController::class, static function (Application $app): DocumentationController { /** @var ConfigRepository */ $config = $app['config']; return new DocumentationController($app->make(ResourceNameCollectionFactoryInterface::class), $config->get('api-platform.title') ?? '', $config->get('api-platform.description') ?? '', $config->get('api-platform.version') ?? '', $app->make(OpenApiFactoryInterface::class), $app->make(ProviderInterface::class), $app->make(ProcessorInterface::class), $app->make(Negotiator::class), $config->get('api-platform.docs_formats'), $config->get('api-platform.swagger_ui.enabled', false)); }); - $this->app->singleton(EntrypointController::class, static function (Application $app) { + $this->app->singleton(EntrypointController::class, static function (Application $app): EntrypointController { /** @var ConfigRepository */ $config = $app['config']; return new EntrypointController($app->make(ResourceNameCollectionFactoryInterface::class), $app->make(ProviderInterface::class), $app->make(ProcessorInterface::class), $config->get('api-platform.docs_formats')); }); - $this->app->singleton(Pagination::class, static function (Application $app) { + $this->app->singleton(Pagination::class, static function (Application $app): Pagination { /** @var ConfigRepository */ $config = $app['config']; return new Pagination($config->get('api-platform.pagination'), []); }); - $this->app->singleton(PaginationOptions::class, static function (Application $app) { + $this->app->singleton(PaginationOptions::class, static function (Application $app): PaginationOptions { /** @var ConfigRepository */ $config = $app['config']; $defaults = $config->get('api-platform.defaults'); @@ -798,7 +798,7 @@ public function register(): void }); $this->app->bind(OpenApiFactoryInterface::class, OpenApiFactory::class); - $this->app->singleton(OpenApiFactory::class, static function (Application $app) { + $this->app->singleton(OpenApiFactory::class, static function (Application $app): OpenApiFactory { /** @var ConfigRepository */ $config = $app['config']; @@ -818,16 +818,16 @@ public function register(): void ); }); - $this->app->singleton(OpenApiCommand::class, static function (Application $app) { + $this->app->singleton(OpenApiCommand::class, static function (Application $app): OpenApiCommand { return new OpenApiCommand($app->make(OpenApiFactory::class), $app->make(Serializer::class)); }); $this->app->bind(DefinitionNameFactoryInterface::class, DefinitionNameFactory::class); - $this->app->singleton(DefinitionNameFactory::class, static function (Application $app) { + $this->app->singleton(DefinitionNameFactory::class, static function (Application $app): DefinitionNameFactory { return new DefinitionNameFactory(); }); - $this->app->singleton(SchemaFactory::class, static function (Application $app) { + $this->app->singleton(SchemaFactory::class, static function (Application $app): SchemaFactory { /** @var ConfigRepository */ $config = $app['config']; @@ -841,7 +841,7 @@ public function register(): void $app->make(DefinitionNameFactoryInterface::class), ); }); - $this->app->singleton(JsonApiSchemaFactory::class, static function (Application $app) { + $this->app->singleton(JsonApiSchemaFactory::class, static function (Application $app): JsonApiSchemaFactory { return new JsonApiSchemaFactory( $app->make(SchemaFactory::class), $app->make(PropertyMetadataFactoryInterface::class), @@ -850,7 +850,7 @@ public function register(): void $app->make(DefinitionNameFactoryInterface::class), ); }); - $this->app->singleton(HydraSchemaFactory::class, static function (Application $app) { + $this->app->singleton(HydraSchemaFactory::class, static function (Application $app): HydraSchemaFactory { $config = $app['config']; $defaultContext = $config->get('api-platform.serializer', []); @@ -862,11 +862,11 @@ public function register(): void $this->app->bind(SchemaFactoryInterface::class, HydraSchemaFactory::class); - $this->app->singleton(OpenApiNormalizer::class, static function (Application $app) { + $this->app->singleton(OpenApiNormalizer::class, static function (Application $app): OpenApiNormalizer { return new OpenApiNormalizer($app->make(ObjectNormalizer::class)); }); - $this->app->singleton(HydraDocumentationNormalizer::class, static function (Application $app) { + $this->app->singleton(HydraDocumentationNormalizer::class, static function (Application $app): HydraDocumentationNormalizer { $config = $app['config']; $defaultContext = $config->get('api-platform.serializer', []); $entrypointEnabled = $config->get('api-platform.enable_entrypoint', true); @@ -883,7 +883,7 @@ public function register(): void ); }); - $this->app->singleton(HydraPartialCollectionViewNormalizer::class, static function (Application $app) { + $this->app->singleton(HydraPartialCollectionViewNormalizer::class, static function (Application $app): HydraPartialCollectionViewNormalizer { $config = $app['config']; $defaultContext = $config->get('api-platform.serializer', []); @@ -909,7 +909,7 @@ public function register(): void ); }); - $this->app->singleton(ReservedAttributeNameConverter::class, static function (Application $app) { + $this->app->singleton(ReservedAttributeNameConverter::class, static function (Application $app): ReservedAttributeNameConverter { return new ReservedAttributeNameConverter($app->make(NameConverterInterface::class)); }); @@ -919,7 +919,7 @@ public function register(): void $this->registerMcp(); - $this->app->singleton(JsonApiEntrypointNormalizer::class, static function (Application $app) { + $this->app->singleton(JsonApiEntrypointNormalizer::class, static function (Application $app): JsonApiEntrypointNormalizer { return new JsonApiEntrypointNormalizer( $app->make(ResourceMetadataCollectionFactoryInterface::class), $app->make(IriConverterInterface::class), @@ -927,7 +927,7 @@ public function register(): void ); }); - $this->app->singleton(JsonApiCollectionNormalizer::class, static function (Application $app) { + $this->app->singleton(JsonApiCollectionNormalizer::class, static function (Application $app): JsonApiCollectionNormalizer { /** @var ConfigRepository */ $config = $app['config']; @@ -938,7 +938,7 @@ public function register(): void ); }); - $this->app->singleton(JsonApiItemNormalizer::class, static function (Application $app) { + $this->app->singleton(JsonApiItemNormalizer::class, static function (Application $app): JsonApiItemNormalizer { $config = $app['config']; $defaultContext = $config->get('api-platform.serializer', []); @@ -957,13 +957,13 @@ public function register(): void ); }); - $this->app->singleton(JsonApiErrorNormalizer::class, static function (Application $app) { + $this->app->singleton(JsonApiErrorNormalizer::class, static function (Application $app): JsonApiErrorNormalizer { return new JsonApiErrorNormalizer( $app->make(JsonApiItemNormalizer::class), ); }); - $this->app->singleton(JsonApiObjectNormalizer::class, static function (Application $app) { + $this->app->singleton(JsonApiObjectNormalizer::class, static function (Application $app): JsonApiObjectNormalizer { return new JsonApiObjectNormalizer( $app->make(ObjectNormalizer::class), $app->make(IriConverterInterface::class), @@ -972,7 +972,7 @@ public function register(): void ); }); - $this->app->singleton('api_platform_normalizer_list', static function (Application $app) { + $this->app->singleton('api_platform_normalizer_list', static function (Application $app): \SplPriorityQueue { $list = new \SplPriorityQueue(); $list->insert($app->make(HydraEntrypointNormalizer::class), -800); $list->insert($app->make(HydraPartialCollectionViewNormalizer::class), -800); @@ -1012,7 +1012,7 @@ public function register(): void $this->app->bind(SerializerInterface::class, Serializer::class); $this->app->bind(NormalizerInterface::class, Serializer::class); - $this->app->singleton(Serializer::class, static function (Application $app) { + $this->app->singleton(Serializer::class, static function (Application $app): Serializer { // TODO: unused + implement hal/jsonapi ? // $list->insert($dataUriNormalizer, -920); // $list->insert($unwrappingDenormalizer, 1000); @@ -1032,7 +1032,7 @@ public function register(): void ); }); - $this->app->singleton(JsonLdItemNormalizer::class, static function (Application $app) { + $this->app->singleton(JsonLdItemNormalizer::class, static function (Application $app): JsonLdItemNormalizer { $config = $app['config']; $defaultContext = $config->get('api-platform.serializer', []); @@ -1055,7 +1055,7 @@ public function register(): void ); }); - $this->app->singleton(InflectorInterface::class, static function (Application $app) { + $this->app->singleton(InflectorInterface::class, static function (Application $app): Inflector { return new Inflector(); }); @@ -1076,14 +1076,14 @@ private function registerMcp(): void return; } - $this->app->singleton(Registry::class, static function (Application $app) { + $this->app->singleton(Registry::class, static function (Application $app): Registry { return new Registry( null, // event dispatcher (todo) $app->make(LoggerInterface::class) ); }); - $this->app->singleton(McpLoader::class, static function (Application $app) { + $this->app->singleton(McpLoader::class, static function (Application $app): McpLoader { return new McpLoader( $app->make(ResourceNameCollectionFactoryInterface::class), $app->make(ResourceMetadataCollectionFactoryInterface::class), @@ -1093,11 +1093,11 @@ private function registerMcp(): void $this->app->tag(McpLoader::class, 'mcp.loader'); // TODO: add more stores? - $this->app->singleton('mcp.session.store', static function () { + $this->app->singleton('mcp.session.store', static function (): InMemorySessionStore { return new InMemorySessionStore(3600); }); - $this->app->singleton(Builder::class, static function (Application $app) { + $this->app->singleton(Builder::class, static function (Application $app): Builder { $config = $app['config']; $builder = Server::builder() @@ -1105,8 +1105,7 @@ private function registerMcp(): void $config->get('api-platform.title', 'API Platform'), $config->get('api-platform.version', '1.0.0'), $config->get('api-platform.description', 'My awesome API'), - [], // icons - null // website_url todo + [] // website_url todo ) ->setPaginationLimit(100) ->setRegistry($app->make(Registry::class)) @@ -1125,21 +1124,21 @@ private function registerMcp(): void return $app->make(Builder::class)->build(); }); - $this->app->singleton(McpOperationMetadataFactory::class, static function (Application $app) { + $this->app->singleton(McpOperationMetadataFactory::class, static function (Application $app): McpOperationMetadataFactory { return new McpOperationMetadataFactory( $app->make(ResourceNameCollectionFactoryInterface::class), $app->make(ResourceMetadataCollectionFactoryInterface::class) ); }); - $this->app->singleton('api_platform.mcp.state_processor.write', static function (Application $app) { + $this->app->singleton('api_platform.mcp.state_processor.write', static function (Application $app): WriteProcessor { return new WriteProcessor( null, $app->make(CallableProcessor::class) ); }); - $this->app->singleton(StructuredContentProcessor::class, static function (Application $app) { + $this->app->singleton(StructuredContentProcessor::class, static function (Application $app): StructuredContentProcessor { return new StructuredContentProcessor( $app->make(SerializerInterface::class), $app->make(SerializerContextBuilderInterface::class), @@ -1147,11 +1146,11 @@ private function registerMcp(): void ); }); - $this->app->singleton(RequestStack::class, static function (Application $app) { + $this->app->singleton(RequestStack::class, static function (Application $app): RequestStack { return new RequestStack(); }); - $this->app->singleton(Handler::class, static function (Application $app) { + $this->app->singleton(Handler::class, static function (Application $app): Handler { return new Handler( $app->make(McpOperationMetadataFactory::class), $app->make(ProviderInterface::class), @@ -1161,12 +1160,12 @@ private function registerMcp(): void ); }); - $this->app->extend(IriConverterInterface::class, static function (IriConverterInterface $iriConverter) { + $this->app->extend(IriConverterInterface::class, static function (IriConverterInterface $iriConverter): McpIriConverter { return new McpIriConverter($iriConverter); }); // Register Symfony MCP controller - $this->app->singleton(McpController::class, static function (Application $app) { + $this->app->singleton(McpController::class, static function (Application $app): McpController { if (!class_exists('Http\Discovery\Psr17Factory')) { throw new \RuntimeException('PSR-17 HTTP factory implementation not available. Please install php-http/discovery.'); } @@ -1192,7 +1191,7 @@ private function registerMcp(): void private function registerGraphQl(): void { - $this->app->singleton(GraphQlItemNormalizer::class, static function (Application $app) { + $this->app->singleton(GraphQlItemNormalizer::class, static function (Application $app): GraphQlItemNormalizer { return new GraphQlItemNormalizer( $app->make(PropertyNameCollectionFactoryInterface::class), $app->make(PropertyMetadataFactoryInterface::class), @@ -1208,7 +1207,7 @@ private function registerGraphQl(): void ); }); - $this->app->singleton(GraphQlObjectNormalizer::class, static function (Application $app) { + $this->app->singleton(GraphQlObjectNormalizer::class, static function (Application $app): GraphQlObjectNormalizer { return new GraphQlObjectNormalizer( $app->make(ObjectNormalizer::class), $app->make(IriConverterInterface::class), @@ -1216,26 +1215,26 @@ private function registerGraphQl(): void ); }); - $this->app->singleton(GraphQlErrorNormalizer::class, static function () { + $this->app->singleton(GraphQlErrorNormalizer::class, static function (): GraphQlErrorNormalizer { return new GraphQlErrorNormalizer(); }); - $this->app->singleton(GraphQlValidationExceptionNormalizer::class, static function (Application $app) { + $this->app->singleton(GraphQlValidationExceptionNormalizer::class, static function (Application $app): GraphQlValidationExceptionNormalizer { /** @var ConfigRepository */ $config = $app['config']; return new GraphQlValidationExceptionNormalizer($config->get('api-platform.exception_to_status')); }); - $this->app->singleton(GraphQlHttpExceptionNormalizer::class, static function () { + $this->app->singleton(GraphQlHttpExceptionNormalizer::class, static function (): GraphQlHttpExceptionNormalizer { return new GraphQlHttpExceptionNormalizer(); }); - $this->app->singleton(GraphQlRuntimeExceptionNormalizer::class, static function () { + $this->app->singleton(GraphQlRuntimeExceptionNormalizer::class, static function (): GraphQlHttpExceptionNormalizer { return new GraphQlHttpExceptionNormalizer(); }); - $this->app->singleton('api_platform.graphql.type_locator', static function (Application $app) { + $this->app->singleton('api_platform.graphql.type_locator', static function (Application $app): ServiceLocator { $tagged = iterator_to_array($app->tagged('api_platform.graphql.type')); $services = []; foreach ($tagged as $service) { @@ -1245,21 +1244,21 @@ private function registerGraphQl(): void return new ServiceLocator($services); }); - $this->app->singleton(TypesFactoryInterface::class, static function (Application $app) { + $this->app->singleton(TypesFactoryInterface::class, static function (Application $app): TypesFactory { $tagged = iterator_to_array($app->tagged('api_platform.graphql.type')); return new TypesFactory($app->make('api_platform.graphql.type_locator'), array_column($tagged, 'name')); }); - $this->app->singleton(TypesContainerInterface::class, static function () { + $this->app->singleton(TypesContainerInterface::class, static function (): TypesContainer { return new TypesContainer(); }); - $this->app->singleton(ResourceFieldResolver::class, static function (Application $app) { + $this->app->singleton(ResourceFieldResolver::class, static function (Application $app): ResourceFieldResolver { return new ResourceFieldResolver($app->make(IriConverterInterface::class)); }); - $this->app->singleton(ContextAwareTypeBuilderInterface::class, static function (Application $app) { + $this->app->singleton(ContextAwareTypeBuilderInterface::class, static function (Application $app): TypeBuilder { return new TypeBuilder( $app->make(TypesContainerInterface::class), $app->make(ResourceFieldResolver::class), @@ -1268,7 +1267,7 @@ private function registerGraphQl(): void ); }); - $this->app->singleton(TypeConverterInterface::class, static function (Application $app) { + $this->app->singleton(TypeConverterInterface::class, static function (Application $app): TypeConverter { return new TypeConverter( $app->make(ContextAwareTypeBuilderInterface::class), $app->make(TypesContainerInterface::class), @@ -1277,11 +1276,11 @@ private function registerGraphQl(): void ); }); - $this->app->singleton(GraphQlSerializerContextBuilder::class, static function (Application $app) { + $this->app->singleton(GraphQlSerializerContextBuilder::class, static function (Application $app): GraphQlSerializerContextBuilder { return new GraphQlSerializerContextBuilder($app->make(NameConverterInterface::class)); }); - $this->app->singleton(GraphQlReadProvider::class, function (Application $app) { + $this->app->singleton(GraphQlReadProvider::class, function (Application $app): GraphQlReadProvider { /** @var ConfigRepository */ $config = $app['config']; @@ -1294,7 +1293,7 @@ private function registerGraphQl(): void }); $this->app->alias(GraphQlReadProvider::class, 'api_platform.graphql.state_provider.read'); - $this->app->singleton(ErrorProvider::class, static function (Application $app) { + $this->app->singleton(ErrorProvider::class, static function (Application $app): ErrorProvider { /** @var ConfigRepository */ $config = $app['config']; @@ -1305,7 +1304,7 @@ private function registerGraphQl(): void ); }); - $this->app->singleton(ResolverProvider::class, static function (Application $app) { + $this->app->singleton(ResolverProvider::class, static function (Application $app): ResolverProvider { $resolvers = iterator_to_array($app->tagged('api_platform.graphql.resolver')); $taggedItemResolvers = iterator_to_array($app->tagged(QueryItemResolverInterface::class)); $taggedCollectionResolvers = iterator_to_array($app->tagged(QueryCollectionResolverInterface::class)); @@ -1318,7 +1317,7 @@ private function registerGraphQl(): void $this->app->alias(ResolverProvider::class, 'api_platform.graphql.state_provider.resolver'); - $this->app->singleton(GraphQlDenormalizeProvider::class, function (Application $app) { + $this->app->singleton(GraphQlDenormalizeProvider::class, function (Application $app): GraphQlDenormalizeProvider { return new GraphQlDenormalizeProvider( $this->app->make(ResolverProvider::class), $app->make(SerializerInterface::class), @@ -1328,11 +1327,11 @@ private function registerGraphQl(): void $this->app->alias(GraphQlDenormalizeProvider::class, 'api_platform.graphql.state_provider.denormalize'); - $this->app->singleton('api_platform.graphql.state_provider.access_checker', static function (Application $app) { + $this->app->singleton('api_platform.graphql.state_provider.access_checker', static function (Application $app): AccessCheckerProvider { return new AccessCheckerProvider($app->make('api_platform.graphql.state_provider.parameter'), $app->make(ResourceAccessCheckerInterface::class)); }); - $this->app->singleton(NormalizeProcessor::class, static function (Application $app) { + $this->app->singleton(NormalizeProcessor::class, static function (Application $app): NormalizeProcessor { return new NormalizeProcessor( $app->make(SerializerInterface::class), $app->make(GraphQlSerializerContextBuilder::class), @@ -1341,14 +1340,14 @@ private function registerGraphQl(): void }); $this->app->alias(NormalizeProcessor::class, 'api_platform.graphql.state_processor.normalize'); - $this->app->singleton('api_platform.graphql.state_processor', static function (Application $app) { + $this->app->singleton('api_platform.graphql.state_processor', static function (Application $app): WriteProcessor { return new WriteProcessor( $app->make('api_platform.graphql.state_processor.normalize'), $app->make(CallableProcessor::class), ); }); - $this->app->singleton(ResolverFactoryInterface::class, static function (Application $app) { + $this->app->singleton(ResolverFactoryInterface::class, static function (Application $app): ResolverFactory { return new ResolverFactory( $app->make('api_platform.graphql.state_provider.access_checker'), $app->make('api_platform.graphql.state_processor'), @@ -1356,29 +1355,29 @@ private function registerGraphQl(): void ); }); - $this->app->singleton('api_platform.graphql.runtime_operation_metadata_factory', static function (Application $app) { + $this->app->singleton('api_platform.graphql.runtime_operation_metadata_factory', static function (Application $app): RuntimeOperationMetadataFactory { return new RuntimeOperationMetadataFactory( $app->make(ResourceMetadataCollectionFactoryInterface::class), $app->make(UrlGeneratorRouter::class) ); }); - $this->app->singleton(SchemaBuilderInterface::class, static function (Application $app) { + $this->app->singleton(SchemaBuilderInterface::class, static function (Application $app): SchemaBuilder { return new SchemaBuilder($app->make(ResourceNameCollectionFactoryInterface::class), $app->make(ResourceMetadataCollectionFactoryInterface::class), $app->make(TypesFactoryInterface::class), $app->make(TypesContainerInterface::class), $app->make(FieldsBuilderEnumInterface::class)); }); - $this->app->singleton(ErrorHandlerInterface::class, static function () { + $this->app->singleton(ErrorHandlerInterface::class, static function (): GraphQlErrorHandler { return new GraphQlErrorHandler(); }); - $this->app->singleton(ExecutorInterface::class, static function (Application $app) { + $this->app->singleton(ExecutorInterface::class, static function (Application $app): Executor { /** @var ConfigRepository */ $config = $app['config']; return new Executor($config->get('api-platform.graphql.introspection.enabled') ?? false, $config->get('api-platform.graphql.max_query_complexity') ?? 500, $config->get('api-platform.graphql.max_query_depth') ?? 200); }); - $this->app->singleton(GraphiQlController::class, static function (Application $app) { + $this->app->singleton(GraphiQlController::class, static function (Application $app): GraphiQlController { /** @var ConfigRepository */ $config = $app['config']; $prefix = $config->get('api-platform.defaults.route_prefix') ?? ''; @@ -1386,7 +1385,7 @@ private function registerGraphQl(): void return new GraphiQlController($prefix); }); - $this->app->singleton(GraphQlEntrypointController::class, static function (Application $app) { + $this->app->singleton(GraphQlEntrypointController::class, static function (Application $app): GraphQlEntrypointController { /** @var ConfigRepository */ $config = $app['config']; diff --git a/src/Laravel/Controller/DocumentationController.php b/src/Laravel/Controller/DocumentationController.php index 0b3b1809b74..15378c6a355 100644 --- a/src/Laravel/Controller/DocumentationController.php +++ b/src/Laravel/Controller/DocumentationController.php @@ -86,7 +86,7 @@ private function getOpenApiDocumentation(array $context, string $format, Request class: OpenApi::class, read: true, serialize: true, - provider: fn () => $this->openApiFactory->__invoke($context), + provider: fn (): OpenApi => $this->openApiFactory->__invoke($context), normalizationContext: [ ApiGatewayNormalizer::API_GATEWAY => $context['api_gateway'] ?? null, LegacyOpenApiNormalizer::SPEC_VERSION => $context['spec_version'] ?? null, @@ -114,7 +114,7 @@ private function getHydraDocumentation(array $context, Request $request): Respon class: Documentation::class, read: true, serialize: true, - provider: fn () => new Documentation($this->resourceNameCollectionFactory->create(), $this->title, $this->description, $this->version) + provider: fn (): Documentation => new Documentation($this->resourceNameCollectionFactory->create(), $this->title, $this->description, $this->version) ); return $this->processor->process($this->provider->provide($operation, [], $context), $operation, [], $context); diff --git a/src/Laravel/Eloquent/ApiPlatformEventProvider.php b/src/Laravel/Eloquent/ApiPlatformEventProvider.php index c9c7aa23d34..b086e3a53d1 100644 --- a/src/Laravel/Eloquent/ApiPlatformEventProvider.php +++ b/src/Laravel/Eloquent/ApiPlatformEventProvider.php @@ -40,7 +40,7 @@ public function register(): void return; } - $this->app->singleton('api_platform.http_cache.clients_array', static function (Application $app) { + $this->app->singleton('api_platform.http_cache.clients_array', static function (Application $app): array { $purgerUrls = Config::get('api-platform.http_cache.invalidation.urls', []); $requestOptions = Config::get('api-platform.http_cache.invalidation.request_options', []); @@ -54,11 +54,11 @@ public function register(): void $httpClients = static fn (Application $app) => $app->make('api_platform.http_cache.clients_array'); - $this->app->singleton(VarnishPurger::class, static function (Application $app) use ($httpClients) { + $this->app->singleton(VarnishPurger::class, static function (Application $app) use ($httpClients): VarnishPurger { return new VarnishPurger($httpClients($app)); }); - $this->app->singleton(VarnishXKeyPurger::class, static function (Application $app) use ($httpClients) { + $this->app->singleton(VarnishXKeyPurger::class, static function (Application $app) use ($httpClients): VarnishXKeyPurger { return new VarnishXKeyPurger( $httpClients($app), Config::get('api-platform.http_cache.invalidation.max_header_length', 7500), @@ -66,7 +66,7 @@ public function register(): void ); }); - $this->app->singleton(SouinPurger::class, static function (Application $app) use ($httpClients) { + $this->app->singleton(SouinPurger::class, static function (Application $app) use ($httpClients): SouinPurger { return new SouinPurger( $httpClients($app), Config::get('api-platform.http_cache.invalidation.max_header_length', 7500) @@ -86,7 +86,7 @@ public function register(): void return $app->make($purgerClass); }); - $this->app->singleton(PurgeHttpCacheListener::class, static function (Application $app) { + $this->app->singleton(PurgeHttpCacheListener::class, static function (Application $app): PurgeHttpCacheListener { return new PurgeHttpCacheListener( $app->make(PurgerInterface::class), $app->make(IriConverterInterface::class), diff --git a/src/Laravel/Eloquent/Filter/OrFilter.php b/src/Laravel/Eloquent/Filter/OrFilter.php index 609608cb929..91de0aa7dd3 100644 --- a/src/Laravel/Eloquent/Filter/OrFilter.php +++ b/src/Laravel/Eloquent/Filter/OrFilter.php @@ -32,7 +32,7 @@ public function __construct(private FilterInterface $filter) */ public function apply(Builder $builder, mixed $values, Parameter $parameter, array $context = []): Builder { - return $builder->where(function ($builder) use ($values, $parameter, $context): void { + return $builder->where(function (Builder $builder) use ($values, $parameter, $context): void { foreach ($values as $value) { $this->filter->apply($builder, $value, $parameter, ['whereClause' => 'orWhere'] + $context); } diff --git a/src/Laravel/Eloquent/Metadata/ModelMetadata.php b/src/Laravel/Eloquent/Metadata/ModelMetadata.php index a481de4b033..4c5b80ce4ce 100644 --- a/src/Laravel/Eloquent/Metadata/ModelMetadata.php +++ b/src/Laravel/Eloquent/Metadata/ModelMetadata.php @@ -29,12 +29,12 @@ final class ModelMetadata /** * @var array> */ - private $attributesLocalCache = []; + private array $attributesLocalCache = []; /** * @var array> */ - private $relationsLocalCache = []; + private array $relationsLocalCache = []; /** * The methods that can be called in a model to indicate a relation. @@ -348,7 +348,7 @@ public function getRelatedModelClass(string $modelClass, string $property): ?str private function columnIsUnique(string $column, array $indexes): bool { return collect($indexes)->contains( - static fn ($index) => 1 === \count($index['columns']) && $index['columns'][0] === $column && $index['unique'] + static fn ($index): bool => 1 === \count($index['columns']) && $index['columns'][0] === $column && $index['unique'] ); } } diff --git a/src/Laravel/Eloquent/State/RemoveProcessor.php b/src/Laravel/Eloquent/State/RemoveProcessor.php index a4a4583a01b..e0cf1c35172 100644 --- a/src/Laravel/Eloquent/State/RemoveProcessor.php +++ b/src/Laravel/Eloquent/State/RemoveProcessor.php @@ -21,7 +21,7 @@ */ final class RemoveProcessor implements ProcessorInterface { - public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []) + public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): null { $data->delete(); diff --git a/src/Laravel/Exception/ErrorHandler.php b/src/Laravel/Exception/ErrorHandler.php index 213ae49efb4..13246b7769a 100644 --- a/src/Laravel/Exception/ErrorHandler.php +++ b/src/Laravel/Exception/ErrorHandler.php @@ -169,9 +169,7 @@ public function render($request, \Throwable $exception) } try { - $response = $this->apiPlatformController->__invoke($dup); - - return $response; + return $this->apiPlatformController->__invoke($dup); } catch (\Throwable $e) { return $this->decorated ? $this->decorated->render($request, $exception) : parent::render($request, $exception); } diff --git a/src/Laravel/Metadata/CachePropertyMetadataFactory.php b/src/Laravel/Metadata/CachePropertyMetadataFactory.php index f3132a55d30..7e3711f4124 100644 --- a/src/Laravel/Metadata/CachePropertyMetadataFactory.php +++ b/src/Laravel/Metadata/CachePropertyMetadataFactory.php @@ -29,7 +29,7 @@ public function create(string $resourceClass, string $property, array $options = { $key = hash('xxh3', serialize(['resource_class' => $resourceClass, 'property' => $property] + $options)); - return Cache::store($this->cacheStore)->rememberForever($key, function () use ($resourceClass, $property, $options) { + return Cache::store($this->cacheStore)->rememberForever($key, function () use ($resourceClass, $property, $options): ApiProperty { return $this->decorated->create($resourceClass, $property, $options); }); } diff --git a/src/Laravel/Metadata/CachePropertyNameCollectionMetadataFactory.php b/src/Laravel/Metadata/CachePropertyNameCollectionMetadataFactory.php index 6269dd2080f..abc4c17f51c 100644 --- a/src/Laravel/Metadata/CachePropertyNameCollectionMetadataFactory.php +++ b/src/Laravel/Metadata/CachePropertyNameCollectionMetadataFactory.php @@ -29,7 +29,7 @@ public function create(string $resourceClass, array $options = []): PropertyName { $key = hash('xxh3', serialize(['resource_class' => $resourceClass] + $options)); - return Cache::store($this->cacheStore)->rememberForever($key, function () use ($resourceClass, $options) { + return Cache::store($this->cacheStore)->rememberForever($key, function () use ($resourceClass, $options): PropertyNameCollection { return $this->decorated->create($resourceClass, $options); }); } diff --git a/src/Laravel/Metadata/CacheResourceCollectionMetadataFactory.php b/src/Laravel/Metadata/CacheResourceCollectionMetadataFactory.php index 83836d9aae4..20816d72482 100644 --- a/src/Laravel/Metadata/CacheResourceCollectionMetadataFactory.php +++ b/src/Laravel/Metadata/CacheResourceCollectionMetadataFactory.php @@ -27,7 +27,7 @@ public function __construct( public function create(string $resourceClass): ResourceMetadataCollection { - return Cache::store($this->cacheStore)->rememberForever($resourceClass, function () use ($resourceClass) { + return Cache::store($this->cacheStore)->rememberForever($resourceClass, function () use ($resourceClass): ResourceMetadataCollection { return $this->decorated->create($resourceClass); }); } diff --git a/src/Laravel/Metadata/ParameterValidationResourceMetadataCollectionFactory.php b/src/Laravel/Metadata/ParameterValidationResourceMetadataCollectionFactory.php index e3741201582..98677e96a3d 100644 --- a/src/Laravel/Metadata/ParameterValidationResourceMetadataCollectionFactory.php +++ b/src/Laravel/Metadata/ParameterValidationResourceMetadataCollectionFactory.php @@ -18,13 +18,11 @@ use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use ApiPlatform\Metadata\Resource\ResourceMetadataCollection; use Illuminate\Validation\Rule; -use Psr\Container\ContainerInterface; final class ParameterValidationResourceMetadataCollectionFactory implements ResourceMetadataCollectionFactoryInterface { public function __construct( private readonly ?ResourceMetadataCollectionFactoryInterface $decorated = null, - private readonly ?ContainerInterface $filterLocator = null, ) { } diff --git a/src/Laravel/Tests/CustomExceptionHandlerTest.php b/src/Laravel/Tests/CustomExceptionHandlerTest.php index 1c9672fcabb..bad0e3fe5f1 100644 --- a/src/Laravel/Tests/CustomExceptionHandlerTest.php +++ b/src/Laravel/Tests/CustomExceptionHandlerTest.php @@ -75,15 +75,15 @@ protected function setUp(): void }); } - Route::get('/non-api-route', static function () { + Route::get('/non-api-route', static function (): void { throw new CustomTestException('This should be handled by custom handler'); }); - Route::get('/non-api-route-regular', static function () { + Route::get('/non-api-route-regular', static function (): void { throw new \RuntimeException('Regular exception on non-API route'); }); - Route::get('/non-api-custom-handler', static function () { + Route::get('/non-api-custom-handler', static function (): void { throw new CustomHandlerException('Should use custom handler class'); }); } @@ -129,7 +129,7 @@ public function testCustomHandlerClassWorksForNonApiRoutes(): void $this->setUpTraits(); CustomHandler::$customRenderCalled = false; - Route::get('/non-api-custom-handler-test', static function () { + Route::get('/non-api-custom-handler-test', static function (): void { throw new CustomHandlerException('Should use custom handler class'); }); diff --git a/src/Laravel/Tests/EloquentTest.php b/src/Laravel/Tests/EloquentTest.php index b0b67ff98d2..073b7fdf5d6 100644 --- a/src/Laravel/Tests/EloquentTest.php +++ b/src/Laravel/Tests/EloquentTest.php @@ -136,7 +136,7 @@ public function testDateFilterIncludeNull(): void $response = $this->get('/api/books', ['Accept' => ['application/ld+json']]); $book = $response->json()['member'][0]; - $updated = $this->patchJson( + $this->patchJson( $book['@id'], ['publicationDate' => null], [ @@ -155,7 +155,7 @@ public function testDateFilterExcludeNull(): void $response = $this->get('/api/books', ['Accept' => ['application/ld+json']]); $book = $response->json()['member'][0]; - $updated = $this->patchJson( + $this->patchJson( $book['@id'], ['publicationDate' => null], [ diff --git a/src/Laravel/Tests/GraphQlTest.php b/src/Laravel/Tests/GraphQlTest.php index 570dae5a6d6..923f776ad82 100644 --- a/src/Laravel/Tests/GraphQlTest.php +++ b/src/Laravel/Tests/GraphQlTest.php @@ -83,7 +83,7 @@ public function testGetBooksWithPaginationAndOrder(): void // Create books in reverse alphabetical order to test the 'asc' order BookFactory::new() ->count(10) - ->sequence(static fn ($sequence) => ['name' => \chr(max(0, min(255, 122 - (int) $sequence->index)))]) // ASCII codes starting from 'z' + ->sequence(static fn ($sequence): array => ['name' => \chr(max(0, min(255, 122 - (int) $sequence->index)))]) // ASCII codes starting from 'z' ->has(AuthorFactory::new()) ->create(); diff --git a/src/Laravel/Tests/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactoryTest.php b/src/Laravel/Tests/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactoryTest.php index f0a3d1a2f6f..3c0b6b5e62e 100644 --- a/src/Laravel/Tests/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactoryTest.php +++ b/src/Laravel/Tests/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactoryTest.php @@ -37,7 +37,7 @@ public function testNestedPropertyWithEloquentRelationship(): void $propertyMetadata = $this->createStub(PropertyMetadataFactoryInterface::class); $propertyMetadata->method('create')->willReturnCallback( - static function (string $class, string $property) { + static function (string $class, string $property): ApiProperty { return new ApiProperty(readable: true); } ); diff --git a/src/Laravel/Tests/NestedPropertyFilterTest.php b/src/Laravel/Tests/NestedPropertyFilterTest.php index 2b2da5c056a..bb89d0b674f 100644 --- a/src/Laravel/Tests/NestedPropertyFilterTest.php +++ b/src/Laravel/Tests/NestedPropertyFilterTest.php @@ -36,7 +36,7 @@ class NestedPropertyFilterTest extends TestCase protected function defineEnvironment($app): void { tap($app['config'], static function (Repository $config): void { - $config->set('api-platform.name_converter', null); + $config->set('api-platform.name_converter'); $config->set('api-platform.formats', ['jsonld' => ['application/ld+json']]); }); } @@ -77,14 +77,14 @@ public function testFilterByDeeplyNestedPropertyWithSnakeCase(): void $product1 = Product::create(['name' => 'Laptop', 'price' => 999.99]); $product2 = Product::create(['name' => 'Keyboard', 'price' => 79.99]); - $variation1 = ProductVariation::create([ + ProductVariation::create([ 'product_id' => $product1->id, 'variant_name' => 'Gaming Edition', 'sku_code' => 'LAP-GAMING-001', 'price_adjustment' => 200.00, ]); - $variation2 = ProductVariation::create([ + ProductVariation::create([ 'product_id' => $product2->id, 'variant_name' => 'Mechanical Blue', 'sku_code' => 'KEY-MECH-BLUE', diff --git a/src/Laravel/Tests/NumericFloatTypesTest.php b/src/Laravel/Tests/NumericFloatTypesTest.php index 7724acf51ee..1ea12b6dba3 100644 --- a/src/Laravel/Tests/NumericFloatTypesTest.php +++ b/src/Laravel/Tests/NumericFloatTypesTest.php @@ -37,7 +37,7 @@ class NumericFloatTypesTest extends TestCase protected function defineEnvironment($app): void { tap($app['config'], static function (Repository $config): void { - $config->set('api-platform.name_converter', null); + $config->set('api-platform.name_converter'); $config->set('api-platform.formats', ['jsonld' => ['application/ld+json']]); $config->set('api-platform.docs_formats', ['jsonld' => ['application/ld+json']]); }); diff --git a/src/Laravel/Tests/Policy/PolicyAllowTest.php b/src/Laravel/Tests/Policy/PolicyAllowTest.php index e739d7d85c7..655a914dab2 100644 --- a/src/Laravel/Tests/Policy/PolicyAllowTest.php +++ b/src/Laravel/Tests/Policy/PolicyAllowTest.php @@ -36,7 +36,7 @@ class PolicyAllowTest extends TestCase */ protected function defineEnvironment($app): void { - Gate::guessPolicyNamesUsing(static function (string $modelClass) { + Gate::guessPolicyNamesUsing(static function (string $modelClass): ?string { return Book::class === $modelClass ? BookAllowPolicy::class : null; diff --git a/src/Laravel/Tests/Policy/PolicyDenyTest.php b/src/Laravel/Tests/Policy/PolicyDenyTest.php index c198eb7a442..3643381601f 100644 --- a/src/Laravel/Tests/Policy/PolicyDenyTest.php +++ b/src/Laravel/Tests/Policy/PolicyDenyTest.php @@ -36,7 +36,7 @@ class PolicyDenyTest extends TestCase */ protected function defineEnvironment($app): void { - Gate::guessPolicyNamesUsing(static function (string $modelClass) { + Gate::guessPolicyNamesUsing(static function (string $modelClass): ?string { return Book::class === $modelClass ? BookDenyPolicy::class : null; diff --git a/src/Laravel/Tests/SnakeCaseApiTest.php b/src/Laravel/Tests/SnakeCaseApiTest.php index e375b5752da..916b6bd81cf 100644 --- a/src/Laravel/Tests/SnakeCaseApiTest.php +++ b/src/Laravel/Tests/SnakeCaseApiTest.php @@ -31,7 +31,7 @@ class SnakeCaseApiTest extends TestCase protected function defineEnvironment($app): void { tap($app['config'], static function (Repository $config): void { - $config->set('api-platform.name_converter', null); + $config->set('api-platform.name_converter'); $config->set('api-platform.formats', ['jsonld' => ['application/ld+json']]); $config->set('api-platform.docs_formats', ['jsonld' => ['application/ld+json']]); }); diff --git a/src/Laravel/workbench/app/ApiResource/Issue7338Reproducer.php b/src/Laravel/workbench/app/ApiResource/Issue7338Reproducer.php index 2c0367173cb..c3ab2960033 100644 --- a/src/Laravel/workbench/app/ApiResource/Issue7338Reproducer.php +++ b/src/Laravel/workbench/app/ApiResource/Issue7338Reproducer.php @@ -39,15 +39,14 @@ class Issue7338Reproducer { public function __construct(public ?int $id = null, public ?string $title = null) { - $this->id = $id; } - public static function provide(Operation $operation, array $uriVariables = [], array $context = []) + public static function provide(Operation $operation, array $uriVariables = [], array $context = []): Issue7338Output { return new Issue7338Output((int) $uriVariables['id'], 'Test Name', new \DateTimeImmutable()); } - public static function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []) + public static function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): self { \assert(null === $data->description); diff --git a/src/Laravel/workbench/app/ApiResource/SlotsForDate.php b/src/Laravel/workbench/app/ApiResource/SlotsForDate.php index 6b32f2ea8c1..718058eac90 100644 --- a/src/Laravel/workbench/app/ApiResource/SlotsForDate.php +++ b/src/Laravel/workbench/app/ApiResource/SlotsForDate.php @@ -33,7 +33,7 @@ class SlotsForDate public string $name = 'Morning Slot'; public string $note = 'This is a morning slot'; - public static function provide() + public static function provide(): array { return []; } diff --git a/src/Laravel/workbench/app/ApiResource/Staff.php b/src/Laravel/workbench/app/ApiResource/Staff.php index 5376f1863da..a7191025018 100644 --- a/src/Laravel/workbench/app/ApiResource/Staff.php +++ b/src/Laravel/workbench/app/ApiResource/Staff.php @@ -18,7 +18,7 @@ #[ApiResource(provider: [self::class, 'provide'])] class Staff { - public static function provide() + public static function provide(): array { return []; } diff --git a/src/Laravel/workbench/app/ApiResource/StaffPositionHistory.php b/src/Laravel/workbench/app/ApiResource/StaffPositionHistory.php index df0f243a253..b4b091bc38f 100644 --- a/src/Laravel/workbench/app/ApiResource/StaffPositionHistory.php +++ b/src/Laravel/workbench/app/ApiResource/StaffPositionHistory.php @@ -18,7 +18,7 @@ #[ApiResource(provider: [self::class, 'provide'])] class StaffPositionHistory { - public static function provide() + public static function provide(): array { return []; } diff --git a/src/Laravel/workbench/app/Http/Requests/GetDropOffSlotsRequest.php b/src/Laravel/workbench/app/Http/Requests/GetDropOffSlotsRequest.php index 696e9f07783..4e4ddc56e92 100644 --- a/src/Laravel/workbench/app/Http/Requests/GetDropOffSlotsRequest.php +++ b/src/Laravel/workbench/app/Http/Requests/GetDropOffSlotsRequest.php @@ -51,7 +51,7 @@ public function rules(): array protected function failedValidation(Validator $validator): void { $violations = collect($validator->errors()) - ->map(static fn ($m, $f) => ['propertyPath' => $f, 'message' => $m[0]]) // ** @phpstan-ignore-line */ + ->map(static fn ($m, $f): array => ['propertyPath' => $f, 'message' => $m[0]]) // ** @phpstan-ignore-line */ ->values()->all(); throw new \ApiPlatform\Laravel\ApiResource\ValidationError($violations[0]['message'] ?? 'Validation failed.', hash('xxh3', implode(',', array_column($violations, 'propertyPath'))), new \Illuminate\Validation\ValidationException($validator), $violations); diff --git a/src/Laravel/workbench/app/Models/GrandFather.php b/src/Laravel/workbench/app/Models/GrandFather.php index d163bc8f5d8..8aa89bc8aa6 100644 --- a/src/Laravel/workbench/app/Models/GrandFather.php +++ b/src/Laravel/workbench/app/Models/GrandFather.php @@ -17,7 +17,6 @@ use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\Link; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; @@ -43,10 +42,6 @@ class GrandFather extends Model #[ApiProperty(genId: false, identifier: true)] private ?int $id_grand_father; - private ?string $name = null; - - private ?Collection $sons = null; - public function sons(): HasMany { return $this->hasMany(GrandSon::class, 'grand_father_id', 'id_grand_father'); diff --git a/src/Laravel/workbench/app/Models/GrandSon.php b/src/Laravel/workbench/app/Models/GrandSon.php index 9eb22eefa34..aa2472e262e 100644 --- a/src/Laravel/workbench/app/Models/GrandSon.php +++ b/src/Laravel/workbench/app/Models/GrandSon.php @@ -42,10 +42,6 @@ class GrandSon extends Model #[ApiProperty(genId: false, identifier: true)] private ?int $id_grand_son; - private ?string $name = null; - - private ?GrandFather $grandfather = null; - public function grandfather(): BelongsTo { return $this->belongsTo(GrandFather::class, 'grand_father_id', 'id_grand_father'); diff --git a/src/Laravel/workbench/app/Models/WithAccessor.php b/src/Laravel/workbench/app/Models/WithAccessor.php index 2e992105187..7b2b3015ae8 100644 --- a/src/Laravel/workbench/app/Models/WithAccessor.php +++ b/src/Laravel/workbench/app/Models/WithAccessor.php @@ -38,7 +38,7 @@ public function relation(): BelongsTo protected function name(): Attribute { return Attribute::make( - get: static fn (string $value) => 'test', + get: static fn (string $value): string => 'test', ); } } diff --git a/src/Laravel/workbench/app/Providers/WorkbenchServiceProvider.php b/src/Laravel/workbench/app/Providers/WorkbenchServiceProvider.php index 9abdc0eb627..c6feb70e4d0 100644 --- a/src/Laravel/workbench/app/Providers/WorkbenchServiceProvider.php +++ b/src/Laravel/workbench/app/Providers/WorkbenchServiceProvider.php @@ -39,10 +39,10 @@ public function register(): void $config->set('api-platform.http_cache.invalidation.purger', MockPurger::class); $config->set('cache.default', 'null'); - $this->app->singleton(MockPurger::class, static fn ($app) => new MockPurger()); - $this->app->singleton(DummyService::class, static fn ($app) => new DummyService($app['config']->get('api-platform.title'))); - $this->app->singleton(CustomProviderWithDependency::class, static fn ($app) => new CustomProviderWithDependency($app->make(DummyService::class))); - $this->app->singleton('app.exact_filter', static fn ($app) => new EqualsFilter()); + $this->app->singleton(MockPurger::class, static fn ($app): MockPurger => new MockPurger()); + $this->app->singleton(DummyService::class, static fn ($app): DummyService => new DummyService($app['config']->get('api-platform.title'))); + $this->app->singleton(CustomProviderWithDependency::class, static fn ($app): CustomProviderWithDependency => new CustomProviderWithDependency($app->make(DummyService::class))); + $this->app->singleton('app.exact_filter', static fn ($app): EqualsFilter => new EqualsFilter()); } /** diff --git a/src/Laravel/workbench/app/Services/DummyService.php b/src/Laravel/workbench/app/Services/DummyService.php index 6f59be5c503..ead02332af9 100644 --- a/src/Laravel/workbench/app/Services/DummyService.php +++ b/src/Laravel/workbench/app/Services/DummyService.php @@ -15,10 +15,6 @@ class DummyService { - public function __construct(private readonly string $var) - { - } - public function dummyMethod(): string { return 'test'; diff --git a/src/Laravel/workbench/database/factories/UserFactory.php b/src/Laravel/workbench/database/factories/UserFactory.php index 6838a98d8b0..772393b7297 100644 --- a/src/Laravel/workbench/database/factories/UserFactory.php +++ b/src/Laravel/workbench/database/factories/UserFactory.php @@ -58,7 +58,7 @@ public function definition(): array */ public function unverified(): static { - return $this->state(static fn (array $attributes) => [ + return $this->state(static fn (array $attributes): array => [ 'email_verified_at' => null, ]); } diff --git a/src/Laravel/workbench/routes/web.php b/src/Laravel/workbench/routes/web.php index 76c005280b4..251cd95b81d 100644 --- a/src/Laravel/workbench/routes/web.php +++ b/src/Laravel/workbench/routes/web.php @@ -14,7 +14,7 @@ use Illuminate\Http\Request; use Workbench\App\Models\User; -Route::post('/tokens/create', static function (Request $request) { +Route::post('/tokens/create', static function (Request $request): array { $user = User::first(); $token = $user->createToken('foo'); diff --git a/src/Mcp/State/StructuredContentProcessor.php b/src/Mcp/State/StructuredContentProcessor.php index b4fac25d2fa..02ea34e4e31 100644 --- a/src/Mcp/State/StructuredContentProcessor.php +++ b/src/Mcp/State/StructuredContentProcessor.php @@ -57,7 +57,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables = $context['original_data'] = $result; $class = $operation->getClass(); - $includeStructuredContent = $operation instanceof McpTool || $operation instanceof McpResource ? $operation->getStructuredContent() ?? true : false; + $includeStructuredContent = ($operation instanceof McpTool || $operation instanceof McpResource) && ($operation->getStructuredContent() ?? true); $structuredContent = null; if ($includeStructuredContent) { diff --git a/src/Mcp/State/ToolProvider.php b/src/Mcp/State/ToolProvider.php index dff2e8874eb..ecfe503f188 100644 --- a/src/Mcp/State/ToolProvider.php +++ b/src/Mcp/State/ToolProvider.php @@ -28,7 +28,7 @@ public function __construct(private readonly ObjectMapperInterface $objectMapper { } - public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null + public function provide(Operation $operation, array $uriVariables = [], array $context = []): ?object { if (!isset($context['mcp_request'])) { return null; diff --git a/src/Metadata/ApiProperty.php b/src/Metadata/ApiProperty.php index 28c6d09870d..40082766f01 100644 --- a/src/Metadata/ApiProperty.php +++ b/src/Metadata/ApiProperty.php @@ -376,10 +376,7 @@ public function getDeprecationReason(): ?string return $this->deprecationReason; } - /** - * @param string $deprecationReason - */ - public function withDeprecationReason($deprecationReason): static + public function withDeprecationReason(?string $deprecationReason): static { $self = clone $this; $self->deprecationReason = $deprecationReason; @@ -392,10 +389,7 @@ public function isFetchable(): ?bool return $this->fetchable; } - /** - * @param bool $fetchable - */ - public function withFetchable($fetchable): static + public function withFetchable(?bool $fetchable): static { $self = clone $this; $self->fetchable = $fetchable; @@ -408,10 +402,7 @@ public function getFetchEager(): ?bool return $this->fetchEager; } - /** - * @param bool $fetchEager - */ - public function withFetchEager($fetchEager): static + public function withFetchEager(?bool $fetchEager): static { $self = clone $this; $self->fetchEager = $fetchEager; @@ -424,10 +415,7 @@ public function getJsonldContext(): ?array return $this->jsonldContext; } - /** - * @param array $jsonldContext - */ - public function withJsonldContext($jsonldContext): static + public function withJsonldContext(?array $jsonldContext): static { $self = clone $this; $self->jsonldContext = $jsonldContext; @@ -440,10 +428,7 @@ public function getOpenapiContext(): ?array return $this->openapiContext; } - /** - * @param array $openapiContext - */ - public function withOpenapiContext($openapiContext): static + public function withOpenapiContext(?array $openapiContext): static { $self = clone $this; $self->openapiContext = $openapiContext; @@ -456,10 +441,7 @@ public function getJsonSchemaContext(): ?array return $this->jsonSchemaContext; } - /** - * @param array $jsonSchemaContext - */ - public function withJsonSchemaContext($jsonSchemaContext): static + public function withJsonSchemaContext(?array $jsonSchemaContext): static { $self = clone $this; $self->jsonSchemaContext = $jsonSchemaContext; @@ -472,10 +454,7 @@ public function getPush(): ?bool return $this->push; } - /** - * @param bool $push - */ - public function withPush($push): static + public function withPush(?bool $push): static { $self = clone $this; $self->push = $push; diff --git a/src/Metadata/ApiResource.php b/src/Metadata/ApiResource.php index eabfdda8fc0..e1cc959b8d5 100644 --- a/src/Metadata/ApiResource.php +++ b/src/Metadata/ApiResource.php @@ -1099,10 +1099,7 @@ public function withTypes(array|string $types): static return $self; } - /** - * @return array|mixed|string|null - */ - public function getFormats() + public function getFormats(): string|array|null { return $this->formats; } @@ -1115,18 +1112,12 @@ public function withFormats(mixed $formats): static return $self; } - /** - * @return array|mixed|string|null - */ - public function getInputFormats() + public function getInputFormats(): string|array|null { return $this->inputFormats; } - /** - * @param mixed|null $inputFormats - */ - public function withInputFormats($inputFormats): static + public function withInputFormats(string|array|null $inputFormats): static { $self = clone $this; $self->inputFormats = $inputFormats; @@ -1134,18 +1125,12 @@ public function withInputFormats($inputFormats): static return $self; } - /** - * @return array|mixed|string|null - */ - public function getOutputFormats() + public function getOutputFormats(): string|array|null { return $this->outputFormats; } - /** - * @param mixed|null $outputFormats - */ - public function withOutputFormats($outputFormats): static + public function withOutputFormats(string|array|null $outputFormats): static { $self = clone $this; $self->outputFormats = $outputFormats; @@ -1268,10 +1253,7 @@ public function getStatus(): ?int return $this->status; } - /** - * @param int $status - */ - public function withStatus($status): static + public function withStatus(?int $status): static { $self = clone $this; $self->status = $status; diff --git a/src/Metadata/Delete.php b/src/Metadata/Delete.php index 5f459c0e35e..5ae0e2f091d 100644 --- a/src/Metadata/Delete.php +++ b/src/Metadata/Delete.php @@ -23,7 +23,7 @@ final class Delete extends HttpOperation implements DeleteOperationInterface public function __construct( ?string $uriTemplate = null, ?array $types = null, - $formats = null, + array|string|null $formats = null, $inputFormats = null, $outputFormats = null, $uriVariables = null, @@ -35,7 +35,7 @@ public function __construct( ?bool $stateless = null, ?string $sunset = null, ?string $acceptPatch = null, - $status = null, + string|int|null $status = null, ?string $host = null, ?array $schemes = null, ?string $condition = null, @@ -76,8 +76,8 @@ public function __construct( ?string $deprecationReason = null, ?array $filters = null, ?array $validationContext = null, - $input = null, - $output = null, + ?string $input = null, + string|bool|null $output = null, $mercure = null, $messenger = null, ?int $urlGenerationStrategy = null, @@ -90,8 +90,8 @@ public function __construct( ?bool $forceEager = null, ?int $priority = null, ?string $name = null, - $provider = null, - $processor = null, + array|string|callable|int|null $provider = null, + array|string|callable|int|null $processor = null, ?OptionsInterface $stateOptions = null, array|Parameters|null $parameters = null, mixed $rules = null, diff --git a/src/Metadata/Error.php b/src/Metadata/Error.php index abeb8ed7a58..1baf4024d5b 100644 --- a/src/Metadata/Error.php +++ b/src/Metadata/Error.php @@ -23,7 +23,7 @@ final class Error extends HttpOperation public function __construct( ?string $uriTemplate = null, ?array $types = null, - $formats = null, + array|string|null $formats = null, $inputFormats = null, $outputFormats = null, $uriVariables = null, @@ -35,7 +35,7 @@ public function __construct( ?bool $stateless = null, ?string $sunset = null, ?string $acceptPatch = null, - $status = null, + string|int|null $status = null, ?string $host = null, ?array $schemes = null, ?string $condition = null, @@ -76,8 +76,8 @@ public function __construct( ?string $deprecationReason = null, ?array $filters = null, ?array $validationContext = null, - $input = null, - $output = null, + ?string $input = null, + string|bool|null $output = null, $mercure = null, $messenger = null, ?int $urlGenerationStrategy = null, @@ -90,8 +90,8 @@ public function __construct( ?bool $forceEager = null, ?int $priority = null, ?string $name = null, - $provider = null, - $processor = null, + array|string|callable|int|null $provider = null, + array|string|callable|int|null $processor = null, ?OptionsInterface $stateOptions = null, ?bool $hideHydraOperation = null, ?bool $jsonStream = null, diff --git a/src/Metadata/ErrorResource.php b/src/Metadata/ErrorResource.php index 8f1586ac038..268362af32d 100644 --- a/src/Metadata/ErrorResource.php +++ b/src/Metadata/ErrorResource.php @@ -36,7 +36,7 @@ public function __construct( ?bool $stateless = null, ?string $sunset = null, ?string $acceptPatch = null, - ?int $status = null, + string|int|null $status = null, ?string $host = null, ?array $schemes = null, ?string $condition = null, @@ -52,7 +52,7 @@ public function __construct( OpenApiOperation|bool|null $openapi = null, ?array $validationContext = null, ?array $filters = null, - $mercure = null, + ?array $mercure = null, $messenger = null, $input = null, $output = null, @@ -80,8 +80,8 @@ public function __construct( ?array $exceptionToStatus = null, ?bool $queryParameterValidationEnabled = null, ?array $graphQlOperations = null, - $provider = null, - $processor = null, + array|string|callable|int|null $provider = null, + array|string|callable|int|null $processor = null, ?OptionsInterface $stateOptions = null, ?bool $jsonStream = null, array $extraProperties = [], diff --git a/src/Metadata/Extractor/AbstractPropertyExtractor.php b/src/Metadata/Extractor/AbstractPropertyExtractor.php index 2f011bf64d9..cfe68edde80 100644 --- a/src/Metadata/Extractor/AbstractPropertyExtractor.php +++ b/src/Metadata/Extractor/AbstractPropertyExtractor.php @@ -87,7 +87,7 @@ protected function resolve(mixed $value): mixed return $value; } - $escapedValue = preg_replace_callback('/%%|%([^%\s]++)%/', function ($match) use ($value) { + $escapedValue = preg_replace_callback('/%%|%([^%\s]++)%/', function (array $match) use ($value) { $parameter = $match[1] ?? null; // skip %% diff --git a/src/Metadata/Extractor/AbstractResourceExtractor.php b/src/Metadata/Extractor/AbstractResourceExtractor.php index d9bd3eac43d..bea227304db 100644 --- a/src/Metadata/Extractor/AbstractResourceExtractor.php +++ b/src/Metadata/Extractor/AbstractResourceExtractor.php @@ -87,7 +87,7 @@ protected function resolve(mixed $value): mixed return $value; } - $escapedValue = preg_replace_callback('/%%|%([^%\s]++)%/', function ($match) use ($value) { + $escapedValue = preg_replace_callback('/%%|%([^%\s]++)%/', function (array $match) use ($value) { $parameter = $match[1] ?? null; // skip %% diff --git a/src/Metadata/Extractor/XmlResourceExtractor.php b/src/Metadata/Extractor/XmlResourceExtractor.php index b726ac03e68..703a9e8c85d 100644 --- a/src/Metadata/Extractor/XmlResourceExtractor.php +++ b/src/Metadata/Extractor/XmlResourceExtractor.php @@ -228,11 +228,11 @@ private function buildOpenapi(\SimpleXMLElement $resource): bool|OpenApiOperatio description: $this->phpize($parameter, 'description', 'string'), required: $this->phpize($parameter, 'required', 'bool'), deprecated: $this->phpize($parameter, 'deprecated', 'bool', false), - allowEmptyValue: $this->phpize($parameter, 'allowEmptyValue', 'bool', null), + allowEmptyValue: $this->phpize($parameter, 'allowEmptyValue', 'bool'), schema: isset($parameter->schema->values) ? $this->buildValues($parameter->schema->values) : [], style: $this->phpize($parameter, 'style', 'string'), explode: $this->phpize($parameter, 'explode', 'bool', false), - allowReserved: $this->phpize($parameter, 'allowReserved', 'bool', null), + allowReserved: $this->phpize($parameter, 'allowReserved', 'bool'), example: $this->phpize($parameter, 'example', 'string'), examples: isset($parameter->examples->values) ? new \ArrayObject($this->buildValues($parameter->examples->values)) : null, content: isset($parameter->content->values) ? new \ArrayObject($this->buildValues($parameter->content->values)) : null, diff --git a/src/Metadata/Extractor/YamlResourceExtractor.php b/src/Metadata/Extractor/YamlResourceExtractor.php index e7dd40093c8..f9d0044381c 100644 --- a/src/Metadata/Extractor/YamlResourceExtractor.php +++ b/src/Metadata/Extractor/YamlResourceExtractor.php @@ -339,7 +339,7 @@ private function buildOperations(array $resource, array $root): ?array } } - if (\in_array((string) $class, [GetCollection::class, Post::class], true)) { + if (\in_array($class, [GetCollection::class, Post::class], true)) { $datum['itemUriTemplate'] = $this->phpize($operation, 'itemUriTemplate', 'string'); } elseif (isset($operation['itemUriTemplate'])) { throw new InvalidArgumentException(\sprintf('"itemUriTemplate" option is not allowed on a %s operation.', $class)); @@ -356,7 +356,7 @@ private function buildOperations(array $resource, array $root): ?array 'hideHydraOperation' => $this->phpize($resource, 'hideHydraOperation', 'bool'), 'priority' => $this->phpize($operation, 'priority', 'integer'), 'name' => $this->phpize($operation, 'name', 'string'), - 'class' => (string) $class, + 'class' => $class, ]); } @@ -401,7 +401,7 @@ private function buildGraphQlOperations(array $resource, array $root): ?array 'resolver' => $this->phpize($operation, 'resolver', 'string'), 'args' => $operation['args'] ?? null, 'extraArgs' => $operation['extraArgs'] ?? null, - 'class' => (string) $class, + 'class' => $class, 'read' => $this->phpize($operation, 'read', 'bool'), 'deserialize' => $this->phpize($operation, 'deserialize', 'bool'), 'validate' => $this->phpize($operation, 'validate', 'bool'), diff --git a/src/Metadata/Get.php b/src/Metadata/Get.php index 0139b825611..3bd641f61f6 100644 --- a/src/Metadata/Get.php +++ b/src/Metadata/Get.php @@ -23,7 +23,7 @@ final class Get extends HttpOperation public function __construct( ?string $uriTemplate = null, ?array $types = null, - $formats = null, + array|string|null $formats = null, $inputFormats = null, $outputFormats = null, $uriVariables = null, @@ -35,7 +35,7 @@ public function __construct( ?bool $stateless = null, ?string $sunset = null, ?string $acceptPatch = null, - $status = null, + string|int|null $status = null, ?string $host = null, ?array $schemes = null, ?string $condition = null, @@ -76,8 +76,8 @@ public function __construct( ?string $deprecationReason = null, ?array $filters = null, ?array $validationContext = null, - $input = null, - $output = null, + ?string $input = null, + string|bool|null $output = null, $mercure = null, $messenger = null, ?int $urlGenerationStrategy = null, @@ -90,8 +90,8 @@ public function __construct( ?bool $forceEager = null, ?int $priority = null, ?string $name = null, - $provider = null, - $processor = null, + array|string|callable|int|null $provider = null, + array|string|callable|int|null $processor = null, ?OptionsInterface $stateOptions = null, array|Parameters|null $parameters = null, mixed $rules = null, diff --git a/src/Metadata/GetCollection.php b/src/Metadata/GetCollection.php index 74886491a23..5171d1a3b14 100644 --- a/src/Metadata/GetCollection.php +++ b/src/Metadata/GetCollection.php @@ -23,7 +23,7 @@ final class GetCollection extends HttpOperation implements CollectionOperationIn public function __construct( ?string $uriTemplate = null, ?array $types = null, - $formats = null, + array|string|null $formats = null, $inputFormats = null, $outputFormats = null, $uriVariables = null, @@ -35,7 +35,7 @@ public function __construct( ?bool $stateless = null, ?string $sunset = null, ?string $acceptPatch = null, - $status = null, + string|int|null $status = null, ?string $host = null, ?array $schemes = null, ?string $condition = null, @@ -76,8 +76,8 @@ public function __construct( ?string $deprecationReason = null, ?array $filters = null, ?array $validationContext = null, - $input = null, - $output = null, + ?string $input = null, + string|bool|null $output = null, $mercure = null, $messenger = null, ?int $urlGenerationStrategy = null, @@ -90,8 +90,8 @@ public function __construct( ?bool $forceEager = null, ?int $priority = null, ?string $name = null, - $provider = null, - $processor = null, + array|string|callable|int|null $provider = null, + array|string|callable|int|null $processor = null, ?OptionsInterface $stateOptions = null, array|Parameters|null $parameters = null, array|string|null $rules = null, diff --git a/src/Metadata/GraphQl/Operation.php b/src/Metadata/GraphQl/Operation.php index 2dbbaa4fddf..62e95353016 100644 --- a/src/Metadata/GraphQl/Operation.php +++ b/src/Metadata/GraphQl/Operation.php @@ -21,18 +21,12 @@ class Operation extends AbstractOperation { /** - * @param Link[]|null $links - * @param array{ - * class?: string|null, - * name?: string, - * }|string|false|null $input {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation} - * @param array{ - * class?: string|null, - * name?: string, - * }|string|false|null $output {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation} + * @param Link[]|null $links + * @param string|null $input {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation} + * @param string|null $output {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation} * @param string|array|bool|null $mercure {@see https://api-platform.com/docs/core/mercure} * @param string|bool|null $messenger {@see https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus} - * @param string|callable|null $provider {@see https://api-platform.com/docs/core/state-providers/#state-providers} + * @param string|null $provider {@see https://api-platform.com/docs/core/state-providers/#state-providers} * @param string|callable|null $processor {@see https://api-platform.com/docs/core/state-processors/#state-processors} */ public function __construct( @@ -70,7 +64,7 @@ public function __construct( ?string $deprecationReason = null, ?array $filters = null, ?array $validationContext = null, - $input = null, + ?string $input = null, $output = null, $mercure = null, $messenger = null, @@ -84,7 +78,7 @@ public function __construct( ?bool $forceEager = null, ?int $priority = null, ?string $name = null, - $provider = null, + ?string $provider = null, $processor = null, ?OptionsInterface $stateOptions = null, array|Parameters|null $parameters = null, diff --git a/src/Metadata/GraphQl/Query.php b/src/Metadata/GraphQl/Query.php index b877afa5e57..e63fb76c315 100644 --- a/src/Metadata/GraphQl/Query.php +++ b/src/Metadata/GraphQl/Query.php @@ -53,8 +53,8 @@ public function __construct( ?string $deprecationReason = null, ?array $filters = null, ?array $validationContext = null, - $input = null, - $output = null, + ?string $input = null, + ?string $output = null, $mercure = null, $messenger = null, ?int $urlGenerationStrategy = null, @@ -67,8 +67,8 @@ public function __construct( ?bool $forceEager = null, ?int $priority = null, ?string $name = null, - $provider = null, - $processor = null, + ?string $provider = null, + ?string $processor = null, ?OptionsInterface $stateOptions = null, array|Parameters|null $parameters = null, ?bool $queryParameterValidationEnabled = null, diff --git a/src/Metadata/GraphQl/QueryCollection.php b/src/Metadata/GraphQl/QueryCollection.php index 2054b519cfe..78e45d0213f 100644 --- a/src/Metadata/GraphQl/QueryCollection.php +++ b/src/Metadata/GraphQl/QueryCollection.php @@ -54,8 +54,8 @@ public function __construct( ?string $deprecationReason = null, ?array $filters = null, ?array $validationContext = null, - $input = null, - $output = null, + ?string $input = null, + ?string $output = null, $mercure = null, $messenger = null, ?int $urlGenerationStrategy = null, @@ -68,8 +68,8 @@ public function __construct( ?bool $forceEager = null, ?int $priority = null, ?string $name = null, - $provider = null, - $processor = null, + ?string $provider = null, + ?string $processor = null, protected ?OptionsInterface $stateOptions = null, array|Parameters|null $parameters = null, ?bool $queryParameterValidationEnabled = null, diff --git a/src/Metadata/GraphQl/Subscription.php b/src/Metadata/GraphQl/Subscription.php index dbd54aff922..9964b50c5bd 100644 --- a/src/Metadata/GraphQl/Subscription.php +++ b/src/Metadata/GraphQl/Subscription.php @@ -53,8 +53,8 @@ public function __construct( ?string $deprecationReason = null, ?array $filters = null, ?array $validationContext = null, - $input = null, - $output = null, + ?string $input = null, + ?string $output = null, $mercure = null, $messenger = null, ?int $urlGenerationStrategy = null, @@ -67,8 +67,8 @@ public function __construct( ?bool $forceEager = null, ?int $priority = null, ?string $name = null, - $provider = null, - $processor = null, + ?string $provider = null, + ?string $processor = null, ?OptionsInterface $stateOptions = null, array|Parameters|null $parameters = null, ?bool $queryParameterValidationEnabled = null, diff --git a/src/Metadata/HttpOperation.php b/src/Metadata/HttpOperation.php index 3f5e0daaeb4..0088d1298df 100644 --- a/src/Metadata/HttpOperation.php +++ b/src/Metadata/HttpOperation.php @@ -30,11 +30,11 @@ class HttpOperation extends Operation public const METHOD_OPTIONS = 'OPTIONS'; /** @var array|null */ - protected $formats; + protected ?array $formats; /** @var array|null */ - protected $inputFormats; + protected ?array $inputFormats; /** @var array|null */ - protected $outputFormats; + protected ?array $outputFormats; /** * @param string[]|null $types the RDF types of this property @@ -330,7 +330,7 @@ public function withTypes($types): static /** * @return array|null */ - public function getFormats() + public function getFormats(): ?array { return $this->formats; } @@ -349,7 +349,7 @@ public function withFormats($formats = null): static /** * @return array|null */ - public function getInputFormats() + public function getInputFormats(): ?array { return $this->inputFormats; } @@ -368,7 +368,7 @@ public function withInputFormats($inputFormats = null): static /** * @return array|null */ - public function getOutputFormats() + public function getOutputFormats(): ?array { return $this->outputFormats; } @@ -473,10 +473,7 @@ public function getStateless(): ?bool return $this->stateless; } - /** - * @param bool $stateless - */ - public function withStateless($stateless): static + public function withStateless(?bool $stateless): static { $self = clone $this; $self->stateless = $stateless; diff --git a/src/Metadata/Metadata.php b/src/Metadata/Metadata.php index 009612c9900..48c9602b75c 100644 --- a/src/Metadata/Metadata.php +++ b/src/Metadata/Metadata.php @@ -167,10 +167,7 @@ public function getDeprecationReason(): ?string return $this->deprecationReason; } - /** - * @param string $deprecationReason - */ - public function withDeprecationReason($deprecationReason): static + public function withDeprecationReason(?string $deprecationReason): static { $self = clone $this; $self->deprecationReason = $deprecationReason; diff --git a/src/Metadata/NotExposed.php b/src/Metadata/NotExposed.php index c7afb4941f0..f998982c3d6 100644 --- a/src/Metadata/NotExposed.php +++ b/src/Metadata/NotExposed.php @@ -34,7 +34,7 @@ public function __construct( string $method = 'GET', ?string $uriTemplate = null, ?array $types = null, - $formats = null, + array|string|null $formats = null, $inputFormats = null, $outputFormats = null, $uriVariables = null, @@ -46,7 +46,7 @@ public function __construct( ?bool $stateless = null, ?string $sunset = null, ?string $acceptPatch = null, - $status = 404, + string|int|null $status = null, ?string $host = null, ?array $schemes = null, ?string $condition = null, @@ -89,8 +89,8 @@ public function __construct( ?string $deprecationReason = null, ?array $filters = null, ?array $validationContext = null, - $input = null, - $output = false, + array|string|false|null $input = null, + array|string|false|null $output = false, $mercure = null, $messenger = null, ?int $urlGenerationStrategy = null, @@ -103,8 +103,8 @@ public function __construct( ?bool $forceEager = null, ?int $priority = null, ?string $name = null, - $provider = null, - $processor = null, + array|string|callable|int|null $provider = null, + array|string|callable|int|null $processor = null, array $extraProperties = [], ?OptionsInterface $stateOptions = null, ?bool $map = null, diff --git a/src/Metadata/Operations.php b/src/Metadata/Operations.php index a90681a7775..ccde1942f8a 100644 --- a/src/Metadata/Operations.php +++ b/src/Metadata/Operations.php @@ -89,7 +89,7 @@ public function remove(string $key): self public function has(string $key): bool { - foreach ($this->operations as $i => [$operationName, $operation]) { + foreach ($this->operations as [$operationName, $operation]) { if ($operationName === $key) { return true; } @@ -105,7 +105,7 @@ public function count(): int public function sort(): self { - usort($this->operations, static fn ($a, $b): int => $a[1]->getPriority() - $b[1]->getPriority()); + usort($this->operations, static fn (array $a, array $b): int => $a[1]->getPriority() - $b[1]->getPriority()); return $this; } diff --git a/src/Metadata/Patch.php b/src/Metadata/Patch.php index b81814350d7..d9da9b4e7ae 100644 --- a/src/Metadata/Patch.php +++ b/src/Metadata/Patch.php @@ -23,7 +23,7 @@ final class Patch extends HttpOperation public function __construct( ?string $uriTemplate = null, ?array $types = null, - $formats = null, + array|string|null $formats = null, $inputFormats = null, $outputFormats = null, $uriVariables = null, @@ -35,7 +35,7 @@ public function __construct( ?bool $stateless = null, ?string $sunset = null, ?string $acceptPatch = null, - $status = null, + string|int|null $status = null, ?string $host = null, ?array $schemes = null, ?string $condition = null, @@ -76,8 +76,8 @@ public function __construct( ?string $deprecationReason = null, ?array $filters = null, ?array $validationContext = null, - $input = null, - $output = null, + ?string $input = null, + string|bool|null $output = null, $mercure = null, $messenger = null, ?int $urlGenerationStrategy = null, @@ -90,8 +90,8 @@ public function __construct( ?bool $forceEager = null, ?int $priority = null, ?string $name = null, - $provider = null, - $processor = null, + array|string|callable|int|null $provider = null, + array|string|callable|int|null $processor = null, ?OptionsInterface $stateOptions = null, array|Parameters|null $parameters = null, mixed $rules = null, diff --git a/src/Metadata/Post.php b/src/Metadata/Post.php index 208366234ef..a5b611664f7 100644 --- a/src/Metadata/Post.php +++ b/src/Metadata/Post.php @@ -23,7 +23,7 @@ final class Post extends HttpOperation public function __construct( ?string $uriTemplate = null, ?array $types = null, - $formats = null, + array|string|null $formats = null, $inputFormats = null, $outputFormats = null, $uriVariables = null, @@ -35,7 +35,7 @@ public function __construct( ?bool $stateless = null, ?string $sunset = null, ?string $acceptPatch = null, - $status = null, + string|int|null $status = null, ?string $host = null, ?array $schemes = null, ?string $condition = null, @@ -76,8 +76,8 @@ public function __construct( ?string $deprecationReason = null, ?array $filters = null, ?array $validationContext = null, - $input = null, - $output = null, + ?string $input = null, + string|bool|null $output = null, $mercure = null, $messenger = null, ?int $urlGenerationStrategy = null, @@ -90,8 +90,8 @@ public function __construct( ?bool $forceEager = null, ?int $priority = null, ?string $name = null, - $provider = null, - $processor = null, + array|string|callable|int|null $provider = null, + array|string|callable|int|null $processor = null, ?OptionsInterface $stateOptions = null, array|Parameters|null $parameters = null, mixed $rules = null, diff --git a/src/Metadata/Property/Factory/AttributePropertyMetadataFactory.php b/src/Metadata/Property/Factory/AttributePropertyMetadataFactory.php index 5e53c08e049..9da27f1a171 100644 --- a/src/Metadata/Property/Factory/AttributePropertyMetadataFactory.php +++ b/src/Metadata/Property/Factory/AttributePropertyMetadataFactory.php @@ -125,7 +125,7 @@ private function createMetadata(ApiProperty $attribute, ?ApiProperty $propertyMe } foreach (get_class_methods(ApiProperty::class) as $method) { - if (preg_match('/^(?:get|is)(.*)/', (string) $method, $matches)) { + if (preg_match('/^(?:get|is)(.*)/', $method, $matches)) { // BC layer, to remove in 5.0 if ('getBuiltinTypes' === $method) { if (method_exists(PropertyInfoExtractor::class, 'getType')) { diff --git a/src/Metadata/Property/Factory/ExtractorPropertyMetadataFactory.php b/src/Metadata/Property/Factory/ExtractorPropertyMetadataFactory.php index e8e13f2256a..da8d48d63b4 100644 --- a/src/Metadata/Property/Factory/ExtractorPropertyMetadataFactory.php +++ b/src/Metadata/Property/Factory/ExtractorPropertyMetadataFactory.php @@ -120,7 +120,7 @@ private function handleNotFound(?ApiProperty $parentPropertyMetadata, string $re private function update(ApiProperty $propertyMetadata, array $metadata): ApiProperty { foreach (get_class_methods(ApiProperty::class) as $method) { - if (preg_match('/^(?:get|is)(.*)/', (string) $method, $matches) && null !== ($val = $metadata[lcfirst($matches[1])] ?? null) && method_exists($propertyMetadata, "with{$matches[1]}")) { + if (preg_match('/^(?:get|is)(.*)/', $method, $matches) && null !== ($val = $metadata[lcfirst($matches[1])] ?? null) && method_exists($propertyMetadata, "with{$matches[1]}")) { $propertyMetadata = $propertyMetadata->{"with{$matches[1]}"}($val); } } diff --git a/src/Metadata/Put.php b/src/Metadata/Put.php index 5fbfbfd49f6..3d69dfb277c 100644 --- a/src/Metadata/Put.php +++ b/src/Metadata/Put.php @@ -23,7 +23,7 @@ final class Put extends HttpOperation public function __construct( ?string $uriTemplate = null, ?array $types = null, - $formats = null, + array|string|null $formats = null, $inputFormats = null, $outputFormats = null, $uriVariables = null, @@ -35,7 +35,7 @@ public function __construct( ?bool $stateless = null, ?string $sunset = null, ?string $acceptPatch = null, - $status = null, + string|int|null $status = null, ?string $host = null, ?array $schemes = null, ?string $condition = null, @@ -76,8 +76,8 @@ public function __construct( ?string $deprecationReason = null, ?array $filters = null, ?array $validationContext = null, - $input = null, - $output = null, + ?string $input = null, + string|bool|null $output = null, $mercure = null, $messenger = null, ?int $urlGenerationStrategy = null, @@ -90,8 +90,8 @@ public function __construct( ?bool $forceEager = null, ?int $priority = null, ?string $name = null, - $provider = null, - $processor = null, + array|string|callable|int|null $provider = null, + array|string|callable|int|null $processor = null, ?OptionsInterface $stateOptions = null, array|Parameters|null $parameters = null, mixed $rules = null, diff --git a/src/Metadata/Resource/Factory/LinkFactory.php b/src/Metadata/Resource/Factory/LinkFactory.php index fb87e584b0a..cf0dcf15878 100644 --- a/src/Metadata/Resource/Factory/LinkFactory.php +++ b/src/Metadata/Resource/Factory/LinkFactory.php @@ -30,7 +30,7 @@ final class LinkFactory implements LinkFactoryInterface, PropertyLinkFactoryInte /** * @var array */ - private $localIdentifiersPerResourceClassCache = []; + private array $localIdentifiersPerResourceClassCache = []; public function __construct(private readonly PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, private readonly PropertyMetadataFactoryInterface $propertyMetadataFactory, private readonly ResourceClassResolverInterface $resourceClassResolver) { diff --git a/src/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactory.php b/src/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactory.php index 66795de7b37..c5ba9f4780f 100644 --- a/src/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactory.php +++ b/src/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactory.php @@ -184,8 +184,6 @@ private function getProperties(string $resourceClass, ?Parameter $parameter = nu $properties[$property] = $propertyMetadata; } } - - continue; } // If traversal wasn't fully successful but the property was explicitly listed diff --git a/src/Metadata/Tests/Extractor/Adapter/XmlPropertyAdapter.php b/src/Metadata/Tests/Extractor/Adapter/XmlPropertyAdapter.php index 27cea064f1b..8809520250e 100644 --- a/src/Metadata/Tests/Extractor/Adapter/XmlPropertyAdapter.php +++ b/src/Metadata/Tests/Extractor/Adapter/XmlPropertyAdapter.php @@ -98,7 +98,7 @@ public function __invoke(string $resourceClass, string $propertyName, array $par return [$filename]; } - private function buildBuiltinTypes(\SimpleXMLElement $resource): void + private function buildBuiltinTypes(): void { // deprecated, to remove in 5.0 } diff --git a/src/Metadata/Tests/Extractor/Adapter/XmlResourceAdapter.php b/src/Metadata/Tests/Extractor/Adapter/XmlResourceAdapter.php index b15d99a4508..381c25f2a69 100644 --- a/src/Metadata/Tests/Extractor/Adapter/XmlResourceAdapter.php +++ b/src/Metadata/Tests/Extractor/Adapter/XmlResourceAdapter.php @@ -535,7 +535,7 @@ private function buildLinks(\SimpleXMLElement $resource, ?array $values = null): $childNode->addAttribute('href', $values[0]['href']); } - private function buildRules(\SimpleXMLElement $resource, ?array $values = null): void + private function buildRules(): void { } diff --git a/src/Metadata/Tests/Extractor/PropertyMetadataCompatibilityTest.php b/src/Metadata/Tests/Extractor/PropertyMetadataCompatibilityTest.php index 9eb3d02f3bb..5c9c85091ad 100644 --- a/src/Metadata/Tests/Extractor/PropertyMetadataCompatibilityTest.php +++ b/src/Metadata/Tests/Extractor/PropertyMetadataCompatibilityTest.php @@ -125,7 +125,7 @@ private function buildApiProperty(): ApiProperty return $property; } - private function withNativeType(string $value): Type + private function withNativeType(string $value): Type\BuiltinType { return Type::builtin($value); } diff --git a/src/Metadata/Tests/Extractor/ResourceMetadataCompatibilityTest.php b/src/Metadata/Tests/Extractor/ResourceMetadataCompatibilityTest.php index 943790e0ba4..cec604a327f 100644 --- a/src/Metadata/Tests/Extractor/ResourceMetadataCompatibilityTest.php +++ b/src/Metadata/Tests/Extractor/ResourceMetadataCompatibilityTest.php @@ -716,7 +716,7 @@ private function withGraphQlOperations(array $values, ?array $fixtures): array return $operations; } - private function withStateOptions(array $values) + private function withStateOptions(array $values): null { if (!$values) { return null; @@ -726,7 +726,7 @@ private function withStateOptions(array $values) throw new \InvalidArgumentException('Only one options can be configured at a time.'); } - $configuration = reset($values); + reset($values); switch (key($values)) { case 'elasticsearchOptions': return null; diff --git a/src/Metadata/Tests/Fixtures/ApiResource/Dummy.php b/src/Metadata/Tests/Fixtures/ApiResource/Dummy.php index c2eaa83d8c1..4471958a461 100644 --- a/src/Metadata/Tests/Fixtures/ApiResource/Dummy.php +++ b/src/Metadata/Tests/Fixtures/ApiResource/Dummy.php @@ -162,7 +162,7 @@ public function getDummyDate() return $this->dummyDate; } - public function setDummyPrice($dummyPrice) + public function setDummyPrice($dummyPrice): static { $this->dummyPrice = $dummyPrice; diff --git a/src/Metadata/Tests/Fixtures/ApiResource/DummyCar.php b/src/Metadata/Tests/Fixtures/ApiResource/DummyCar.php index a132dc1adda..9bfb863ebee 100644 --- a/src/Metadata/Tests/Fixtures/ApiResource/DummyCar.php +++ b/src/Metadata/Tests/Fixtures/ApiResource/DummyCar.php @@ -75,7 +75,7 @@ public function getSecondColors(): ?iterable return $this->secondColors; } - public function setSecondColors($secondColors): void + public function setSecondColors(?iterable $secondColors): void { $this->secondColors = $secondColors; } @@ -85,7 +85,7 @@ public function getThirdColors(): ?iterable return $this->thirdColors; } - public function setThirdColors($thirdColors): void + public function setThirdColors(?iterable $thirdColors): void { $this->thirdColors = $thirdColors; } @@ -95,7 +95,7 @@ public function getUuid(): ?iterable return $this->uuid; } - public function setUuid($uuid): void + public function setUuid(?iterable $uuid): void { $this->uuid = $uuid; } diff --git a/src/Metadata/Tests/Fixtures/ApiResource/DummyObjectWithOnlyPrivateProperty.php b/src/Metadata/Tests/Fixtures/ApiResource/DummyObjectWithOnlyPrivateProperty.php index 0dba99761c1..0d5626579ec 100644 --- a/src/Metadata/Tests/Fixtures/ApiResource/DummyObjectWithOnlyPrivateProperty.php +++ b/src/Metadata/Tests/Fixtures/ApiResource/DummyObjectWithOnlyPrivateProperty.php @@ -15,5 +15,5 @@ class DummyObjectWithOnlyPrivateProperty { - private $foo; // @phpstan-ignore-line + // @phpstan-ignore-line } diff --git a/src/Metadata/Tests/Fixtures/ApiResource/InstanceOfApiResource.php b/src/Metadata/Tests/Fixtures/ApiResource/InstanceOfApiResource.php index a44d6567ce2..9e530f680c2 100644 --- a/src/Metadata/Tests/Fixtures/ApiResource/InstanceOfApiResource.php +++ b/src/Metadata/Tests/Fixtures/ApiResource/InstanceOfApiResource.php @@ -20,10 +20,6 @@ class InstanceOfApiResource { private $id; - public function __construct() - { - } - public function getId() { return $this->id; diff --git a/src/Metadata/Tests/Property/Factory/SerializerPropertyMetadataFactoryTest.php b/src/Metadata/Tests/Property/Factory/SerializerPropertyMetadataFactoryTest.php index 0921b7a7568..b8ef2f811c2 100644 --- a/src/Metadata/Tests/Property/Factory/SerializerPropertyMetadataFactoryTest.php +++ b/src/Metadata/Tests/Property/Factory/SerializerPropertyMetadataFactoryTest.php @@ -42,7 +42,7 @@ public static function groupsProvider(): array } #[DataProvider('groupsProvider')] - public function testCreateWithGroups($readGroups, $writeGroups): void + public function testCreateWithGroups(string|array $readGroups, string|array $writeGroups): void { $serializerClassMetadataFactoryProphecy = $this->prophesize(SerializerClassMetadataFactoryInterface::class); $dummySerializerClassMetadata = new SerializerClassMetadata(Dummy::class); @@ -120,7 +120,7 @@ public static function attributesProvider(): array } #[DataProvider('attributesProvider')] - public function testCreateWithAttributes($readAttributes, $writeAttributes): void + public function testCreateWithAttributes(array $readAttributes, array $writeAttributes): void { $serializerClassMetadataFactoryProphecy = $this->prophesize(SerializerClassMetadataFactoryInterface::class); $dummySerializerClassMetadata = new SerializerClassMetadata(Dummy::class); diff --git a/src/Metadata/Tests/Resource/Factory/LinkFactoryTest.php b/src/Metadata/Tests/Resource/Factory/LinkFactoryTest.php index 9c4c352139b..bd448a239e1 100644 --- a/src/Metadata/Tests/Resource/Factory/LinkFactoryTest.php +++ b/src/Metadata/Tests/Resource/Factory/LinkFactoryTest.php @@ -144,8 +144,6 @@ public function testCompleteLink(): void public function testCreateLinkFromProperty(): void { $propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class); - - $property = 'test'; $propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class); $propertyMetadataFactoryProphecy->create(Dummy::class, 'test')->willReturn(new ApiProperty(nativeType: Type::object(RelatedDummy::class))); diff --git a/src/Metadata/Tests/Resource/Factory/ParameterResourceMetadataCollectionFactoryTest.php b/src/Metadata/Tests/Resource/Factory/ParameterResourceMetadataCollectionFactoryTest.php index a26c9321393..1cdeef4a093 100644 --- a/src/Metadata/Tests/Resource/Factory/ParameterResourceMetadataCollectionFactoryTest.php +++ b/src/Metadata/Tests/Resource/Factory/ParameterResourceMetadataCollectionFactoryTest.php @@ -40,7 +40,7 @@ public function testParameterFactory(): void $nameCollection->method('create')->willReturn(new PropertyNameCollection(['id', 'hydra', 'everywhere'])); $propertyMetadata = $this->createStub(PropertyMetadataFactoryInterface::class); $propertyMetadata->method('create')->willReturnCallback( - static fn (string $class, string $property) => match ($property) { + static fn (string $class, string $property): ApiProperty => match ($property) { 'id' => new ApiProperty(identifier: true), default => new ApiProperty(readable: true), } @@ -185,7 +185,7 @@ public function testParameterFactoryNoFilter(): void $nameCollection->method('create')->willReturn(new PropertyNameCollection(['id', 'hydra', 'everywhere'])); $propertyMetadata = $this->createStub(PropertyMetadataFactoryInterface::class); $propertyMetadata->method('create')->willReturnCallback( - static fn (string $class, string $property) => match ($property) { + static fn (string $class, string $property): ApiProperty => match ($property) { 'id' => new ApiProperty(identifier: true), default => new ApiProperty(readable: true), } diff --git a/src/Metadata/Tests/Util/ClassInfoTraitTest.php b/src/Metadata/Tests/Util/ClassInfoTraitTest.php index 541f1e578ff..63d913c6498 100644 --- a/src/Metadata/Tests/Util/ClassInfoTraitTest.php +++ b/src/Metadata/Tests/Util/ClassInfoTraitTest.php @@ -19,7 +19,7 @@ class ClassInfoTraitTest extends TestCase { - private function getClassInfoTraitImplementation() + private function getClassInfoTraitImplementation(): object { return new class { use ClassInfoTrait { diff --git a/src/Metadata/Util/AttributesExtractor.php b/src/Metadata/Util/AttributesExtractor.php index 99b5cee8b13..2cbd2a9878e 100644 --- a/src/Metadata/Util/AttributesExtractor.php +++ b/src/Metadata/Util/AttributesExtractor.php @@ -55,12 +55,10 @@ public static function extractAttributes(array $attributes): array return []; } - $result += [ + return $result + [ 'receive' => (bool) ($attributes['_api_receive'] ?? true), 'respond' => (bool) ($attributes['_api_respond'] ?? true), 'persist' => (bool) ($attributes['_api_persist'] ?? true), ]; - - return $result; } } diff --git a/src/Metadata/WithResourceTrait.php b/src/Metadata/WithResourceTrait.php index 3acceb92e28..13c7f795237 100644 --- a/src/Metadata/WithResourceTrait.php +++ b/src/Metadata/WithResourceTrait.php @@ -24,7 +24,7 @@ protected function copyFrom(Metadata $resource, array $ignoredOptions = []): sta foreach (get_class_methods($resource) as $method) { if ( method_exists($self, $method) - && preg_match('/^(?:get|is|can)(.*)/', (string) $method, $matches) + && preg_match('/^(?:get|is|can)(.*)/', $method, $matches) && (!$ignoredOptions || !\in_array(lcfirst($matches[1]), $ignoredOptions, true)) && null === $self->{$method}() && null !== $val = $resource->{$method}() diff --git a/src/OpenApi/Command/OpenApiCommand.php b/src/OpenApi/Command/OpenApiCommand.php index 30802a482e6..686812a0bc8 100644 --- a/src/OpenApi/Command/OpenApiCommand.php +++ b/src/OpenApi/Command/OpenApiCommand.php @@ -46,7 +46,7 @@ protected function configure(): void ->addOption('output', 'o', InputOption::VALUE_REQUIRED, 'Write output to file') ->addOption('spec-version', null, InputOption::VALUE_REQUIRED, 'Open API version to use (2 or 3) (2 is deprecated)', '3') ->addOption('api-gateway', null, InputOption::VALUE_NONE, 'Enable the Amazon API Gateway compatibility mode') - ->addOption('filter-tags', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Filter only matching x-apiplatform-tag operations', null); + ->addOption('filter-tags', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Filter only matching x-apiplatform-tag operations'); } /** diff --git a/src/OpenApi/Factory/OpenApiFactory.php b/src/OpenApi/Factory/OpenApiFactory.php index 0e15d24aed4..92fab0dc5a6 100644 --- a/src/OpenApi/Factory/OpenApiFactory.php +++ b/src/OpenApi/Factory/OpenApiFactory.php @@ -265,7 +265,6 @@ private function collectPaths(ApiResource $resource, ResourceMetadataCollection $operationOutputSchemas = []; foreach ($responseMimeTypes as $operationFormat) { - $operationOutputSchema = null; $operationOutputSchema = $this->jsonSchemaFactory->buildSchema($resourceClass, $operationFormat, Schema::TYPE_OUTPUT, $operation, $schema, null, $forceSchemaCollection); $this->appendSchemaDefinitions($schemas, $operationOutputSchema->getDefinitions()); @@ -459,7 +458,6 @@ private function collectPaths(ApiResource $resource, ResourceMetadataCollection if (null === $content) { $operationInputSchemas = []; foreach ($requestMimeTypes as $operationFormat) { - $operationInputSchema = null; $operationInputSchema = $this->jsonSchemaFactory->buildSchema($resourceClass, $operationFormat, Schema::TYPE_INPUT, $operation, $schema, null, $forceSchemaCollection); $this->appendSchemaDefinitions($schemas, $operationInputSchema->getDefinitions()); @@ -890,7 +888,7 @@ private function getOauthSecurityScheme(): SecurityScheme throw new \LogicException('OAuth flow must be one of: implicit, password, clientCredentials, authorizationCode'); } - return new SecurityScheme($this->openApiOptions->getOAuthType(), $description, null, null, null, null, new OAuthFlows($implicit, $password, $clientCredentials, $authorizationCode), null); + return new SecurityScheme($this->openApiOptions->getOAuthType(), $description, null, null, null, null, new OAuthFlows($implicit, $password, $clientCredentials, $authorizationCode)); } private function getSecuritySchemes(): array @@ -1006,7 +1004,6 @@ private function addOperationErrors( $operationErrorSchemas = []; foreach ($responseMimeTypes as $operationFormat) { - $operationErrorSchema = null; $operationErrorSchema = $this->jsonSchemaFactory->buildSchema($errorResource->getClass(), $operationFormat, Schema::TYPE_OUTPUT, null, $schema); $this->appendSchemaDefinitions($schemas, $operationErrorSchema->getDefinitions()); $operationErrorSchemas[$operationFormat] = $operationErrorSchema; diff --git a/src/OpenApi/Serializer/OpenApiNormalizer.php b/src/OpenApi/Serializer/OpenApiNormalizer.php index e55a6a22c5a..0912dcf5fe9 100644 --- a/src/OpenApi/Serializer/OpenApiNormalizer.php +++ b/src/OpenApi/Serializer/OpenApiNormalizer.php @@ -91,7 +91,7 @@ private function getPathsCallBack(): \Closure $paths = $decoratedObject->getPaths(); // sort paths by tags, then by path for each tag - uksort($paths, static function ($keyA, $keyB) use ($paths) { + uksort($paths, static function ($keyA, $keyB) use ($paths): int { $a = $paths[$keyA]; $b = $paths[$keyB]; diff --git a/src/OpenApi/Tests/Factory/OpenApiFactoryTest.php b/src/OpenApi/Tests/Factory/OpenApiFactoryTest.php index d8773f8c7a6..0a6cedcb0cb 100644 --- a/src/OpenApi/Tests/Factory/OpenApiFactoryTest.php +++ b/src/OpenApi/Tests/Factory/OpenApiFactoryTest.php @@ -673,7 +673,7 @@ public function testInvoke(): void 'header' => new SecurityScheme('apiKey', 'Value for the Authorization header parameter.', 'Authorization', 'header'), 'query' => new SecurityScheme('apiKey', 'Value for the key query parameter.', 'key', 'query'), 'bearer' => new SecurityScheme('http', 'Value for the http bearer parameter.', null, null, 'bearer', 'JWT'), - 'basic' => new SecurityScheme('http', 'Value for the http basic parameter.', null, null, 'basic', null), + 'basic' => new SecurityScheme('http', 'Value for the http basic parameter.', null, null, 'basic'), ])); $this->assertEquals([ @@ -1285,8 +1285,7 @@ public function testInvoke(): void 'Creates a Dummy resource.', 'Creates a Dummy resource.', null, - [], - null + [] ), $emptyRequestBodyPath->getPost()); $emptyResponsePath = $paths->getPath('/dummyitem/nooutput'); @@ -1436,6 +1435,6 @@ public function testGetExtensionPropertiesWithFalseValue(): void ['json' => ['application/problem+json']] ); - $openApi = $factory->__invoke(); + $factory->__invoke(); } } diff --git a/src/OpenApi/Tests/Fixtures/Dummy.php b/src/OpenApi/Tests/Fixtures/Dummy.php index f6d73d7556d..d949b94bb60 100644 --- a/src/OpenApi/Tests/Fixtures/Dummy.php +++ b/src/OpenApi/Tests/Fixtures/Dummy.php @@ -171,7 +171,7 @@ public function getDummyDate() return $this->dummyDate; } - public function setDummyPrice($dummyPrice) + public function setDummyPrice($dummyPrice): static { $this->dummyPrice = $dummyPrice; @@ -223,10 +223,7 @@ public function isDummyBoolean(): ?bool return $this->dummyBoolean; } - /** - * @param bool $dummyBoolean - */ - public function setDummyBoolean($dummyBoolean): void + public function setDummyBoolean(?bool $dummyBoolean): void { $this->dummyBoolean = $dummyBoolean; } diff --git a/src/OpenApi/Tests/Serializer/OpenApiNormalizerTest.php b/src/OpenApi/Tests/Serializer/OpenApiNormalizerTest.php index be36a20f288..d4e02b0d2e9 100644 --- a/src/OpenApi/Tests/Serializer/OpenApiNormalizerTest.php +++ b/src/OpenApi/Tests/Serializer/OpenApiNormalizerTest.php @@ -208,7 +208,7 @@ public function testNormalize(): void $propertyNameCollectionFactory = $propertyNameCollectionFactoryProphecy->reveal(); $propertyMetadataFactory = $propertyMetadataFactoryProphecy->reveal(); - $definitionNameFactory = new DefinitionNameFactory(null); + $definitionNameFactory = new DefinitionNameFactory(); $schemaFactory = new SchemaFactory( resourceMetadataFactory: $resourceMetadataFactory, diff --git a/src/Serializer/AbstractItemNormalizer.php b/src/Serializer/AbstractItemNormalizer.php index b4bd8e67147..243230464d5 100644 --- a/src/Serializer/AbstractItemNormalizer.php +++ b/src/Serializer/AbstractItemNormalizer.php @@ -79,7 +79,7 @@ abstract class AbstractItemNormalizer extends AbstractObjectNormalizer public function __construct(protected PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, protected PropertyMetadataFactoryInterface $propertyMetadataFactory, protected IriConverterInterface $iriConverter, protected ResourceClassResolverInterface $resourceClassResolver, ?PropertyAccessorInterface $propertyAccessor = null, ?NameConverterInterface $nameConverter = null, ?ClassMetadataFactoryInterface $classMetadataFactory = null, array $defaultContext = [], ?ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory = null, ?ResourceAccessCheckerInterface $resourceAccessChecker = null, protected ?TagCollectorInterface $tagCollector = null, protected ?OperationResourceClassResolverInterface $operationResourceResolver = null) { if (!isset($defaultContext['circular_reference_handler'])) { - $defaultContext['circular_reference_handler'] = fn ($object): ?string => $this->iriConverter->getIriFromResource($object); + $defaultContext['circular_reference_handler'] = fn (object|string $object): ?string => $this->iriConverter->getIriFromResource($object); } parent::__construct($classMetadataFactory, $nameConverter, null, null, \Closure::fromCallable($this->getObjectClass(...)), $defaultContext); @@ -1118,7 +1118,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value $className = null; $typeIsResourceClass = function (Type $type) use (&$className): bool { - return $type instanceof ObjectType ? $this->resourceClassResolver->isResourceClass($className = $type->getClassName()) : false; + return $type instanceof ObjectType && $this->resourceClassResolver->isResourceClass($className = $type->getClassName()); }; $isMultipleTypes = \count($types) > 1; @@ -1334,9 +1334,9 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value } if ($denormalizationException) { - if ($type instanceof Type && $type->isSatisfiedBy(static fn ($type) => $type instanceof BuiltinType) && !$type->isSatisfiedBy($typeIsResourceClass)) { + if ($type instanceof Type && $type->isSatisfiedBy(static fn ($type): bool => $type instanceof BuiltinType) && !$type->isSatisfiedBy($typeIsResourceClass)) { // If the exception came from object denormalization, preserve its message as it's more specific - $message = $type->isSatisfiedBy(static fn ($type) => $type instanceof ObjectType) + $message = $type->isSatisfiedBy(static fn ($type): bool => $type instanceof ObjectType) ? $denormalizationException->getMessage() : \sprintf('The type of the "%s" attribute must be "%s", "%s" given.', $attribute, $type, \gettype($value)); diff --git a/src/Serializer/ConstraintViolationListNormalizer.php b/src/Serializer/ConstraintViolationListNormalizer.php index 6ee3aa5b1f2..b6337c323e9 100644 --- a/src/Serializer/ConstraintViolationListNormalizer.php +++ b/src/Serializer/ConstraintViolationListNormalizer.php @@ -13,8 +13,6 @@ namespace ApiPlatform\Serializer; -use Symfony\Component\Serializer\NameConverter\NameConverterInterface; - /** * Converts {@see \Symfony\Component\Validator\ConstraintViolationListInterface} the API Problem spec (RFC 7807). * @@ -26,11 +24,6 @@ final class ConstraintViolationListNormalizer extends AbstractConstraintViolatio { public const FORMAT = 'json'; - public function __construct(?array $serializePayloadFields = null, ?NameConverterInterface $nameConverter = null) - { - parent::__construct($serializePayloadFields, $nameConverter); - } - /** * {@inheritdoc} */ diff --git a/src/Serializer/Filter/PropertyFilter.php b/src/Serializer/Filter/PropertyFilter.php index 01f36dfc0b1..194df5c0511 100644 --- a/src/Serializer/Filter/PropertyFilter.php +++ b/src/Serializer/Filter/PropertyFilter.php @@ -135,7 +135,7 @@ public function apply(Request $request, bool $normalization, array $attributes, // TODO: ideally we should return the new context, not mutate the context given in our arguments which is the serializer context // this would allow to use `Parameter::filterContext` properly, for now let's retrieve it like this: /** @var MetadataParameter|null */ - $parameter = $request->attributes->get('_api_parameter', null); + $parameter = $request->attributes->get('_api_parameter'); $parameterName = $this->parameterName; $whitelist = $this->whitelist; $overrideDefaultProperties = $this->overrideDefaultProperties; diff --git a/src/Serializer/Tests/AbstractItemNormalizerTest.php b/src/Serializer/Tests/AbstractItemNormalizerTest.php index d0c15eac0af..28060cd26df 100644 --- a/src/Serializer/Tests/AbstractItemNormalizerTest.php +++ b/src/Serializer/Tests/AbstractItemNormalizerTest.php @@ -81,7 +81,7 @@ public function testSupportNormalizationAndSupportDenormalization(): void $resourceClassResolverProphecy->isResourceClass(Dummy::class)->willReturn(true); $resourceClassResolverProphecy->isResourceClass(\stdClass::class)->willReturn(false); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $this->assertTrue($normalizer->supportsNormalization($dummy)); $this->assertFalse($normalizer->supportsNormalization($std)); @@ -151,7 +151,7 @@ public function testNormalize(): void $serializerProphecy->normalize('/dummies/2', null, Argument::type('array'))->willReturn('/dummies/2'); $serializerProphecy->normalize(['/dummies/2'], null, Argument::type('array'))->willReturn(['/dummies/2']); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $expected = [ @@ -293,7 +293,7 @@ public function testNormalizePropertyAsIriWithUriTemplate(): void $resourceClassResolverProphecy->getResourceClass([$propertyCollectionIriOnlyRelation], PropertyCollectionIriOnlyRelation::class)->willReturn(PropertyCollectionIriOnlyRelation::class); $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), new PropertyAccessor(), // $propertyAccessorProphecy->reveal(), - null, null, [], $resourceMetadataCollectionFactoryProphecy->reveal(), null, ) extends AbstractItemNormalizer {}; + null, null, [], $resourceMetadataCollectionFactoryProphecy->reveal(), ) extends AbstractItemNormalizer {}; $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(NormalizerInterface::class); @@ -350,7 +350,7 @@ public function testDenormalizeWithSecuredPropertyAndThrowOnAccessDeniedExtraPro $resourceAccessChecker->isGranted( SecuredDummy::class, 'is_granted(\'ROLE_ADMIN\')', - Argument::that(static function (array $context) { + Argument::that(static function (array $context): bool { return \array_key_exists('property', $context) && \array_key_exists('object', $context) && \array_key_exists('previous_object', $context) @@ -403,7 +403,7 @@ public function testDenormalizeWithSecuredPropertyAndThrowOnAccessDeniedExtraPro $resourceAccessChecker->isGranted( SecuredDummy::class, 'is_granted(\'ROLE_ADMIN\')', - Argument::that(static function (array $context) { + Argument::that(static function (array $context): bool { return \array_key_exists('property', $context) && \array_key_exists('object', $context) && \array_key_exists('previous_object', $context) @@ -460,7 +460,7 @@ public function testDenormalizeWithSecuredPropertyAndThrowOnAccessDeniedExtraPro $resourceAccessChecker->isGranted( SecuredDummy::class, 'is_granted(\'ROLE_ADMIN\')', - Argument::that(static function (array $context) { + Argument::that(static function (array $context): bool { return \array_key_exists('property', $context) && \array_key_exists('object', $context) && \array_key_exists('previous_object', $context) @@ -817,7 +817,7 @@ public function testNormalizeReadableLinks(): void $serializerProphecy->normalize(['foo' => 'hello'], null, Argument::type('array'))->willReturn(['foo' => 'hello']); $serializerProphecy->normalize([['foo' => 'hello']], null, Argument::type('array'))->willReturn([['foo' => 'hello']]); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $expected = [ @@ -879,7 +879,7 @@ public function testNormalizePolymorphicRelations(): void $serializerProphecy->normalize($concreteDummy, null, $concreteDummyChildContext)->willReturn(['foo' => 'concrete']); $serializerProphecy->normalize([['foo' => 'concrete']], null, Argument::type('array'))->willReturn([['foo' => 'concrete']]); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $expected = [ @@ -940,7 +940,7 @@ public function testDenormalize(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(NormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $actual = $normalizer->denormalize($data, Dummy::class); @@ -1069,7 +1069,7 @@ public function testDenormalizeWritableLinks(): void $serializerProphecy->denormalize(['bar' => 'qux'], RelatedDummy::class, null, Argument::type('array'))->willReturn($relatedDummy3); $serializerProphecy->denormalize(['bar' => 'quux'], RelatedDummy::class, null, Argument::type('array'))->willReturn($relatedDummy4); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $actual = $normalizer->denormalize($data, Dummy::class); @@ -1118,7 +1118,7 @@ public function testDenormalizeRelationNotFoundReturnsNull(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(DenormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $actual = $normalizer->denormalize($data, Dummy::class, null, [ @@ -1168,7 +1168,7 @@ public function testBadRelationType(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(DenormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $normalizer->denormalize($data, Dummy::class); @@ -1209,7 +1209,7 @@ public function testBadRelationTypeWithExceptionToValidationErrors(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(DenormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); // 'not_normalizable_value_exceptions' is set by Serializer thanks to DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS @@ -1253,7 +1253,7 @@ public function testDeserializationPathForNotDenormalizableRelations(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(DenormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $errors = []; @@ -1286,7 +1286,7 @@ public function testDeserializationPathForNotDenormalizableResource(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(DenormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $normalizer->denormalize('wrong IRI', Dummy::class, null, ['not_normalizable_value_exceptions' => []]); @@ -1313,7 +1313,7 @@ public function testDeserializationPathForNotFoundResource(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(DenormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $normalizer->denormalize('/some-iri', Dummy::class, null, ['not_normalizable_value_exceptions' => []]); @@ -1359,7 +1359,7 @@ public function testInnerDocumentNotAllowed(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(DenormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $normalizer->denormalize($data, Dummy::class); @@ -1397,7 +1397,7 @@ public function testBadType(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(DenormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $normalizer->denormalize($data, Dummy::class); @@ -1432,7 +1432,7 @@ public function testTypeChecksCanBeDisabled(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(DenormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $actual = $normalizer->denormalize($data, Dummy::class, null, ['disable_type_enforcement' => true]); @@ -1471,7 +1471,7 @@ public function testJsonAllowIntAsFloat(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(DenormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $actual = $normalizer->denormalize($data, Dummy::class, 'jsonfoo'); @@ -1543,7 +1543,7 @@ public function testDenormalizeBadKeyType(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(DenormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $normalizer->denormalize($data, Dummy::class); @@ -1578,7 +1578,7 @@ public function testNullable(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(DenormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $actual = $normalizer->denormalize($data, Dummy::class); @@ -1649,7 +1649,7 @@ public function testDenormalizeBasicTypePropertiesFromXml(): void $propertyAccessorProphecy->setValue(Argument::type(ObjectWithBasicProperties::class), 'float1', Argument::approximate(123.456, 0))->shouldBeCalled(); $propertyAccessorProphecy->setValue(Argument::type(ObjectWithBasicProperties::class), 'float2', Argument::approximate(-1.2344e56, 1))->shouldBeCalled(); $propertyAccessorProphecy->setValue(Argument::type(ObjectWithBasicProperties::class), 'float3', Argument::approximate(45E-6, 1))->shouldBeCalled(); - $propertyAccessorProphecy->setValue(Argument::type(ObjectWithBasicProperties::class), 'floatNaN', Argument::that(static fn (float $arg) => is_nan($arg)))->shouldBeCalled(); + $propertyAccessorProphecy->setValue(Argument::type(ObjectWithBasicProperties::class), 'floatNaN', Argument::that(static fn (float $arg): bool => is_nan($arg)))->shouldBeCalled(); $propertyAccessorProphecy->setValue(Argument::type(ObjectWithBasicProperties::class), 'floatInf', \INF)->shouldBeCalled(); $propertyAccessorProphecy->setValue(Argument::type(ObjectWithBasicProperties::class), 'floatNegInf', -\INF)->shouldBeCalled(); @@ -1660,7 +1660,7 @@ public function testDenormalizeBasicTypePropertiesFromXml(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(NormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $objectWithBasicProperties = $normalizer->denormalize( @@ -1729,7 +1729,7 @@ public function testDenormalizeCollectionDecodedFromXmlWithOneChild(): void $serializerProphecy->willImplement(DenormalizerInterface::class); $serializerProphecy->denormalize(['name' => 'foo'], RelatedDummy::class, 'xml', Argument::type('array'))->willReturn($relatedDummy); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $normalizer->denormalize($data, Dummy::class, 'xml'); @@ -1766,7 +1766,7 @@ public function testDenormalizePopulatingNonCloneableObject(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(NormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $normalizer->setSerializer($serializerProphecy->reveal()); @@ -1805,7 +1805,7 @@ public function testDenormalizeObjectWithNullDisabledTypeEnforcement(): void $serializerProphecy = $this->prophesize(SerializerInterface::class); $serializerProphecy->willImplement(NormalizerInterface::class); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $context = [AbstractItemNormalizer::DISABLE_TYPE_ENFORCEMENT => true]; @@ -1874,7 +1874,7 @@ public function testCacheKey(): void $serializerProphecy->normalize('/dummies/2', null, Argument::type('array'))->willReturn('/dummies/2'); $serializerProphecy->normalize(['/dummies/2'], null, Argument::type('array'))->willReturn(['/dummies/2']); - $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, [], null, null) extends AbstractItemNormalizer {}; + $normalizer = new class($propertyNameCollectionFactoryProphecy->reveal(), $propertyMetadataFactoryProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal(), null, null, []) extends AbstractItemNormalizer {}; $normalizer->setSerializer($serializerProphecy->reveal()); $expected = [ diff --git a/src/Serializer/Tests/Fixtures/ApiResource/Dummy.php b/src/Serializer/Tests/Fixtures/ApiResource/Dummy.php index 549421ce47a..76d7238cf7f 100644 --- a/src/Serializer/Tests/Fixtures/ApiResource/Dummy.php +++ b/src/Serializer/Tests/Fixtures/ApiResource/Dummy.php @@ -179,7 +179,7 @@ public function getDummyDate() return $this->dummyDate; } - public function setDummyPrice($dummyPrice) + public function setDummyPrice($dummyPrice): static { $this->dummyPrice = $dummyPrice; @@ -231,10 +231,7 @@ public function isDummyBoolean(): ?bool return $this->dummyBoolean; } - /** - * @param bool $dummyBoolean - */ - public function setDummyBoolean($dummyBoolean): void + public function setDummyBoolean(?bool $dummyBoolean): void { $this->dummyBoolean = $dummyBoolean; } diff --git a/src/Serializer/Tests/Fixtures/ApiResource/DummyTableInheritanceRelated.php b/src/Serializer/Tests/Fixtures/ApiResource/DummyTableInheritanceRelated.php index 9378cda6230..44e7e050369 100644 --- a/src/Serializer/Tests/Fixtures/ApiResource/DummyTableInheritanceRelated.php +++ b/src/Serializer/Tests/Fixtures/ApiResource/DummyTableInheritanceRelated.php @@ -47,14 +47,14 @@ public function getChildren(): Collection|iterable return $this->children; } - public function setChildren(Collection|iterable $children) + public function setChildren(Collection|iterable $children): static { $this->children = $children; return $this; } - public function addChild($child) + public function addChild($child): static { $this->children->add($child); $child->setParent($this); @@ -62,7 +62,7 @@ public function addChild($child) return $this; } - public function removeChild($child) + public function removeChild(string|int $child): static { $this->children->remove($child); diff --git a/src/Serializer/Tests/Fixtures/ApiResource/NonCloneableDummy.php b/src/Serializer/Tests/Fixtures/ApiResource/NonCloneableDummy.php index f0e6d86b2f2..ea07cd980d8 100644 --- a/src/Serializer/Tests/Fixtures/ApiResource/NonCloneableDummy.php +++ b/src/Serializer/Tests/Fixtures/ApiResource/NonCloneableDummy.php @@ -35,7 +35,7 @@ class NonCloneableDummy */ #[ApiProperty(iris: ['http://schema.org/name'])] #[Assert\NotBlank] - private $name; + private string $name; public function getId() { diff --git a/src/Serializer/Tests/Fixtures/ApiResource/RelatedDummy.php b/src/Serializer/Tests/Fixtures/ApiResource/RelatedDummy.php index dfdd5e0c93f..28583136f78 100644 --- a/src/Serializer/Tests/Fixtures/ApiResource/RelatedDummy.php +++ b/src/Serializer/Tests/Fixtures/ApiResource/RelatedDummy.php @@ -70,10 +70,6 @@ class RelatedDummy implements \Stringable #[Groups(['friends'])] public ?bool $dummyBoolean = null; - public function __construct() - { - } - public function getId() { return $this->id; @@ -119,10 +115,7 @@ public function isDummyBoolean(): ?bool return $this->dummyBoolean; } - /** - * @param bool $dummyBoolean - */ - public function setDummyBoolean($dummyBoolean): void + public function setDummyBoolean(?bool $dummyBoolean): void { $this->dummyBoolean = $dummyBoolean; } diff --git a/src/Serializer/Tests/SerializerFilterContextBuilderTest.php b/src/Serializer/Tests/SerializerFilterContextBuilderTest.php index 41b7da79a94..fb2948dd5fe 100644 --- a/src/Serializer/Tests/SerializerFilterContextBuilderTest.php +++ b/src/Serializer/Tests/SerializerFilterContextBuilderTest.php @@ -109,7 +109,7 @@ public function testCreateFromRequestWithoutFilters(): void 'operation_name' => 'get', ]; - $resourceMetadata = $this->getMetadataWithFilter(DummyGroup::class, null); + $resourceMetadata = $this->getMetadataWithFilter(DummyGroup::class); $decoratedProphecy = $this->prophesize(SerializerContextBuilderInterface::class); $decoratedProphecy->createFromRequest($request, false, $attributes)->willReturn([])->shouldBeCalled(); diff --git a/src/State/Pagination/Pagination.php b/src/State/Pagination/Pagination.php index 28c034bef0f..90b61a96541 100644 --- a/src/State/Pagination/Pagination.php +++ b/src/State/Pagination/Pagination.php @@ -176,7 +176,7 @@ public function isEnabled(?Operation $operation = null, array $context = []): bo /** * Is the pagination enabled for GraphQL? */ - public function isGraphQlEnabled(?Operation $operation = null, array $context = []): bool + public function isGraphQlEnabled(?Operation $operation = null): bool { return $this->getGraphQlEnabled($operation); } diff --git a/src/State/Provider/DeserializeProvider.php b/src/State/Provider/DeserializeProvider.php index 6390c86bcd0..d0a6ca0fc4f 100644 --- a/src/State/Provider/DeserializeProvider.php +++ b/src/State/Provider/DeserializeProvider.php @@ -117,7 +117,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c if ($exception->canUseMessageForUser()) { $parameters['hint'] = $exception->getMessage(); } - $violations->add(new ConstraintViolation($this->translator->trans($message, ['{{ type }}' => implode('|', $expectedTypes)], 'validators'), $message, $parameters, null, $exception->getPath(), null, null, (string) Type::INVALID_TYPE_ERROR)); + $violations->add(new ConstraintViolation($this->translator->trans($message, ['{{ type }}' => implode('|', $expectedTypes)], 'validators'), $message, $parameters, null, $exception->getPath(), null, null, Type::INVALID_TYPE_ERROR)); } if (0 !== \count($violations)) { throw new ValidationException($violations); diff --git a/src/State/Tests/CallableProcessorTest.php b/src/State/Tests/CallableProcessorTest.php index 43d05685895..c1b8082c191 100644 --- a/src/State/Tests/CallableProcessorTest.php +++ b/src/State/Tests/CallableProcessorTest.php @@ -31,7 +31,7 @@ public function testNoProcessor(): void public function testCallable(): void { - $operation = new Get(name: 'hello', processor: static fn () => ['ok']); + $operation = new Get(name: 'hello', processor: static fn (): array => ['ok']); $this->assertEquals((new CallableProcessor())->process(new \stdClass(), $operation), ['ok']); } diff --git a/src/State/Tests/CallableProviderTest.php b/src/State/Tests/CallableProviderTest.php index 6b4d7de36f4..f13f0d75ed1 100644 --- a/src/State/Tests/CallableProviderTest.php +++ b/src/State/Tests/CallableProviderTest.php @@ -32,7 +32,7 @@ public function testNoProvider(): void public function testCallable(): void { - $operation = new Get(name: 'hello', provider: static fn () => ['ok']); + $operation = new Get(name: 'hello', provider: static fn (): array => ['ok']); $this->assertEquals((new CallableProvider())->provide($operation), ['ok']); } diff --git a/src/State/Tests/ParameterProviderTest.php b/src/State/Tests/ParameterProviderTest.php index 5f649da2827..cf18654f1ad 100644 --- a/src/State/Tests/ParameterProviderTest.php +++ b/src/State/Tests/ParameterProviderTest.php @@ -14,7 +14,6 @@ namespace ApiPlatform\State\Tests; use ApiPlatform\Metadata\Get; -use ApiPlatform\Metadata\Operation; use ApiPlatform\Metadata\Parameter; use ApiPlatform\Metadata\Parameters; use ApiPlatform\Metadata\QueryParameter; @@ -34,7 +33,7 @@ public function get(string $id) { if ('test' === $id) { return new class implements ParameterProviderInterface { - public function provide(Parameter $parameter, array $parameters = [], array $context = []): Operation + public function provide(Parameter $parameter, array $parameters = [], array $context = []): Get { return new Get(name: 'ok'); } diff --git a/src/State/Tests/Provider/DeserializeProviderTest.php b/src/State/Tests/Provider/DeserializeProviderTest.php index b0f29c11413..199cddffa4e 100644 --- a/src/State/Tests/Provider/DeserializeProviderTest.php +++ b/src/State/Tests/Provider/DeserializeProviderTest.php @@ -188,7 +188,7 @@ public function testDeserializeSetsObjectToPopulateWhenContextIsTrue(): void 'test', \stdClass::class, 'format', - $this->callback(function (array $context) use ($objectToPopulate) { + $this->callback(function (array $context) use ($objectToPopulate): true { $this->assertArrayHasKey(AbstractNormalizer::OBJECT_TO_POPULATE, $context); $this->assertSame($objectToPopulate, $context[AbstractNormalizer::OBJECT_TO_POPULATE]); @@ -219,7 +219,7 @@ public function testDeserializeDoesNotSetObjectToPopulateWhenContextIsFalse(): v 'test', \stdClass::class, 'format', - $this->callback(function (array $context) { + $this->callback(function (array $context): true { $this->assertArrayNotHasKey(AbstractNormalizer::OBJECT_TO_POPULATE, $context); return true; diff --git a/src/State/Util/ParameterParserTrait.php b/src/State/Util/ParameterParserTrait.php index bd8a26b950a..1dffe4522e6 100644 --- a/src/State/Util/ParameterParserTrait.php +++ b/src/State/Util/ParameterParserTrait.php @@ -94,7 +94,7 @@ private function extractParameterValues(Parameter $parameter, array $values): mi return $value; } - $isCollectionType = static fn ($t) => $t instanceof CollectionType; + $isCollectionType = static fn ($t): bool => $t instanceof CollectionType; $isCollection = $parameter->getNativeType()?->isSatisfiedBy($isCollectionType) ?? false; // type-info 7.2 diff --git a/src/Symfony/Action/DocumentationAction.php b/src/Symfony/Action/DocumentationAction.php index 891d5d83d4c..3f01f467713 100644 --- a/src/Symfony/Action/DocumentationAction.php +++ b/src/Symfony/Action/DocumentationAction.php @@ -56,10 +56,7 @@ public function __construct( $this->negotiator = $negotiator ?? new Negotiator(); } - /** - * @return DocumentationInterface|OpenApi|Response - */ - public function __invoke(?Request $request = null) + public function __invoke(?Request $request = null): Documentation|OpenApi|Response|DocumentationInterface { if (false === $this->docsEnabled) { throw new NotFoundHttpException(); @@ -129,7 +126,7 @@ private function getHydraDocumentation(array $context, Request $request): Docume class: Documentation::class, read: true, serialize: true, - provider: fn () => new Documentation($this->resourceNameCollectionFactory->create(), $this->title, $this->description, $this->version) + provider: fn (): Documentation => new Documentation($this->resourceNameCollectionFactory->create(), $this->title, $this->description, $this->version) ); return $this->processor->process($this->provider->provide($operation, [], $context), $operation, [], $context); diff --git a/src/Symfony/Action/NotFoundAction.php b/src/Symfony/Action/NotFoundAction.php index 8d183f3c9b2..fe4edc93d15 100644 --- a/src/Symfony/Action/NotFoundAction.php +++ b/src/Symfony/Action/NotFoundAction.php @@ -20,7 +20,7 @@ */ final class NotFoundAction { - public function __invoke(): void + public function __invoke(): never { throw new NotFoundHttpException(); } diff --git a/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php b/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php index 1f2f6689b96..9c63f8d70ad 100644 --- a/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php +++ b/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php @@ -176,7 +176,7 @@ public function load(array $configs, ContainerBuilder $container): void $this->registerOAuthConfiguration($container, $config); $this->registerOpenApiConfiguration($container, $config, $loader); $this->registerSwaggerConfiguration($container, $config, $loader); - $this->registerJsonApiConfiguration($formats, $loader, $config); + $this->registerJsonApiConfiguration($formats, $loader); $this->registerJsonLdHydraConfiguration($container, $formats, $loader, $config); $this->registerJsonHalConfiguration($formats, $loader); $this->registerJsonProblemConfiguration($errorFormats, $loader); @@ -193,7 +193,7 @@ public function load(array $configs, ContainerBuilder $container): void $this->registerSecurityConfiguration($container, $config, $loader); $this->registerMakerConfiguration($container, $config, $loader); $this->registerArgumentResolverConfiguration($loader); - $this->registerLinkSecurityConfiguration($loader, $config); + $this->registerLinkSecurityConfiguration($loader); $this->registerJsonStreamerConfiguration($container, $loader, $formats, $config); // TranslationExtractCommand was introduced in framework-bundle/7.3 with the object mapper service @@ -676,7 +676,7 @@ private function registerSwaggerConfiguration(ContainerBuilder $container, array $container->setParameter('api_platform.swagger_ui.extra_configuration', $config['openapi']['swagger_ui_extra_configuration'] ?: $config['swagger']['swagger_ui_extra_configuration']); } - private function registerJsonApiConfiguration(array $formats, PhpFileLoader $loader, array $config): void + private function registerJsonApiConfiguration(array $formats, PhpFileLoader $loader): void { if (!isset($formats['jsonapi'])) { return; @@ -1070,7 +1070,7 @@ private function registerArgumentResolverConfiguration(PhpFileLoader $loader): v $loader->load('argument_resolver.php'); } - private function registerLinkSecurityConfiguration(PhpFileLoader $loader, array $config): void + private function registerLinkSecurityConfiguration(PhpFileLoader $loader): void { $loader->load('link_security.php'); } diff --git a/src/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPass.php b/src/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPass.php index 45485824678..21b6dbf8c54 100644 --- a/src/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPass.php +++ b/src/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPass.php @@ -42,7 +42,7 @@ public function process(ContainerBuilder $container): void { $resourceClassDirectories = $container->getParameter('api_platform.resource_class_directories'); - foreach (ReflectionClassRecursiveIterator::getReflectionClassesFromDirectories($resourceClassDirectories) as $className => $reflectionClass) { + foreach (ReflectionClassRecursiveIterator::getReflectionClassesFromDirectories($resourceClassDirectories) as $reflectionClass) { $this->createFilterDefinitions($reflectionClass, $container); } } diff --git a/src/Symfony/Bundle/Resources/config/api.php b/src/Symfony/Bundle/Resources/config/api.php index c1685a0c4ae..7414d5e1568 100644 --- a/src/Symfony/Bundle/Resources/config/api.php +++ b/src/Symfony/Bundle/Resources/config/api.php @@ -49,7 +49,7 @@ use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; -return function (ContainerConfigurator $container) { +return function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.action.not_found', NotFoundAction::class) diff --git a/src/Symfony/Bundle/Resources/config/argument_resolver.php b/src/Symfony/Bundle/Resources/config/argument_resolver.php index 46c86b8499c..fef00438f95 100644 --- a/src/Symfony/Bundle/Resources/config/argument_resolver.php +++ b/src/Symfony/Bundle/Resources/config/argument_resolver.php @@ -15,7 +15,7 @@ use ApiPlatform\Symfony\Bundle\ArgumentResolver\PayloadArgumentResolver; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.argument_resolver.payload', PayloadArgumentResolver::class) diff --git a/src/Symfony/Bundle/Resources/config/data_collector.php b/src/Symfony/Bundle/Resources/config/data_collector.php index c7a5ee16947..5f9fab83580 100644 --- a/src/Symfony/Bundle/Resources/config/data_collector.php +++ b/src/Symfony/Bundle/Resources/config/data_collector.php @@ -15,7 +15,7 @@ use ApiPlatform\Symfony\Bundle\DataCollector\RequestDataCollector; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.data_collector.request', RequestDataCollector::class) diff --git a/src/Symfony/Bundle/Resources/config/debug.php b/src/Symfony/Bundle/Resources/config/debug.php index 86fe34593d9..5b1f3b85c42 100644 --- a/src/Symfony/Bundle/Resources/config/debug.php +++ b/src/Symfony/Bundle/Resources/config/debug.php @@ -17,7 +17,7 @@ use Symfony\Component\VarDumper\Cloner\VarCloner; use Symfony\Component\VarDumper\Dumper\CliDumper; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('debug.var_dumper.cloner', VarCloner::class); diff --git a/src/Symfony/Bundle/Resources/config/doctrine_mongodb_odm.php b/src/Symfony/Bundle/Resources/config/doctrine_mongodb_odm.php index 17d22bbf589..d412875243b 100644 --- a/src/Symfony/Bundle/Resources/config/doctrine_mongodb_odm.php +++ b/src/Symfony/Bundle/Resources/config/doctrine_mongodb_odm.php @@ -35,7 +35,7 @@ use ApiPlatform\Doctrine\Odm\State\LinksHandler; use Doctrine\Persistence\Mapping\ClassMetadataFactory; -return function (ContainerConfigurator $container) { +return function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.doctrine_mongodb.odm.default_document_manager.property_info_extractor', DoctrineExtractor::class) diff --git a/src/Symfony/Bundle/Resources/config/doctrine_odm_mercure_publisher.php b/src/Symfony/Bundle/Resources/config/doctrine_odm_mercure_publisher.php index 6cb90c9dcf7..aa01ff6e6ed 100644 --- a/src/Symfony/Bundle/Resources/config/doctrine_odm_mercure_publisher.php +++ b/src/Symfony/Bundle/Resources/config/doctrine_odm_mercure_publisher.php @@ -15,7 +15,7 @@ use ApiPlatform\Symfony\Doctrine\EventListener\PublishMercureUpdatesListener; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.doctrine_mongodb.odm.listener.mercure.publish', PublishMercureUpdatesListener::class) diff --git a/src/Symfony/Bundle/Resources/config/doctrine_orm.php b/src/Symfony/Bundle/Resources/config/doctrine_orm.php index 4a2c6772e3d..4a1f5a97943 100644 --- a/src/Symfony/Bundle/Resources/config/doctrine_orm.php +++ b/src/Symfony/Bundle/Resources/config/doctrine_orm.php @@ -41,7 +41,7 @@ use ApiPlatform\Doctrine\Orm\State\LinksHandler; use Doctrine\Persistence\Mapping\ClassMetadataFactory; -return function (ContainerConfigurator $container) { +return function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.doctrine.metadata_factory', ClassMetadataFactory::class)->factory([service('doctrine.orm.default_entity_manager'), 'getMetadataFactory']); diff --git a/src/Symfony/Bundle/Resources/config/doctrine_orm_http_cache_purger.php b/src/Symfony/Bundle/Resources/config/doctrine_orm_http_cache_purger.php index cce74a00600..e24a45ced19 100644 --- a/src/Symfony/Bundle/Resources/config/doctrine_orm_http_cache_purger.php +++ b/src/Symfony/Bundle/Resources/config/doctrine_orm_http_cache_purger.php @@ -15,7 +15,7 @@ use ApiPlatform\Symfony\Doctrine\EventListener\PurgeHttpCacheListener; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.doctrine.listener.http_cache.purge', PurgeHttpCacheListener::class) diff --git a/src/Symfony/Bundle/Resources/config/doctrine_orm_mercure_publisher.php b/src/Symfony/Bundle/Resources/config/doctrine_orm_mercure_publisher.php index 79cb7ec1cd9..a690f107756 100644 --- a/src/Symfony/Bundle/Resources/config/doctrine_orm_mercure_publisher.php +++ b/src/Symfony/Bundle/Resources/config/doctrine_orm_mercure_publisher.php @@ -15,7 +15,7 @@ use ApiPlatform\Symfony\Doctrine\EventListener\PublishMercureUpdatesListener; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.doctrine.orm.listener.mercure.publish', PublishMercureUpdatesListener::class) diff --git a/src/Symfony/Bundle/Resources/config/elasticsearch.php b/src/Symfony/Bundle/Resources/config/elasticsearch.php index 212fa22343b..907b068ac6b 100644 --- a/src/Symfony/Bundle/Resources/config/elasticsearch.php +++ b/src/Symfony/Bundle/Resources/config/elasticsearch.php @@ -26,7 +26,7 @@ use ApiPlatform\Elasticsearch\State\CollectionProvider; use ApiPlatform\Elasticsearch\State\ItemProvider; -return function (ContainerConfigurator $container) { +return function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.elasticsearch.name_converter.inner_fields', InnerFieldsNameConverter::class) diff --git a/src/Symfony/Bundle/Resources/config/filter.php b/src/Symfony/Bundle/Resources/config/filter.php index 6d961581bfc..7e2e8ba8f74 100644 --- a/src/Symfony/Bundle/Resources/config/filter.php +++ b/src/Symfony/Bundle/Resources/config/filter.php @@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\ServiceLocator; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.filter_locator', ServiceLocator::class) diff --git a/src/Symfony/Bundle/Resources/config/graphql.php b/src/Symfony/Bundle/Resources/config/graphql.php index 0453cc84485..f26d8f18d42 100644 --- a/src/Symfony/Bundle/Resources/config/graphql.php +++ b/src/Symfony/Bundle/Resources/config/graphql.php @@ -48,7 +48,7 @@ use ApiPlatform\Symfony\Bundle\Command\GraphQlExportCommand; use Symfony\Component\DependencyInjection\ServiceLocator; -return function (ContainerConfigurator $container) { +return function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.graphql.executor', Executor::class) diff --git a/src/Symfony/Bundle/Resources/config/graphql/security.php b/src/Symfony/Bundle/Resources/config/graphql/security.php index a056bbc4fb4..de937e926a0 100644 --- a/src/Symfony/Bundle/Resources/config/graphql/security.php +++ b/src/Symfony/Bundle/Resources/config/graphql/security.php @@ -15,7 +15,7 @@ use ApiPlatform\Symfony\Security\State\AccessCheckerProvider; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.graphql.state_provider.access_checker', AccessCheckerProvider::class) diff --git a/src/Symfony/Bundle/Resources/config/graphql/validator.php b/src/Symfony/Bundle/Resources/config/graphql/validator.php index 5d4a0a64988..6d2d1f385d9 100644 --- a/src/Symfony/Bundle/Resources/config/graphql/validator.php +++ b/src/Symfony/Bundle/Resources/config/graphql/validator.php @@ -15,7 +15,7 @@ use ApiPlatform\Symfony\Validator\State\ValidateProvider; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.graphql.state_provider.validate', ValidateProvider::class) diff --git a/src/Symfony/Bundle/Resources/config/graphql_mercure.php b/src/Symfony/Bundle/Resources/config/graphql_mercure.php index cd87445ee34..368d8001565 100644 --- a/src/Symfony/Bundle/Resources/config/graphql_mercure.php +++ b/src/Symfony/Bundle/Resources/config/graphql_mercure.php @@ -15,7 +15,7 @@ use ApiPlatform\GraphQl\Subscription\MercureSubscriptionIriGenerator; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.graphql.subscription.mercure_iri_generator', MercureSubscriptionIriGenerator::class) diff --git a/src/Symfony/Bundle/Resources/config/hal.php b/src/Symfony/Bundle/Resources/config/hal.php index 933eaff113e..1e8bd69113e 100644 --- a/src/Symfony/Bundle/Resources/config/hal.php +++ b/src/Symfony/Bundle/Resources/config/hal.php @@ -20,7 +20,7 @@ use ApiPlatform\Hal\Serializer\ObjectNormalizer; use ApiPlatform\Serializer\JsonEncoder; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.hal.json_schema.schema_factory', SchemaFactory::class) diff --git a/src/Symfony/Bundle/Resources/config/http_cache.php b/src/Symfony/Bundle/Resources/config/http_cache.php index 98db9a5df77..51074162b43 100644 --- a/src/Symfony/Bundle/Resources/config/http_cache.php +++ b/src/Symfony/Bundle/Resources/config/http_cache.php @@ -15,7 +15,7 @@ use ApiPlatform\HttpCache\State\AddHeadersProcessor; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.http_cache.processor.add_headers', AddHeadersProcessor::class) diff --git a/src/Symfony/Bundle/Resources/config/http_cache_purger.php b/src/Symfony/Bundle/Resources/config/http_cache_purger.php index 1637f91ea45..646575011a1 100644 --- a/src/Symfony/Bundle/Resources/config/http_cache_purger.php +++ b/src/Symfony/Bundle/Resources/config/http_cache_purger.php @@ -17,7 +17,7 @@ use ApiPlatform\HttpCache\VarnishPurger; use ApiPlatform\HttpCache\VarnishXKeyPurger; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->alias('api_platform.http_cache.purger.varnish', 'api_platform.http_cache.purger.varnish.ban'); diff --git a/src/Symfony/Bundle/Resources/config/hydra.php b/src/Symfony/Bundle/Resources/config/hydra.php index f015e531d7d..4b421b27682 100644 --- a/src/Symfony/Bundle/Resources/config/hydra.php +++ b/src/Symfony/Bundle/Resources/config/hydra.php @@ -22,7 +22,7 @@ use ApiPlatform\Hydra\Serializer\HydraPrefixNameConverter; use ApiPlatform\Hydra\Serializer\PartialCollectionViewNormalizer; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.hydra.json_schema.schema_factory', SchemaFactory::class) diff --git a/src/Symfony/Bundle/Resources/config/json_schema.php b/src/Symfony/Bundle/Resources/config/json_schema.php index ab64a31e40d..74b706b1ad8 100644 --- a/src/Symfony/Bundle/Resources/config/json_schema.php +++ b/src/Symfony/Bundle/Resources/config/json_schema.php @@ -20,7 +20,7 @@ use ApiPlatform\JsonSchema\SchemaFactory; use ApiPlatform\JsonSchema\SchemaFactoryInterface; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.json_schema.schema_factory', SchemaFactory::class) diff --git a/src/Symfony/Bundle/Resources/config/json_streamer/common.php b/src/Symfony/Bundle/Resources/config/json_streamer/common.php index 756c16898f2..21165006be7 100644 --- a/src/Symfony/Bundle/Resources/config/json_streamer/common.php +++ b/src/Symfony/Bundle/Resources/config/json_streamer/common.php @@ -22,7 +22,7 @@ use Symfony\Component\JsonStreamer\JsonStreamWriter; use Symfony\Component\JsonStreamer\StreamerDumper; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.jsonld.json_streamer.stream_writer', JsonStreamWriter::class) diff --git a/src/Symfony/Bundle/Resources/config/json_streamer/events.php b/src/Symfony/Bundle/Resources/config/json_streamer/events.php index e5addb83c23..3a7a2882812 100644 --- a/src/Symfony/Bundle/Resources/config/json_streamer/events.php +++ b/src/Symfony/Bundle/Resources/config/json_streamer/events.php @@ -20,7 +20,7 @@ use ApiPlatform\Symfony\EventListener\JsonStreamerDeserializeListener; use ApiPlatform\Symfony\EventListener\JsonStreamerSerializeListener; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.jsonld.state_processor.json_streamer', HydraJsonStreamerProcessor::class) diff --git a/src/Symfony/Bundle/Resources/config/json_streamer/hydra.php b/src/Symfony/Bundle/Resources/config/json_streamer/hydra.php index 17fe3e72c08..9bb6317f64b 100644 --- a/src/Symfony/Bundle/Resources/config/json_streamer/hydra.php +++ b/src/Symfony/Bundle/Resources/config/json_streamer/hydra.php @@ -16,7 +16,7 @@ use ApiPlatform\Hydra\State\JsonStreamerProcessor; use ApiPlatform\Hydra\State\JsonStreamerProvider; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.jsonld.state_processor.json_streamer', JsonStreamerProcessor::class) diff --git a/src/Symfony/Bundle/Resources/config/json_streamer/json.php b/src/Symfony/Bundle/Resources/config/json_streamer/json.php index 40831d878fa..6b3e9e28207 100644 --- a/src/Symfony/Bundle/Resources/config/json_streamer/json.php +++ b/src/Symfony/Bundle/Resources/config/json_streamer/json.php @@ -16,7 +16,7 @@ use ApiPlatform\Serializer\State\JsonStreamerProcessor; use ApiPlatform\Serializer\State\JsonStreamerProvider; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.state_processor.json_streamer', JsonStreamerProcessor::class) diff --git a/src/Symfony/Bundle/Resources/config/jsonapi.php b/src/Symfony/Bundle/Resources/config/jsonapi.php index c4e7c895bb7..bc8ef6e7f2a 100644 --- a/src/Symfony/Bundle/Resources/config/jsonapi.php +++ b/src/Symfony/Bundle/Resources/config/jsonapi.php @@ -23,7 +23,7 @@ use ApiPlatform\JsonApi\Serializer\ReservedAttributeNameConverter; use ApiPlatform\Serializer\JsonEncoder; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.jsonapi.json_schema.schema_factory', SchemaFactory::class) diff --git a/src/Symfony/Bundle/Resources/config/jsonld.php b/src/Symfony/Bundle/Resources/config/jsonld.php index 33859c30723..40c9ae6b9c4 100644 --- a/src/Symfony/Bundle/Resources/config/jsonld.php +++ b/src/Symfony/Bundle/Resources/config/jsonld.php @@ -20,7 +20,7 @@ use ApiPlatform\Serializer\JsonEncoder; use ApiPlatform\Symfony\Validator\Serializer\ValidationExceptionNormalizer; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.jsonld.context_builder', ContextBuilder::class) diff --git a/src/Symfony/Bundle/Resources/config/link_security.php b/src/Symfony/Bundle/Resources/config/link_security.php index 6309adf93ba..e0afd0ba8cf 100644 --- a/src/Symfony/Bundle/Resources/config/link_security.php +++ b/src/Symfony/Bundle/Resources/config/link_security.php @@ -15,7 +15,7 @@ use ApiPlatform\State\ParameterProvider\ReadLinkParameterProvider; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.state_provider.read_link', ReadLinkParameterProvider::class) diff --git a/src/Symfony/Bundle/Resources/config/maker.php b/src/Symfony/Bundle/Resources/config/maker.php index 9eef4dd5dde..a7ecab9f93d 100644 --- a/src/Symfony/Bundle/Resources/config/maker.php +++ b/src/Symfony/Bundle/Resources/config/maker.php @@ -17,7 +17,7 @@ use ApiPlatform\Symfony\Maker\MakeStateProcessor; use ApiPlatform\Symfony\Maker\MakeStateProvider; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.maker.command.state_processor', MakeStateProcessor::class) diff --git a/src/Symfony/Bundle/Resources/config/mcp/events.php b/src/Symfony/Bundle/Resources/config/mcp/events.php index 3bb7db5372b..11a72b2465a 100644 --- a/src/Symfony/Bundle/Resources/config/mcp/events.php +++ b/src/Symfony/Bundle/Resources/config/mcp/events.php @@ -17,7 +17,7 @@ use ApiPlatform\Mcp\State\StructuredContentProcessor; use ApiPlatform\State\Processor\WriteProcessor; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.mcp.state_processor.write', WriteProcessor::class) diff --git a/src/Symfony/Bundle/Resources/config/mcp/mcp.php b/src/Symfony/Bundle/Resources/config/mcp/mcp.php index 8ffdffaea8c..a26fd9a75f0 100644 --- a/src/Symfony/Bundle/Resources/config/mcp/mcp.php +++ b/src/Symfony/Bundle/Resources/config/mcp/mcp.php @@ -18,7 +18,7 @@ use ApiPlatform\Mcp\Routing\IriConverter; use ApiPlatform\Mcp\State\ToolProvider; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.mcp.loader', Loader::class) diff --git a/src/Symfony/Bundle/Resources/config/mcp/state.php b/src/Symfony/Bundle/Resources/config/mcp/state.php index 85525d4b779..d4eac866f2a 100644 --- a/src/Symfony/Bundle/Resources/config/mcp/state.php +++ b/src/Symfony/Bundle/Resources/config/mcp/state.php @@ -17,7 +17,7 @@ use ApiPlatform\Mcp\State\StructuredContentProcessor; use ApiPlatform\State\Processor\WriteProcessor; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.mcp.state_processor.write', WriteProcessor::class) diff --git a/src/Symfony/Bundle/Resources/config/messenger.php b/src/Symfony/Bundle/Resources/config/messenger.php index 9424cdf3b4f..c15836a4f07 100644 --- a/src/Symfony/Bundle/Resources/config/messenger.php +++ b/src/Symfony/Bundle/Resources/config/messenger.php @@ -16,7 +16,7 @@ use ApiPlatform\Symfony\Messenger\Metadata\MessengerResourceMetadataCollectionFactory; use ApiPlatform\Symfony\Messenger\Processor; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->alias('api_platform.message_bus', 'messenger.default_bus'); diff --git a/src/Symfony/Bundle/Resources/config/metadata/links.php b/src/Symfony/Bundle/Resources/config/metadata/links.php index b05f49594c1..faf7d725cd2 100644 --- a/src/Symfony/Bundle/Resources/config/metadata/links.php +++ b/src/Symfony/Bundle/Resources/config/metadata/links.php @@ -15,7 +15,7 @@ use ApiPlatform\Metadata\Resource\Factory\LinkFactory; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.metadata.resource.link_factory', LinkFactory::class) diff --git a/src/Symfony/Bundle/Resources/config/metadata/mutator.php b/src/Symfony/Bundle/Resources/config/metadata/mutator.php index e9290ecde29..e2373097f99 100644 --- a/src/Symfony/Bundle/Resources/config/metadata/mutator.php +++ b/src/Symfony/Bundle/Resources/config/metadata/mutator.php @@ -16,7 +16,7 @@ use ApiPlatform\Metadata\Mutator\OperationMutatorCollection; use ApiPlatform\Metadata\Mutator\ResourceMutatorCollection; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.metadata.mutator_collection.resource', ResourceMutatorCollection::class); diff --git a/src/Symfony/Bundle/Resources/config/metadata/operation.php b/src/Symfony/Bundle/Resources/config/metadata/operation.php index ef8987a809b..82ec16b2aa9 100644 --- a/src/Symfony/Bundle/Resources/config/metadata/operation.php +++ b/src/Symfony/Bundle/Resources/config/metadata/operation.php @@ -17,7 +17,7 @@ use ApiPlatform\Metadata\Operation\Factory\OperationMetadataFactory; use ApiPlatform\Metadata\Operation\Factory\OperationMetadataFactoryInterface; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.metadata.operation.metadata_factory', OperationMetadataFactory::class) diff --git a/src/Symfony/Bundle/Resources/config/metadata/php.php b/src/Symfony/Bundle/Resources/config/metadata/php.php index 7dbaa00ea3c..9273b835d9f 100644 --- a/src/Symfony/Bundle/Resources/config/metadata/php.php +++ b/src/Symfony/Bundle/Resources/config/metadata/php.php @@ -15,7 +15,7 @@ use ApiPlatform\Metadata\Extractor\PhpFileResourceExtractor; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.metadata.resource_extractor.php_file', PhpFileResourceExtractor::class) diff --git a/src/Symfony/Bundle/Resources/config/metadata/php_doc.php b/src/Symfony/Bundle/Resources/config/metadata/php_doc.php index 50e40c3e5b4..18fe4f97684 100644 --- a/src/Symfony/Bundle/Resources/config/metadata/php_doc.php +++ b/src/Symfony/Bundle/Resources/config/metadata/php_doc.php @@ -15,7 +15,7 @@ use ApiPlatform\Metadata\Resource\Factory\PhpDocResourceMetadataCollectionFactory; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.metadata.resource.metadata_collection_factory.php_doc', PhpDocResourceMetadataCollectionFactory::class) diff --git a/src/Symfony/Bundle/Resources/config/metadata/property.php b/src/Symfony/Bundle/Resources/config/metadata/property.php index bfcc0f359d7..8470a21b835 100644 --- a/src/Symfony/Bundle/Resources/config/metadata/property.php +++ b/src/Symfony/Bundle/Resources/config/metadata/property.php @@ -22,7 +22,7 @@ use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface; use ApiPlatform\Metadata\Property\Factory\SerializerPropertyMetadataFactory; -return function (ContainerConfigurator $container) { +return function (ContainerConfigurator $container): void { $services = $container->services(); $services->alias('api_platform.metadata.property.metadata_factory', 'api_platform.metadata.property.metadata_factory.xml'); diff --git a/src/Symfony/Bundle/Resources/config/metadata/property_name.php b/src/Symfony/Bundle/Resources/config/metadata/property_name.php index 75a3962ef43..21d24a8ef6d 100644 --- a/src/Symfony/Bundle/Resources/config/metadata/property_name.php +++ b/src/Symfony/Bundle/Resources/config/metadata/property_name.php @@ -19,7 +19,7 @@ use ApiPlatform\Metadata\Property\Factory\PropertyInfoPropertyNameCollectionFactory; use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->alias('api_platform.metadata.property.name_collection_factory', 'api_platform.metadata.property.name_collection_factory.property_info'); diff --git a/src/Symfony/Bundle/Resources/config/metadata/resource.php b/src/Symfony/Bundle/Resources/config/metadata/resource.php index 0e0b3c088d4..65cf5eb783b 100644 --- a/src/Symfony/Bundle/Resources/config/metadata/resource.php +++ b/src/Symfony/Bundle/Resources/config/metadata/resource.php @@ -32,7 +32,7 @@ use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use ApiPlatform\Metadata\Resource\Factory\UriTemplateResourceMetadataCollectionFactory; -return function (ContainerConfigurator $container) { +return function (ContainerConfigurator $container): void { $services = $container->services(); $services->alias('api_platform.metadata.resource.metadata_collection_factory', 'api_platform.metadata.resource.metadata_collection_factory.attributes'); diff --git a/src/Symfony/Bundle/Resources/config/metadata/resource_name.php b/src/Symfony/Bundle/Resources/config/metadata/resource_name.php index bea58a3f06c..07703090136 100644 --- a/src/Symfony/Bundle/Resources/config/metadata/resource_name.php +++ b/src/Symfony/Bundle/Resources/config/metadata/resource_name.php @@ -21,7 +21,7 @@ use ApiPlatform\Metadata\Resource\Factory\PhpFileResourceNameCollectionFactory; use ApiPlatform\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface; -return function (ContainerConfigurator $container) { +return function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.cache.metadata.resource') diff --git a/src/Symfony/Bundle/Resources/config/metadata/validator.php b/src/Symfony/Bundle/Resources/config/metadata/validator.php index f663d3f60c8..47ae0776dd3 100644 --- a/src/Symfony/Bundle/Resources/config/metadata/validator.php +++ b/src/Symfony/Bundle/Resources/config/metadata/validator.php @@ -29,7 +29,7 @@ use ApiPlatform\Symfony\Validator\Metadata\Property\Restriction\PropertySchemaUniqueRestriction; use ApiPlatform\Symfony\Validator\Metadata\Property\ValidatorPropertyMetadataFactory; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.metadata.property.metadata_factory.validator', ValidatorPropertyMetadataFactory::class) diff --git a/src/Symfony/Bundle/Resources/config/metadata/xml.php b/src/Symfony/Bundle/Resources/config/metadata/xml.php index 105943590dc..7ccaafd9301 100644 --- a/src/Symfony/Bundle/Resources/config/metadata/xml.php +++ b/src/Symfony/Bundle/Resources/config/metadata/xml.php @@ -16,7 +16,7 @@ use ApiPlatform\Metadata\Extractor\XmlPropertyExtractor; use ApiPlatform\Metadata\Extractor\XmlResourceExtractor; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.metadata.resource_extractor.xml', XmlResourceExtractor::class) diff --git a/src/Symfony/Bundle/Resources/config/metadata/yaml.php b/src/Symfony/Bundle/Resources/config/metadata/yaml.php index 346b579970d..9e2e1367e29 100644 --- a/src/Symfony/Bundle/Resources/config/metadata/yaml.php +++ b/src/Symfony/Bundle/Resources/config/metadata/yaml.php @@ -20,7 +20,7 @@ use ApiPlatform\Metadata\Resource\Factory\ExtractorResourceMetadataCollectionFactory; use ApiPlatform\Metadata\Resource\Factory\ExtractorResourceNameCollectionFactory; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.metadata.resource_extractor.yaml', YamlResourceExtractor::class) diff --git a/src/Symfony/Bundle/Resources/config/openapi.php b/src/Symfony/Bundle/Resources/config/openapi.php index b68eb55ed4b..f5de0339bab 100644 --- a/src/Symfony/Bundle/Resources/config/openapi.php +++ b/src/Symfony/Bundle/Resources/config/openapi.php @@ -26,7 +26,7 @@ use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Component\Serializer\Serializer; -return function (ContainerConfigurator $container) { +return function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.openapi.normalizer', OpenApiNormalizer::class) diff --git a/src/Symfony/Bundle/Resources/config/openapi/yaml.php b/src/Symfony/Bundle/Resources/config/openapi/yaml.php index 8454f84dab0..d513ecc9500 100644 --- a/src/Symfony/Bundle/Resources/config/openapi/yaml.php +++ b/src/Symfony/Bundle/Resources/config/openapi/yaml.php @@ -15,7 +15,7 @@ use ApiPlatform\Serializer\YamlEncoder; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.yamlopenapi.encoder', YamlEncoder::class) diff --git a/src/Symfony/Bundle/Resources/config/problem.php b/src/Symfony/Bundle/Resources/config/problem.php index ebb4adad684..672ac24921d 100644 --- a/src/Symfony/Bundle/Resources/config/problem.php +++ b/src/Symfony/Bundle/Resources/config/problem.php @@ -16,7 +16,7 @@ use ApiPlatform\Serializer\JsonEncoder; use ApiPlatform\Symfony\Validator\Serializer\ValidationExceptionNormalizer; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.problem.encoder', JsonEncoder::class) diff --git a/src/Symfony/Bundle/Resources/config/ramsey_uuid.php b/src/Symfony/Bundle/Resources/config/ramsey_uuid.php index 990d7aadc9e..bad58a89160 100644 --- a/src/Symfony/Bundle/Resources/config/ramsey_uuid.php +++ b/src/Symfony/Bundle/Resources/config/ramsey_uuid.php @@ -16,7 +16,7 @@ use ApiPlatform\RamseyUuid\Serializer\UuidDenormalizer; use ApiPlatform\RamseyUuid\UriVariableTransformer\UuidUriVariableTransformer; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.serializer.uuid_denormalizer', UuidDenormalizer::class) diff --git a/src/Symfony/Bundle/Resources/config/routing/api.php b/src/Symfony/Bundle/Resources/config/routing/api.php index 50982559a6b..79a3f0d1a73 100644 --- a/src/Symfony/Bundle/Resources/config/routing/api.php +++ b/src/Symfony/Bundle/Resources/config/routing/api.php @@ -13,7 +13,7 @@ namespace Symfony\Component\Routing\Loader\Configurator; -return static function (RoutingConfigurator $routes) { +return static function (RoutingConfigurator $routes): void { $routes->add('api_entrypoint', '/{index}.{_format}') ->controller('api_platform.action.entrypoint') ->methods(['GET', 'HEAD']) diff --git a/src/Symfony/Bundle/Resources/config/routing/docs.php b/src/Symfony/Bundle/Resources/config/routing/docs.php index fb9482495c4..21fbe7b7d98 100644 --- a/src/Symfony/Bundle/Resources/config/routing/docs.php +++ b/src/Symfony/Bundle/Resources/config/routing/docs.php @@ -13,7 +13,7 @@ namespace Symfony\Component\Routing\Loader\Configurator; -return static function (RoutingConfigurator $routes) { +return static function (RoutingConfigurator $routes): void { $routes->add('api_doc', '/docs.{_format}') ->controller('api_platform.action.documentation') ->methods(['GET', 'HEAD']) diff --git a/src/Symfony/Bundle/Resources/config/routing/errors.php b/src/Symfony/Bundle/Resources/config/routing/errors.php index 3e3066806ce..a2d5c8c6a95 100644 --- a/src/Symfony/Bundle/Resources/config/routing/errors.php +++ b/src/Symfony/Bundle/Resources/config/routing/errors.php @@ -13,7 +13,7 @@ namespace Symfony\Component\Routing\Loader\Configurator; -return static function (RoutingConfigurator $routes) { +return static function (RoutingConfigurator $routes): void { $routes->add('api_validation_errors', '/validation_errors/{id}') ->controller('api_platform.action.not_exposed') ->methods(['GET', 'HEAD']); diff --git a/src/Symfony/Bundle/Resources/config/routing/genid.php b/src/Symfony/Bundle/Resources/config/routing/genid.php index 57acbca80a2..4fd11d684be 100644 --- a/src/Symfony/Bundle/Resources/config/routing/genid.php +++ b/src/Symfony/Bundle/Resources/config/routing/genid.php @@ -13,7 +13,7 @@ namespace Symfony\Component\Routing\Loader\Configurator; -return static function (RoutingConfigurator $routes) { +return static function (RoutingConfigurator $routes): void { $routes->add('api_genid', '/.well-known/genid/{id}') ->controller('api_platform.action.not_exposed') ->methods(['GET', 'HEAD']) diff --git a/src/Symfony/Bundle/Resources/config/routing/graphql/graphiql.php b/src/Symfony/Bundle/Resources/config/routing/graphql/graphiql.php index e3a3ade7319..b02ef89a92f 100644 --- a/src/Symfony/Bundle/Resources/config/routing/graphql/graphiql.php +++ b/src/Symfony/Bundle/Resources/config/routing/graphql/graphiql.php @@ -13,7 +13,7 @@ namespace Symfony\Component\Routing\Loader\Configurator; -return static function (RoutingConfigurator $routes) { +return static function (RoutingConfigurator $routes): void { $routes->add('api_graphql_graphiql', '/graphql/graphiql') ->controller('api_platform.graphql.action.graphiql') ->methods(['GET', 'HEAD']); diff --git a/src/Symfony/Bundle/Resources/config/routing/graphql/graphql.php b/src/Symfony/Bundle/Resources/config/routing/graphql/graphql.php index c425551dfc5..4104415a363 100644 --- a/src/Symfony/Bundle/Resources/config/routing/graphql/graphql.php +++ b/src/Symfony/Bundle/Resources/config/routing/graphql/graphql.php @@ -13,7 +13,7 @@ namespace Symfony\Component\Routing\Loader\Configurator; -return static function (RoutingConfigurator $routes) { +return static function (RoutingConfigurator $routes): void { $routes->add('api_graphql_entrypoint', '/graphql') ->controller('api_platform.graphql.action.entrypoint'); }; diff --git a/src/Symfony/Bundle/Resources/config/routing/jsonld.php b/src/Symfony/Bundle/Resources/config/routing/jsonld.php index 9d9604b7b38..9764c7aaf67 100644 --- a/src/Symfony/Bundle/Resources/config/routing/jsonld.php +++ b/src/Symfony/Bundle/Resources/config/routing/jsonld.php @@ -13,7 +13,7 @@ namespace Symfony\Component\Routing\Loader\Configurator; -return static function (RoutingConfigurator $routes) { +return static function (RoutingConfigurator $routes): void { $routes->add('api_jsonld_context', '/contexts/{shortName}.{_format}') ->controller('api_platform.jsonld.action.context') ->methods(['GET', 'HEAD']) diff --git a/src/Symfony/Bundle/Resources/config/security.php b/src/Symfony/Bundle/Resources/config/security.php index 0976d4b6a10..39cca40d46f 100644 --- a/src/Symfony/Bundle/Resources/config/security.php +++ b/src/Symfony/Bundle/Resources/config/security.php @@ -17,7 +17,7 @@ use ApiPlatform\Symfony\Security\Core\Authorization\ExpressionLanguageProvider; use ApiPlatform\Symfony\Security\ResourceAccessChecker; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->alias('api_platform.security.expression_language', 'security.expression_language'); diff --git a/src/Symfony/Bundle/Resources/config/state/http_cache_purger.php b/src/Symfony/Bundle/Resources/config/state/http_cache_purger.php index 58c93cc959c..b1637e4dc80 100644 --- a/src/Symfony/Bundle/Resources/config/state/http_cache_purger.php +++ b/src/Symfony/Bundle/Resources/config/state/http_cache_purger.php @@ -15,7 +15,7 @@ use ApiPlatform\HttpCache\State\AddTagsProcessor; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.http_cache_purger.processor.add_tags', AddTagsProcessor::class) diff --git a/src/Symfony/Bundle/Resources/config/state/hydra.php b/src/Symfony/Bundle/Resources/config/state/hydra.php index 370d0612d9c..a3d782361e8 100644 --- a/src/Symfony/Bundle/Resources/config/state/hydra.php +++ b/src/Symfony/Bundle/Resources/config/state/hydra.php @@ -15,7 +15,7 @@ use ApiPlatform\Hydra\State\HydraLinkProcessor; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.hydra.processor.link', HydraLinkProcessor::class) diff --git a/src/Symfony/Bundle/Resources/config/state/jsonapi.php b/src/Symfony/Bundle/Resources/config/state/jsonapi.php index 011e445a1c8..6789cc7d0cc 100644 --- a/src/Symfony/Bundle/Resources/config/state/jsonapi.php +++ b/src/Symfony/Bundle/Resources/config/state/jsonapi.php @@ -15,7 +15,7 @@ use ApiPlatform\JsonApi\State\JsonApiProvider; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.jsonapi.state_provider', JsonApiProvider::class) diff --git a/src/Symfony/Bundle/Resources/config/state/jsonld.php b/src/Symfony/Bundle/Resources/config/state/jsonld.php index 5339d4dbef4..3339db723bd 100644 --- a/src/Symfony/Bundle/Resources/config/state/jsonld.php +++ b/src/Symfony/Bundle/Resources/config/state/jsonld.php @@ -15,7 +15,7 @@ use ApiPlatform\JsonLd\Action\ContextAction; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.jsonld.action.context', ContextAction::class) diff --git a/src/Symfony/Bundle/Resources/config/state/mercure.php b/src/Symfony/Bundle/Resources/config/state/mercure.php index 993bd87d489..18149579ba2 100644 --- a/src/Symfony/Bundle/Resources/config/state/mercure.php +++ b/src/Symfony/Bundle/Resources/config/state/mercure.php @@ -15,7 +15,7 @@ use ApiPlatform\Symfony\State\MercureLinkProcessor; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.mercure.processor.add_link_header', MercureLinkProcessor::class) diff --git a/src/Symfony/Bundle/Resources/config/state/object_mapper.php b/src/Symfony/Bundle/Resources/config/state/object_mapper.php index ad970c8d2d2..c5f00b08765 100644 --- a/src/Symfony/Bundle/Resources/config/state/object_mapper.php +++ b/src/Symfony/Bundle/Resources/config/state/object_mapper.php @@ -18,7 +18,7 @@ use ApiPlatform\State\Provider\ObjectMapperProvider; use Symfony\Component\ObjectMapper\Metadata\ReflectionObjectMapperMetadataFactory; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.object_mapper.metadata_factory', ReflectionObjectMapperMetadataFactory::class); diff --git a/src/Symfony/Bundle/Resources/config/state/object_mapper_processor.php b/src/Symfony/Bundle/Resources/config/state/object_mapper_processor.php index 40de78b6169..9a1744ca2b5 100644 --- a/src/Symfony/Bundle/Resources/config/state/object_mapper_processor.php +++ b/src/Symfony/Bundle/Resources/config/state/object_mapper_processor.php @@ -16,7 +16,7 @@ use ApiPlatform\State\Processor\ObjectMapperInputProcessor; use ApiPlatform\State\Processor\ObjectMapperOutputProcessor; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.state_processor.object_mapper_input', ObjectMapperInputProcessor::class) diff --git a/src/Symfony/Bundle/Resources/config/state/parameter_provider.php b/src/Symfony/Bundle/Resources/config/state/parameter_provider.php index 921c869c19c..10d2f8ce684 100644 --- a/src/Symfony/Bundle/Resources/config/state/parameter_provider.php +++ b/src/Symfony/Bundle/Resources/config/state/parameter_provider.php @@ -15,7 +15,7 @@ use ApiPlatform\State\ParameterProvider\IriConverterParameterProvider; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.state_provider.parameter.iri_converter', IriConverterParameterProvider::class) diff --git a/src/Symfony/Bundle/Resources/config/state/processor.php b/src/Symfony/Bundle/Resources/config/state/processor.php index f44dfb20d8f..ce22a7ca618 100644 --- a/src/Symfony/Bundle/Resources/config/state/processor.php +++ b/src/Symfony/Bundle/Resources/config/state/processor.php @@ -18,7 +18,7 @@ use ApiPlatform\State\Processor\SerializeProcessor; use ApiPlatform\State\Processor\WriteProcessor; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->alias('api_platform.state_processor.main', 'api_platform.state_processor.respond'); diff --git a/src/Symfony/Bundle/Resources/config/state/provider.php b/src/Symfony/Bundle/Resources/config/state/provider.php index f31fc2bc7c1..4ff4b5c9358 100644 --- a/src/Symfony/Bundle/Resources/config/state/provider.php +++ b/src/Symfony/Bundle/Resources/config/state/provider.php @@ -19,7 +19,7 @@ use ApiPlatform\State\Provider\ReadProvider; use ApiPlatform\Symfony\EventListener\ErrorListener; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->alias('api_platform.state_provider.main', 'api_platform.state_provider.locator'); diff --git a/src/Symfony/Bundle/Resources/config/state/security.php b/src/Symfony/Bundle/Resources/config/state/security.php index ee24ded92e8..709d8573421 100644 --- a/src/Symfony/Bundle/Resources/config/state/security.php +++ b/src/Symfony/Bundle/Resources/config/state/security.php @@ -16,7 +16,7 @@ use ApiPlatform\State\Provider\SecurityParameterProvider; use ApiPlatform\Symfony\Security\State\AccessCheckerProvider; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.state_provider.access_checker', AccessCheckerProvider::class) diff --git a/src/Symfony/Bundle/Resources/config/state/security_validator.php b/src/Symfony/Bundle/Resources/config/state/security_validator.php index 1b515348651..b2a127ccbe8 100644 --- a/src/Symfony/Bundle/Resources/config/state/security_validator.php +++ b/src/Symfony/Bundle/Resources/config/state/security_validator.php @@ -15,7 +15,7 @@ use ApiPlatform\Symfony\Security\State\AccessCheckerProvider; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.state_provider.access_checker.post_validate', AccessCheckerProvider::class) diff --git a/src/Symfony/Bundle/Resources/config/state/state.php b/src/Symfony/Bundle/Resources/config/state/state.php index f3dd834d730..abf5e4491d9 100644 --- a/src/Symfony/Bundle/Resources/config/state/state.php +++ b/src/Symfony/Bundle/Resources/config/state/state.php @@ -23,7 +23,7 @@ use ApiPlatform\State\SerializerContextBuilderInterface; use Symfony\Component\DependencyInjection\ServiceLocator; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.state_provider.locator', CallableProvider::class) diff --git a/src/Symfony/Bundle/Resources/config/state/swagger_ui.php b/src/Symfony/Bundle/Resources/config/state/swagger_ui.php index 0ebb86e6410..286fcbe59dd 100644 --- a/src/Symfony/Bundle/Resources/config/state/swagger_ui.php +++ b/src/Symfony/Bundle/Resources/config/state/swagger_ui.php @@ -15,7 +15,7 @@ use ApiPlatform\Symfony\Bundle\SwaggerUi\SwaggerUiProvider; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.swagger_ui.provider', SwaggerUiProvider::class) diff --git a/src/Symfony/Bundle/Resources/config/swagger_ui.php b/src/Symfony/Bundle/Resources/config/swagger_ui.php index 4d4b756af6e..ad0df6f793e 100644 --- a/src/Symfony/Bundle/Resources/config/swagger_ui.php +++ b/src/Symfony/Bundle/Resources/config/swagger_ui.php @@ -16,7 +16,7 @@ use ApiPlatform\Symfony\Bundle\SwaggerUi\SwaggerUiContext; use ApiPlatform\Symfony\Bundle\SwaggerUi\SwaggerUiProcessor; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.swagger_ui.context', SwaggerUiContext::class) diff --git a/src/Symfony/Bundle/Resources/config/symfony/controller.php b/src/Symfony/Bundle/Resources/config/symfony/controller.php index 203afa69245..c6831fec58a 100644 --- a/src/Symfony/Bundle/Resources/config/symfony/controller.php +++ b/src/Symfony/Bundle/Resources/config/symfony/controller.php @@ -17,7 +17,7 @@ use ApiPlatform\Symfony\Action\EntrypointAction; use ApiPlatform\Symfony\Controller\MainController; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.symfony.main_controller', MainController::class) diff --git a/src/Symfony/Bundle/Resources/config/symfony/events.php b/src/Symfony/Bundle/Resources/config/symfony/events.php index 12488624e08..ee8e780cf55 100644 --- a/src/Symfony/Bundle/Resources/config/symfony/events.php +++ b/src/Symfony/Bundle/Resources/config/symfony/events.php @@ -32,7 +32,7 @@ use ApiPlatform\Symfony\EventListener\SerializeListener; use ApiPlatform\Symfony\EventListener\WriteListener; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.state_provider.content_negotiation', ContentNegotiationProvider::class) diff --git a/src/Symfony/Bundle/Resources/config/symfony/jsonld.php b/src/Symfony/Bundle/Resources/config/symfony/jsonld.php index 1b96773c023..fc1c5cb40c0 100644 --- a/src/Symfony/Bundle/Resources/config/symfony/jsonld.php +++ b/src/Symfony/Bundle/Resources/config/symfony/jsonld.php @@ -15,7 +15,7 @@ use ApiPlatform\JsonLd\Action\ContextAction; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.jsonld.action.context', ContextAction::class) diff --git a/src/Symfony/Bundle/Resources/config/symfony/object_mapper.php b/src/Symfony/Bundle/Resources/config/symfony/object_mapper.php index b1ed3ca5b74..bd99bfa6231 100644 --- a/src/Symfony/Bundle/Resources/config/symfony/object_mapper.php +++ b/src/Symfony/Bundle/Resources/config/symfony/object_mapper.php @@ -21,7 +21,7 @@ use ApiPlatform\Symfony\Validator\State\ValidateProcessor; use Symfony\Component\Validator\Validator\ValidatorInterface; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.state_processor.object_mapper_input', ObjectMapperInputProcessor::class) diff --git a/src/Symfony/Bundle/Resources/config/symfony/swagger_ui.php b/src/Symfony/Bundle/Resources/config/symfony/swagger_ui.php index a82f07a2713..b823d6738e6 100644 --- a/src/Symfony/Bundle/Resources/config/symfony/swagger_ui.php +++ b/src/Symfony/Bundle/Resources/config/symfony/swagger_ui.php @@ -15,7 +15,7 @@ use ApiPlatform\Symfony\Bundle\SwaggerUi\SwaggerUiProvider; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.swagger_ui.documentation.provider', SwaggerUiProvider::class) diff --git a/src/Symfony/Bundle/Resources/config/symfony/symfony.php b/src/Symfony/Bundle/Resources/config/symfony/symfony.php index 31b6c0f05d4..b51add8c35b 100644 --- a/src/Symfony/Bundle/Resources/config/symfony/symfony.php +++ b/src/Symfony/Bundle/Resources/config/symfony/symfony.php @@ -16,7 +16,7 @@ use ApiPlatform\Symfony\Bundle\CacheWarmer\CachePoolClearerCacheWarmer; use ApiPlatform\Symfony\EventListener\ExceptionListener; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.listener.exception', ExceptionListener::class) diff --git a/src/Symfony/Bundle/Resources/config/symfony/uid.php b/src/Symfony/Bundle/Resources/config/symfony/uid.php index d1b43ec7552..ae35dd9883c 100644 --- a/src/Symfony/Bundle/Resources/config/symfony/uid.php +++ b/src/Symfony/Bundle/Resources/config/symfony/uid.php @@ -16,7 +16,7 @@ use ApiPlatform\Symfony\UriVariableTransformer\UlidUriVariableTransformer; use ApiPlatform\Symfony\UriVariableTransformer\UuidUriVariableTransformer; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.symfony.uri_variables.transformer.ulid', UlidUriVariableTransformer::class) diff --git a/src/Symfony/Bundle/Resources/config/validator/events.php b/src/Symfony/Bundle/Resources/config/validator/events.php index c2768a8c77d..c96ee42a3c0 100644 --- a/src/Symfony/Bundle/Resources/config/validator/events.php +++ b/src/Symfony/Bundle/Resources/config/validator/events.php @@ -17,7 +17,7 @@ use ApiPlatform\Symfony\Validator\State\ParameterValidatorProvider; use ApiPlatform\Symfony\Validator\State\ValidateProvider; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.state_provider.validate', ValidateProvider::class) diff --git a/src/Symfony/Bundle/Resources/config/validator/state.php b/src/Symfony/Bundle/Resources/config/validator/state.php index af407f9184c..9d22c04bcb2 100644 --- a/src/Symfony/Bundle/Resources/config/validator/state.php +++ b/src/Symfony/Bundle/Resources/config/validator/state.php @@ -17,7 +17,7 @@ use ApiPlatform\Symfony\Validator\State\ValidateProcessor; use ApiPlatform\Symfony\Validator\State\ValidateProvider; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.state_provider.validate', ValidateProvider::class) diff --git a/src/Symfony/Bundle/Resources/config/validator/validator.php b/src/Symfony/Bundle/Resources/config/validator/validator.php index 786221ea971..3cd8af0aac8 100644 --- a/src/Symfony/Bundle/Resources/config/validator/validator.php +++ b/src/Symfony/Bundle/Resources/config/validator/validator.php @@ -18,7 +18,7 @@ use ApiPlatform\Validator\Metadata\Resource\Factory\ParameterValidationResourceMetadataCollectionFactory; use ApiPlatform\Validator\ValidatorInterface; -return static function (ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set('api_platform.validator', Validator::class) diff --git a/src/Symfony/Doctrine/EventListener/PublishMercureUpdatesListener.php b/src/Symfony/Doctrine/EventListener/PublishMercureUpdatesListener.php index 902f4c52a05..cb5d662fbd2 100644 --- a/src/Symfony/Doctrine/EventListener/PublishMercureUpdatesListener.php +++ b/src/Symfony/Doctrine/EventListener/PublishMercureUpdatesListener.php @@ -86,7 +86,7 @@ public function __construct(ResourceClassResolverInterface $resourceClassResolve new ExpressionFunction('get_operation', static fn (string $apiResource, string $name): string => \sprintf('getOperation(%s, %s)', $apiResource, $name), static fn (array $arguments, $apiResource, string $name): Operation => $resourceMetadataFactory->create($resourceClassResolver->getResourceClass($apiResource))->getOperation($name)) ); $this->expressionLanguage->addFunction( - new ExpressionFunction('iri', static fn (string $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL, ?string $operation = null): string => \sprintf('iri(%s, %d, %s)', $apiResource, $referenceType, $operation), static fn (array $arguments, $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL, $operation = null): string => $iriConverter->getIriFromResource($apiResource, $referenceType, $operation)) + new ExpressionFunction('iri', static fn (string $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL, ?string $operation = null): string => \sprintf('iri(%s, %d, %s)', $apiResource, $referenceType, $operation), static fn (array $arguments, object|string $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL, ?Operation $operation = null): string => $iriConverter->getIriFromResource($apiResource, $referenceType, $operation)) ); } } diff --git a/src/Symfony/Doctrine/EventListener/PurgeHttpCacheListener.php b/src/Symfony/Doctrine/EventListener/PurgeHttpCacheListener.php index 8419b496734..b919a0f8b0c 100644 --- a/src/Symfony/Doctrine/EventListener/PurgeHttpCacheListener.php +++ b/src/Symfony/Doctrine/EventListener/PurgeHttpCacheListener.php @@ -228,7 +228,7 @@ private function getResourcesForEntity(object $entity): array } $resources = array_map( - fn ($mapping) => $this->objectMapper->map($entity, $mapping->target), + fn ($mapping): object => $this->objectMapper->map($entity, $mapping->target), $mappings ); } else { @@ -240,7 +240,7 @@ private function getResourcesForEntity(object $entity): array // loop over all mappings to fetch all resources mapped to this entity $resources = array_map( - fn ($mapAttribute) => $this->objectMapper->map($entity, $mapAttribute->newInstance()->target), + fn ($mapAttribute): object => $this->objectMapper->map($entity, $mapAttribute->newInstance()->target), $mapAttributes ); } diff --git a/src/Symfony/Messenger/DispatchTrait.php b/src/Symfony/Messenger/DispatchTrait.php index ba16190b3cc..4479a677afa 100644 --- a/src/Symfony/Messenger/DispatchTrait.php +++ b/src/Symfony/Messenger/DispatchTrait.php @@ -24,9 +24,6 @@ trait DispatchTrait { private ?MessageBusInterface $messageBus; - /** - * @param object|Envelope $message - */ private function dispatch(object $message): Envelope { if (!$this->messageBus instanceof MessageBusInterface) { diff --git a/src/Symfony/Security/Core/Authorization/ExpressionLanguageProvider.php b/src/Symfony/Security/Core/Authorization/ExpressionLanguageProvider.php index feb2238a900..4da99da15f6 100644 --- a/src/Symfony/Security/Core/Authorization/ExpressionLanguageProvider.php +++ b/src/Symfony/Security/Core/Authorization/ExpressionLanguageProvider.php @@ -26,7 +26,7 @@ final class ExpressionLanguageProvider implements ExpressionFunctionProviderInte public function getFunctions(): array { return [ - new ExpressionFunction('is_granted', static fn ($attributes, $object = 'null'): string => \sprintf('$auth_checker->isGranted(%s, %s)', $attributes, $object), static fn (array $variables, $attributes, $object = null) => $variables['auth_checker']->isGranted($attributes, $object)), + new ExpressionFunction('is_granted', static fn (string $attributes, $object = 'null'): string => \sprintf('$auth_checker->isGranted(%s, %s)', $attributes, $object), static fn (array $variables, $attributes, $object = null) => $variables['auth_checker']->isGranted($attributes, $object)), ]; } } diff --git a/src/Symfony/Tests/Action/DocumentationActionTest.php b/src/Symfony/Tests/Action/DocumentationActionTest.php index 2595e33b232..c83b7d1bd4d 100644 --- a/src/Symfony/Tests/Action/DocumentationActionTest.php +++ b/src/Symfony/Tests/Action/DocumentationActionTest.php @@ -168,13 +168,13 @@ public static function getOpenApiContentTypes(): array } #[DataProvider('getOpenApiContentTypes')] - public function testGetOpenApi($contentType): void + public function testGetOpenApi(string $contentType): void { $request = new Request(server: ['CONTENT_TYPE' => $contentType]); $openApiFactory = $this->createMock(OpenApiFactoryInterface::class); $resourceNameCollectionFactory = $this->createMock(ResourceNameCollectionFactoryInterface::class); $provider = $this->createMock(ProviderInterface::class); - $provider->expects($this->once())->method('provide')->willReturnCallback(static fn ($operation, $uriVariables, $context) => new OpenApi(new Info('title', '1.0.0'), [], new Paths())); + $provider->expects($this->once())->method('provide')->willReturnCallback(static fn ($operation, $uriVariables, $context): OpenApi => new OpenApi(new Info('title', '1.0.0'), [], new Paths())); $processor = $this->createMock(ProcessorInterface::class); $processor->expects($this->once())->method('process')->willReturnArgument(0); $entrypoint = new DocumentationAction($resourceNameCollectionFactory, provider: $provider, processor: $processor, openApiFactory: $openApiFactory); diff --git a/src/Symfony/Tests/EventListener/ErrorListenerTest.php b/src/Symfony/Tests/EventListener/ErrorListenerTest.php index 09b8a990248..bc44988067a 100644 --- a/src/Symfony/Tests/EventListener/ErrorListenerTest.php +++ b/src/Symfony/Tests/EventListener/ErrorListenerTest.php @@ -49,7 +49,7 @@ public function testDuplicateException(): void $resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class); $resourceClassResolver->expects($this->once())->method('isResourceClass')->with($exception::class)->willReturn(false); $kernel = $this->createStub(KernelInterface::class); - $kernel->method('handle')->willReturnCallback(function ($request) { + $kernel->method('handle')->willReturnCallback(function ($request): Response { $this->assertTrue($request->attributes->has('_api_original_route')); $this->assertTrue($request->attributes->has('_api_original_route_params')); $this->assertTrue($request->attributes->has('_api_requested_operation')); @@ -80,7 +80,7 @@ public function testDuplicateExceptionWithHydra(): void $resourceClassResolver->expects($this->once())->method('isResourceClass')->with($exception::class)->willReturn(false); $kernel = $this->createStub(KernelInterface::class); - $kernel->method('handle')->willReturnCallback(function ($request) { + $kernel->method('handle')->willReturnCallback(function ($request): Response { $this->assertTrue($request->attributes->has('_api_original_route')); $this->assertTrue($request->attributes->has('_api_original_route_params')); $this->assertTrue($request->attributes->has('_api_requested_operation')); @@ -111,7 +111,7 @@ public function testDuplicateExceptionWithErrorResource(): void $resourceClassResolver->expects($this->once())->method('isResourceClass')->with(Error::class)->willReturn(true); $kernel = $this->createStub(KernelInterface::class); - $kernel->method('handle')->willReturnCallback(function ($request) { + $kernel->method('handle')->willReturnCallback(function ($request): Response { $this->assertTrue($request->attributes->has('_api_original_route')); $this->assertTrue($request->attributes->has('_api_original_route_params')); $this->assertTrue($request->attributes->has('_api_requested_operation')); diff --git a/src/Symfony/Tests/Fixtures/TestBundle/Entity/DummyCar.php b/src/Symfony/Tests/Fixtures/TestBundle/Entity/DummyCar.php index 95d95358302..690780bad47 100644 --- a/src/Symfony/Tests/Fixtures/TestBundle/Entity/DummyCar.php +++ b/src/Symfony/Tests/Fixtures/TestBundle/Entity/DummyCar.php @@ -52,10 +52,6 @@ class DummyCar #[ORM\Column] private string $brand = 'DummyBrand'; - public function __construct() - { - } - /** * Get name. */ diff --git a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaChoiceRestriction.php b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaChoiceRestriction.php index f23b20a5d8a..65a9f47a1c3 100644 --- a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaChoiceRestriction.php +++ b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaChoiceRestriction.php @@ -57,7 +57,7 @@ public function create(Constraint $constraint, ApiProperty $propertyMetadata): a $restriction['type'] = 'array'; - $types = array_values(array_unique(array_map(static fn (mixed $choice) => \is_string($choice) ? 'string' : 'number', $choices))); + $types = array_values(array_unique(array_map(static fn (mixed $choice): string => \is_string($choice) ? 'string' : 'number', $choices))); if ($count = \count($types)) { if (1 === $count) { @@ -97,7 +97,7 @@ public function supports(Constraint $constraint, ApiProperty $propertyMetadata): return true; } - if ($nativeType->isSatisfiedBy(static fn ($t) => $t instanceof CollectionType)) { + if ($nativeType->isSatisfiedBy(static fn ($t): bool => $t instanceof CollectionType)) { if (null !== ($collectionValueType = TypeHelper::getCollectionValueType($nativeType)) && $isValidScalarType($collectionValueType)) { return true; } @@ -106,7 +106,7 @@ public function supports(Constraint $constraint, ApiProperty $propertyMetadata): return false; } - $types = array_map(static fn (LegacyType $type) => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []); + $types = array_map(static fn (LegacyType $type): string => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []); if ($propertyMetadata->getExtraProperties()['nested_schema'] ?? false) { $types = [LegacyType::BUILTIN_TYPE_STRING]; } @@ -116,7 +116,7 @@ public function supports(Constraint $constraint, ApiProperty $propertyMetadata): && $builtinType->isCollection() && \count($builtinType->getCollectionValueTypes()) > 0 ) { - $types = array_unique(array_merge($types, array_map(static fn (LegacyType $type) => $type->getBuiltinType(), $builtinType->getCollectionValueTypes()))); + $types = array_unique(array_merge($types, array_map(static fn (LegacyType $type): string => $type->getBuiltinType(), $builtinType->getCollectionValueTypes()))); } return \count($types) > 0 && \count(array_intersect($types, [LegacyType::BUILTIN_TYPE_STRING, LegacyType::BUILTIN_TYPE_INT, LegacyType::BUILTIN_TYPE_FLOAT])) > 0; diff --git a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaCssColorRestriction.php b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaCssColorRestriction.php index 360cf1f6dbb..2979d95e532 100644 --- a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaCssColorRestriction.php +++ b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaCssColorRestriction.php @@ -62,7 +62,7 @@ public function create(Constraint $constraint, ApiProperty $propertyMetadata): a { return [ 'pattern' => '^('.implode('|', array_map( - static fn ($format) => trim(self::COLOR_PATTERNS[$format], '/iD^$'), + static fn ($format): string => trim(self::COLOR_PATTERNS[$format], '/iD^$'), (array) $constraint->formats )).')$', ]; diff --git a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanOrEqualRestriction.php b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanOrEqualRestriction.php index 7d8c9d05428..b6f126067c7 100644 --- a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanOrEqualRestriction.php +++ b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanOrEqualRestriction.php @@ -52,7 +52,7 @@ public function supports(Constraint $constraint, ApiProperty $propertyMetadata): return $type->isIdentifiedBy(TypeIdentifier::INT, TypeIdentifier::FLOAT); } - $types = array_map(static fn (LegacyType $type) => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []); + $types = array_map(static fn (LegacyType $type): string => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []); if ($propertyMetadata->getExtraProperties()['nested_schema'] ?? false) { $types = [LegacyType::BUILTIN_TYPE_INT]; } diff --git a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanRestriction.php b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanRestriction.php index 0e33eca2ea7..d0cf10fa461 100644 --- a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanRestriction.php +++ b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanRestriction.php @@ -56,7 +56,7 @@ public function supports(Constraint $constraint, ApiProperty $propertyMetadata): return $type->isIdentifiedBy(TypeIdentifier::INT, TypeIdentifier::FLOAT); } - $types = array_map(static fn (LegacyType $type) => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []); + $types = array_map(static fn (LegacyType $type): string => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []); if ($propertyMetadata->getExtraProperties()['nested_schema'] ?? false) { $types = [LegacyType::BUILTIN_TYPE_INT]; } diff --git a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLengthRestriction.php b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLengthRestriction.php index 07b2f76d588..6927399c859 100644 --- a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLengthRestriction.php +++ b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLengthRestriction.php @@ -59,7 +59,7 @@ public function supports(Constraint $constraint, ApiProperty $propertyMetadata): return $constraint instanceof Length && $type?->isIdentifiedBy(TypeIdentifier::STRING); } - $types = array_map(static fn (LegacyType $type) => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []); + $types = array_map(static fn (LegacyType $type): string => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []); if ($propertyMetadata->getExtraProperties()['nested_schema'] ?? false) { $types = [LegacyType::BUILTIN_TYPE_STRING]; } diff --git a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanOrEqualRestriction.php b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanOrEqualRestriction.php index f1141818a07..c6e4a26744f 100644 --- a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanOrEqualRestriction.php +++ b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanOrEqualRestriction.php @@ -55,7 +55,7 @@ public function supports(Constraint $constraint, ApiProperty $propertyMetadata): return $type->isIdentifiedBy(TypeIdentifier::INT, TypeIdentifier::FLOAT); } - $types = array_map(static fn (LegacyType $type) => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []); + $types = array_map(static fn (LegacyType $type): string => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []); if ($propertyMetadata->getExtraProperties()['nested_schema'] ?? false) { $types = [LegacyType::BUILTIN_TYPE_INT]; } diff --git a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanRestriction.php b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanRestriction.php index 7af4d9f7567..74a7a0c498a 100644 --- a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanRestriction.php +++ b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanRestriction.php @@ -53,7 +53,7 @@ public function supports(Constraint $constraint, ApiProperty $propertyMetadata): return $type->isIdentifiedBy(TypeIdentifier::INT, TypeIdentifier::FLOAT); } - $types = array_map(static fn (LegacyType $type) => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []); + $types = array_map(static fn (LegacyType $type): string => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []); if ($propertyMetadata->getExtraProperties()['nested_schema'] ?? false) { $types = [LegacyType::BUILTIN_TYPE_INT]; } diff --git a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaRangeRestriction.php b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaRangeRestriction.php index 833af136c6d..caa971f5797 100644 --- a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaRangeRestriction.php +++ b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaRangeRestriction.php @@ -63,7 +63,7 @@ public function supports(Constraint $constraint, ApiProperty $propertyMetadata): return $type->isIdentifiedBy(TypeIdentifier::INT, TypeIdentifier::FLOAT); } - $types = array_map(static fn (LegacyType $type) => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []); + $types = array_map(static fn (LegacyType $type): string => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []); if ($propertyMetadata->getExtraProperties()['nested_schema'] ?? false) { $types = [LegacyType::BUILTIN_TYPE_INT]; } diff --git a/src/Symfony/Validator/State/ErrorProvider.php b/src/Symfony/Validator/State/ErrorProvider.php index 3b813f377ec..81457954475 100644 --- a/src/Symfony/Validator/State/ErrorProvider.php +++ b/src/Symfony/Validator/State/ErrorProvider.php @@ -24,10 +24,6 @@ */ final class ErrorProvider implements ProviderInterface { - public function __construct() - { - } - public function provide(Operation $operation, array $uriVariables = [], array $context = []): ConstraintViolationListInterface|\Throwable { if (!($request = $context['request'] ?? null) || !$operation instanceof HttpOperation) { diff --git a/src/Validator/Util/ParameterValidationConstraints.php b/src/Validator/Util/ParameterValidationConstraints.php index b1f4ffb7fc6..6a8c641704d 100644 --- a/src/Validator/Util/ParameterValidationConstraints.php +++ b/src/Validator/Util/ParameterValidationConstraints.php @@ -102,7 +102,7 @@ public static function getParameterValidationConstraints(Parameter $parameter, ? $assertions[] = new Choice(choices: $schema['enum']); } - $isCollectionType = static fn ($t) => $t instanceof CollectionType; + $isCollectionType = static fn ($t): bool => $t instanceof CollectionType; $isCollection = $parameter->getNativeType()?->isSatisfiedBy($isCollectionType) ?? false; // type-info 7.2 diff --git a/tests/Behat/CoverageContext.php b/tests/Behat/CoverageContext.php index ee5c171cd3d..bb82d27241a 100644 --- a/tests/Behat/CoverageContext.php +++ b/tests/Behat/CoverageContext.php @@ -30,10 +30,7 @@ */ final class CoverageContext implements Context { - /** - * @var CodeCoverage - */ - private static $coverage; + private static ?CodeCoverage $coverage = null; /** * @BeforeSuite diff --git a/tests/Behat/GraphqlContext.php b/tests/Behat/GraphqlContext.php index ca644baaff9..b59c5bc46b2 100644 --- a/tests/Behat/GraphqlContext.php +++ b/tests/Behat/GraphqlContext.php @@ -34,9 +34,7 @@ final class GraphqlContext implements Context private ?RestContext $restContext = null; private ?JsonContext $jsonContext = null; - private array $graphqlRequest; - - private ?int $graphqlLine = null; // @phpstan-ignore-line + private array $graphqlRequest; // @phpstan-ignore-line public function __construct(private readonly Request $request) { @@ -65,7 +63,6 @@ public function gatherContexts(BeforeScenarioScope $scope): void public function IHaveTheFollowingGraphqlRequest(PyStringNode $request): void { $this->graphqlRequest = ['query' => $request->getRaw()]; - $this->graphqlLine = $request->getLine(); } /** diff --git a/tests/Behat/JsonContext.php b/tests/Behat/JsonContext.php index 4450465fd08..5e2b315eb07 100644 --- a/tests/Behat/JsonContext.php +++ b/tests/Behat/JsonContext.php @@ -17,17 +17,11 @@ use Behat\Gherkin\Node\PyStringNode; use Behat\Mink\Exception\ExpectationException; use Behatch\Context\JsonContext as BaseJsonContext; -use Behatch\HttpCall\HttpCallResultPool; use Behatch\Json\Json; use PHPUnit\Framework\Assert; final class JsonContext extends BaseJsonContext { - public function __construct(HttpCallResultPool $httpCallResultPool) - { - parent::__construct($httpCallResultPool); - } - /** * @Then the JSON node :node should contain: */ diff --git a/tests/Fixtures/DummyObjectWithOnlyPrivateProperty.php b/tests/Fixtures/DummyObjectWithOnlyPrivateProperty.php index cdf40afef7f..0e23b22193b 100644 --- a/tests/Fixtures/DummyObjectWithOnlyPrivateProperty.php +++ b/tests/Fixtures/DummyObjectWithOnlyPrivateProperty.php @@ -15,5 +15,5 @@ class DummyObjectWithOnlyPrivateProperty { - private $foo; // @phpstan-ignore-line + // @phpstan-ignore-line } diff --git a/tests/Fixtures/Query.php b/tests/Fixtures/Query.php index 712138dc990..5e9d31a09ef 100644 --- a/tests/Fixtures/Query.php +++ b/tests/Fixtures/Query.php @@ -45,7 +45,7 @@ public function setParameters($parameters): self return $this; } - public function getParameters() + public function getParameters(): ArrayCollection { return new ArrayCollection(); } @@ -55,12 +55,12 @@ public function setCacheable($cacheable): self return $this; } - public function getHints() + public function getHints(): array { return []; } - public function getFetchJoinCollection() + public function getFetchJoinCollection(): bool { return false; } diff --git a/tests/Fixtures/TestBundle/Action/ConfigCustom.php b/tests/Fixtures/TestBundle/Action/ConfigCustom.php index b028383246e..4eb79510d13 100644 --- a/tests/Fixtures/TestBundle/Action/ConfigCustom.php +++ b/tests/Fixtures/TestBundle/Action/ConfigCustom.php @@ -29,7 +29,7 @@ public function __construct(private readonly ProviderInterface $provider) { } - public function __invoke(Request $request, $id) + public function __invoke(Request $request, $id): object|array|null { $attributes = RequestAttributesExtractor::extractAttributes($request); diff --git a/tests/Fixtures/TestBundle/ApiResource/IsGrantedTestResource.php b/tests/Fixtures/TestBundle/ApiResource/IsGrantedTestResource.php index c7d8687373c..52991fb56d9 100644 --- a/tests/Fixtures/TestBundle/ApiResource/IsGrantedTestResource.php +++ b/tests/Fixtures/TestBundle/ApiResource/IsGrantedTestResource.php @@ -34,12 +34,12 @@ public function getId(): ?int return $this->id; } - public static function provide(Operation $operation, array $uriVariables = [], array $context = []) + public static function provide(Operation $operation, array $uriVariables = [], array $context = []): self { return new self(); } - public static function provideShouldNotBeCalled(Operation $operation, array $uriVariables = [], array $context = []) + public static function provideShouldNotBeCalled(Operation $operation, array $uriVariables = [], array $context = []): never { throw new \RuntimeException('provider should not get called'); } diff --git a/tests/Fixtures/TestBundle/ApiResource/Issue6264/BackedEnumStringTrait.php b/tests/Fixtures/TestBundle/ApiResource/Issue6264/BackedEnumStringTrait.php index f6f90be4cc7..920ae0c12cb 100644 --- a/tests/Fixtures/TestBundle/ApiResource/Issue6264/BackedEnumStringTrait.php +++ b/tests/Fixtures/TestBundle/ApiResource/Issue6264/BackedEnumStringTrait.php @@ -20,7 +20,7 @@ trait BackedEnumStringTrait { public static function values(): array { - return array_map(static fn (\BackedEnum $feature) => $feature->value, self::cases()); + return array_map(static fn (\BackedEnum $feature): string => $feature->value, self::cases()); } public function getId(): string @@ -44,6 +44,6 @@ public static function getCases(): array */ public static function getCase(Operation $operation, array $uriVariables): ?self { - return array_reduce(self::cases(), static fn ($c, \BackedEnum $case) => $case->value == $uriVariables['id'] ? $case : $c, null); + return array_reduce(self::cases(), static fn ($c, \BackedEnum $case) => $case->value == $uriVariables['id'] ? $case : $c); } } diff --git a/tests/Fixtures/TestBundle/ApiResource/Issue6264/BackedEnumTrait.php b/tests/Fixtures/TestBundle/ApiResource/Issue6264/BackedEnumTrait.php index 3bd48c3ebd5..ddb56591ce1 100644 --- a/tests/Fixtures/TestBundle/ApiResource/Issue6264/BackedEnumTrait.php +++ b/tests/Fixtures/TestBundle/ApiResource/Issue6264/BackedEnumTrait.php @@ -20,7 +20,7 @@ trait BackedEnumTrait { public static function values(): array { - return array_map(static fn (\BackedEnum $feature) => $feature->value, self::cases()); + return array_map(static fn (\BackedEnum $feature): int => $feature->value, self::cases()); } public function getId(): int @@ -44,6 +44,6 @@ public static function getCases(): array */ public static function getCase(Operation $operation, array $uriVariables): ?self { - return array_reduce(self::cases(), static fn ($c, \BackedEnum $case) => $case->value == $uriVariables['id'] ? $case : $c, null); + return array_reduce(self::cases(), static fn ($c, \BackedEnum $case) => $case->value == $uriVariables['id'] ? $case : $c); } } diff --git a/tests/Fixtures/TestBundle/ApiResource/Issue6427/SecurityAfterResolver.php b/tests/Fixtures/TestBundle/ApiResource/Issue6427/SecurityAfterResolver.php index c94cce04c91..42b697343fa 100644 --- a/tests/Fixtures/TestBundle/ApiResource/Issue6427/SecurityAfterResolver.php +++ b/tests/Fixtures/TestBundle/ApiResource/Issue6427/SecurityAfterResolver.php @@ -32,7 +32,7 @@ public function __construct(public ?string $id, public ?string $name) { } - public static function provide() + public static function provide(): self { return new self('1', '1'); } diff --git a/tests/Fixtures/TestBundle/ApiResource/Issue7432/OriginalDataWithListeners.php b/tests/Fixtures/TestBundle/ApiResource/Issue7432/OriginalDataWithListeners.php index bc1b3fe2cb5..c68ce4cbe5a 100644 --- a/tests/Fixtures/TestBundle/ApiResource/Issue7432/OriginalDataWithListeners.php +++ b/tests/Fixtures/TestBundle/ApiResource/Issue7432/OriginalDataWithListeners.php @@ -29,7 +29,7 @@ public function __construct(public string $uuid, public ?string $code = null) { } - public static function process($data, Operation $operation, array $uriVariables = [], array $context = []) + public static function process($data, Operation $operation, array $uriVariables = [], array $context = []): self { \assert($data instanceof UserVerifyInput); \assert($context['previous_data'] instanceof self); @@ -44,7 +44,7 @@ public static function process($data, Operation $operation, array $uriVariables return $context['previous_data']; } - public static function provide(Operation $operation, array $uriVariables = [], array $context = []) + public static function provide(Operation $operation, array $uriVariables = [], array $context = []): self { return new self($uriVariables['uuid']); } diff --git a/tests/Fixtures/TestBundle/ApiResource/Issue7469TestResource.php b/tests/Fixtures/TestBundle/ApiResource/Issue7469TestResource.php index 29027b10633..8188f703144 100644 --- a/tests/Fixtures/TestBundle/ApiResource/Issue7469TestResource.php +++ b/tests/Fixtures/TestBundle/ApiResource/Issue7469TestResource.php @@ -43,7 +43,7 @@ final class Issue7469TestResource /** * @param HttpOperation $operation */ - public static function provide(Operation $operation, array $uriVariables = [], array $context = []) + public static function provide(Operation $operation): self { /** @var Issue7469Dummy $dummy */ $dummy = $operation->getUriVariables()['id']->getValue(); diff --git a/tests/Fixtures/TestBundle/ApiResource/LinkParameterProviderResource.php b/tests/Fixtures/TestBundle/ApiResource/LinkParameterProviderResource.php index 8d1f72d68e8..3f9bdca8d84 100644 --- a/tests/Fixtures/TestBundle/ApiResource/LinkParameterProviderResource.php +++ b/tests/Fixtures/TestBundle/ApiResource/LinkParameterProviderResource.php @@ -38,7 +38,7 @@ class LinkParameterProviderResource /** * @param HttpOperation $operation */ - public static function provide(Operation $operation, array $uriVariables = []) + public static function provide(Operation $operation, array $uriVariables = []): self { $d = new self(); $d->id = '1'; diff --git a/tests/Fixtures/TestBundle/ApiResource/MappedResourceNoMap.php b/tests/Fixtures/TestBundle/ApiResource/MappedResourceNoMap.php index 1f2ce644de3..5d931a4bc19 100644 --- a/tests/Fixtures/TestBundle/ApiResource/MappedResourceNoMap.php +++ b/tests/Fixtures/TestBundle/ApiResource/MappedResourceNoMap.php @@ -35,7 +35,7 @@ public function __construct(public ?int $id = null, public ?string $name = null) { } - public static function provide(Operation $operation, array $uriVariables = []) + public static function provide(Operation $operation, array $uriVariables = []): self { return new self($uriVariables['id'], 'test name'); } diff --git a/tests/Fixtures/TestBundle/ApiResource/MappedResourceWithInput.php b/tests/Fixtures/TestBundle/ApiResource/MappedResourceWithInput.php index f85e218fc39..5f14e31ed9b 100644 --- a/tests/Fixtures/TestBundle/ApiResource/MappedResourceWithInput.php +++ b/tests/Fixtures/TestBundle/ApiResource/MappedResourceWithInput.php @@ -15,7 +15,6 @@ use ApiPlatform\Doctrine\Orm\State\Options; use ApiPlatform\JsonLd\ContextBuilder; -use ApiPlatform\Metadata\Operation; use ApiPlatform\Metadata\Post; use ApiPlatform\Tests\Fixtures\TestBundle\Dto\MappedResouceInput; use ApiPlatform\Tests\Fixtures\TestBundle\Entity\MappedEntity; @@ -35,7 +34,7 @@ final class MappedResourceWithInput public ?string $id = null; public string $username; - public static function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []) + public static function process(mixed $data): self { $s = new self(); $s->id = $data->id; diff --git a/tests/Fixtures/TestBundle/ApiResource/PostWithUriVariables.php b/tests/Fixtures/TestBundle/ApiResource/PostWithUriVariables.php index 4c3f36bb2c5..f4456840c10 100644 --- a/tests/Fixtures/TestBundle/ApiResource/PostWithUriVariables.php +++ b/tests/Fixtures/TestBundle/ApiResource/PostWithUriVariables.php @@ -32,7 +32,7 @@ public static function process(): self return new self(id: 1); } - public static function provide(): void + public static function provide(): never { throw new ValidationException(new ConstraintViolationList()); } diff --git a/tests/Fixtures/TestBundle/ApiResource/Product.php b/tests/Fixtures/TestBundle/ApiResource/Product.php index c5f7dba9ab3..eb327954b73 100644 --- a/tests/Fixtures/TestBundle/ApiResource/Product.php +++ b/tests/Fixtures/TestBundle/ApiResource/Product.php @@ -43,7 +43,7 @@ class Product #[ApiProperty(property: 'name', iris: ['https://schema.org/name'])] public string $name; - public static function provide() + public static function provide(): self { $s = new self(); $s->code = 'test'; diff --git a/tests/Fixtures/TestBundle/ApiResource/StrictParameters.php b/tests/Fixtures/TestBundle/ApiResource/StrictParameters.php index c51a079ea00..93416952c43 100644 --- a/tests/Fixtures/TestBundle/ApiResource/StrictParameters.php +++ b/tests/Fixtures/TestBundle/ApiResource/StrictParameters.php @@ -28,7 +28,7 @@ class StrictParameters { public string $id; - public static function provider() + public static function provider(): self { return new self(); } diff --git a/tests/Fixtures/TestBundle/ApiResource/SubresourceCategory.php b/tests/Fixtures/TestBundle/ApiResource/SubresourceCategory.php index 66eaf24a9e1..13a1833455f 100644 --- a/tests/Fixtures/TestBundle/ApiResource/SubresourceCategory.php +++ b/tests/Fixtures/TestBundle/ApiResource/SubresourceCategory.php @@ -36,7 +36,7 @@ public function __construct( ) { } - public static function provideNull() + public static function provideNull(): null { return null; } diff --git a/tests/Fixtures/TestBundle/ApiResource/ValidateParameterBeforeProvider.php b/tests/Fixtures/TestBundle/ApiResource/ValidateParameterBeforeProvider.php index c6b657af389..1b426241106 100644 --- a/tests/Fixtures/TestBundle/ApiResource/ValidateParameterBeforeProvider.php +++ b/tests/Fixtures/TestBundle/ApiResource/ValidateParameterBeforeProvider.php @@ -38,7 +38,7 @@ )] class ValidateParameterBeforeProvider { - public static function provide(Operation $operation, array $uriVariables = [], array $context = []) + public static function provide(Operation $operation, array $uriVariables = [], array $context = []): JsonResponse { if (!$context['request']->query->get('search')) { throw new \RuntimeException('Not supposed to happen'); diff --git a/tests/Fixtures/TestBundle/ApiResource/WithParameter.php b/tests/Fixtures/TestBundle/ApiResource/WithParameter.php index 9c4f3c01304..06d10da42aa 100644 --- a/tests/Fixtures/TestBundle/ApiResource/WithParameter.php +++ b/tests/Fixtures/TestBundle/ApiResource/WithParameter.php @@ -360,12 +360,12 @@ class WithParameter #[Groups(['b', 'custom'])] public $b = 'bar'; - public static function collectionProvider() + public static function collectionProvider(): array { return [new self()]; } - public static function provide() + public static function provide(): self { return new self(); } diff --git a/tests/Fixtures/TestBundle/ApiResource/WithSecurityParameter.php b/tests/Fixtures/TestBundle/ApiResource/WithSecurityParameter.php index 4707c359fe9..97b1f0ed31b 100644 --- a/tests/Fixtures/TestBundle/ApiResource/WithSecurityParameter.php +++ b/tests/Fixtures/TestBundle/ApiResource/WithSecurityParameter.php @@ -30,7 +30,7 @@ )] class WithSecurityParameter { - public static function collectionProvider() + public static function collectionProvider(): array { return [new self()]; } diff --git a/tests/Fixtures/TestBundle/Controller/DummyDtoNoInput/CreateItemAction.php b/tests/Fixtures/TestBundle/Controller/DummyDtoNoInput/CreateItemAction.php index 70650f57b3d..1c2bb33e4b7 100644 --- a/tests/Fixtures/TestBundle/Controller/DummyDtoNoInput/CreateItemAction.php +++ b/tests/Fixtures/TestBundle/Controller/DummyDtoNoInput/CreateItemAction.php @@ -19,7 +19,7 @@ final class CreateItemAction { - public function __invoke(Request $request) + public function __invoke(Request $request): DummyDtoNoInput|DummyDtoNoInputDocument { $resourceClass = $request->attributes->get('_api_resource_class'); if (!\in_array($resourceClass, [DummyDtoNoInput::class, DummyDtoNoInputDocument::class], true)) { diff --git a/tests/Fixtures/TestBundle/Controller/DummyDtoNoInput/DoubleBatAction.php b/tests/Fixtures/TestBundle/Controller/DummyDtoNoInput/DoubleBatAction.php index 894568a5385..756fce2b22a 100644 --- a/tests/Fixtures/TestBundle/Controller/DummyDtoNoInput/DoubleBatAction.php +++ b/tests/Fixtures/TestBundle/Controller/DummyDtoNoInput/DoubleBatAction.php @@ -18,7 +18,7 @@ final class DoubleBatAction { - public function __invoke($data) + public function __invoke($data): DummyDtoNoInput|DummyDtoNoInputDocument { if (!$data instanceof DummyDtoNoInput && !$data instanceof DummyDtoNoInputDocument) { throw new \InvalidArgumentException(); diff --git a/tests/Fixtures/TestBundle/Controller/Payment/VoidPaymentAction.php b/tests/Fixtures/TestBundle/Controller/Payment/VoidPaymentAction.php index 9642ce86eb9..f93c471c6e2 100644 --- a/tests/Fixtures/TestBundle/Controller/Payment/VoidPaymentAction.php +++ b/tests/Fixtures/TestBundle/Controller/Payment/VoidPaymentAction.php @@ -18,7 +18,7 @@ final class VoidPaymentAction { - public function __invoke($data) + public function __invoke($data): \ApiPlatform\Tests\Fixtures\TestBundle\Entity\VoidPayment|\ApiPlatform\Tests\Fixtures\TestBundle\Document\VoidPayment|null { if (!$data instanceof Payment && !$data instanceof PaymentDocument) { throw new \InvalidArgumentException(); diff --git a/tests/Fixtures/TestBundle/Doctrine/Generator/Uuid.php b/tests/Fixtures/TestBundle/Doctrine/Generator/Uuid.php index 125556e808b..ac659e283c9 100644 --- a/tests/Fixtures/TestBundle/Doctrine/Generator/Uuid.php +++ b/tests/Fixtures/TestBundle/Doctrine/Generator/Uuid.php @@ -17,10 +17,6 @@ class Uuid implements \JsonSerializable, \Stringable { private string $id = 'foo'; - public function __construct() - { - } - public function __toString(): string { return $this->id; diff --git a/tests/Fixtures/TestBundle/Document/ArrayFilterValidator.php b/tests/Fixtures/TestBundle/Document/ArrayFilterValidator.php index 22da35f4a03..7595f5a29b8 100644 --- a/tests/Fixtures/TestBundle/Document/ArrayFilterValidator.php +++ b/tests/Fixtures/TestBundle/Document/ArrayFilterValidator.php @@ -40,7 +40,7 @@ public function getId(): ?int return $this->id; } - public function setName($name): void + public function setName(?string $name): void { $this->name = $name; } diff --git a/tests/Fixtures/TestBundle/Document/CompositeLabel.php b/tests/Fixtures/TestBundle/Document/CompositeLabel.php index 5794548455d..54f17cd9dec 100644 --- a/tests/Fixtures/TestBundle/Document/CompositeLabel.php +++ b/tests/Fixtures/TestBundle/Document/CompositeLabel.php @@ -51,7 +51,7 @@ public function getValue(): ?string * * @param string|null $value the value to set */ - public function setValue($value = null): void + public function setValue(?string $value = null): void { $this->value = $value; } diff --git a/tests/Fixtures/TestBundle/Document/CompositeRelation.php b/tests/Fixtures/TestBundle/Document/CompositeRelation.php index cf0a9547b37..5cacb7a9a9d 100644 --- a/tests/Fixtures/TestBundle/Document/CompositeRelation.php +++ b/tests/Fixtures/TestBundle/Document/CompositeRelation.php @@ -57,7 +57,7 @@ public function getValue(): ?string * * @param string|null $value the value to set */ - public function setValue($value = null): void + public function setValue(?string $value = null): void { $this->value = $value; } diff --git a/tests/Fixtures/TestBundle/Document/ConcreteDummy.php b/tests/Fixtures/TestBundle/Document/ConcreteDummy.php index 0e10bad5d7b..9008bde6498 100644 --- a/tests/Fixtures/TestBundle/Document/ConcreteDummy.php +++ b/tests/Fixtures/TestBundle/Document/ConcreteDummy.php @@ -30,7 +30,7 @@ class ConcreteDummy extends AbstractDummy #[ODM\Field] private ?string $instance = null; - public function setInstance($instance): void + public function setInstance(?string $instance): void { $this->instance = $instance; } diff --git a/tests/Fixtures/TestBundle/Document/CustomIdentifierDummy.php b/tests/Fixtures/TestBundle/Document/CustomIdentifierDummy.php index bb26debd0d7..14b7622adcb 100644 --- a/tests/Fixtures/TestBundle/Document/CustomIdentifierDummy.php +++ b/tests/Fixtures/TestBundle/Document/CustomIdentifierDummy.php @@ -44,10 +44,7 @@ public function getName(): string return $this->name; } - /** - * @param string $name - */ - public function setName($name): void + public function setName(?string $name): void { $this->name = $name; } diff --git a/tests/Fixtures/TestBundle/Document/CustomNormalizedDummy.php b/tests/Fixtures/TestBundle/Document/CustomNormalizedDummy.php index 27354bceaa6..5785f5e9e73 100644 --- a/tests/Fixtures/TestBundle/Document/CustomNormalizedDummy.php +++ b/tests/Fixtures/TestBundle/Document/CustomNormalizedDummy.php @@ -57,10 +57,7 @@ public function getId(): ?int return $this->id; } - /** - * @param string $name - */ - public function setName($name): void + public function setName(?string $name): void { $this->name = $name; } @@ -75,10 +72,7 @@ public function getAlias(): ?string return $this->alias; } - /** - * @param string $alias - */ - public function setAlias($alias): void + public function setAlias(?string $alias): void { $this->alias = $alias; } @@ -88,10 +82,7 @@ public function getPersonalizedAlias(): ?string return $this->alias; } - /** - * @param string $value - */ - public function setPersonalizedAlias($value): void + public function setPersonalizedAlias(?string $value): void { $this->alias = $value; } diff --git a/tests/Fixtures/TestBundle/Document/CustomWritableIdentifierDummy.php b/tests/Fixtures/TestBundle/Document/CustomWritableIdentifierDummy.php index a9abf458479..8299767f7b8 100644 --- a/tests/Fixtures/TestBundle/Document/CustomWritableIdentifierDummy.php +++ b/tests/Fixtures/TestBundle/Document/CustomWritableIdentifierDummy.php @@ -34,10 +34,7 @@ class CustomWritableIdentifierDummy #[ODM\Field(name: 'name', type: 'string')] private ?string $name = null; - /** - * @param string $slug - */ - public function setSlug($slug): void + public function setSlug(?string $slug): void { $this->slug = $slug; } @@ -52,10 +49,7 @@ public function getName(): string return $this->name; } - /** - * @param string $name - */ - public function setName($name): void + public function setName(?string $name): void { $this->name = $name; } diff --git a/tests/Fixtures/TestBundle/Document/Dummy.php b/tests/Fixtures/TestBundle/Document/Dummy.php index c47a817705f..17842a398bb 100644 --- a/tests/Fixtures/TestBundle/Document/Dummy.php +++ b/tests/Fixtures/TestBundle/Document/Dummy.php @@ -83,7 +83,7 @@ class Dummy #[Context(denormalizationContext: ['datetime_format' => 'Y-m-d'])] #[ApiProperty(iris: ['https://schema.org/DateTime'])] #[ODM\Field(type: 'date', nullable: true)] - private $dummyDateWithFormat; + private ?\DateTime $dummyDateWithFormat; /** * @var float|null A dummy float */ @@ -133,7 +133,7 @@ public function getId(): ?int return $this->id; } - public function setId($id): void + public function setId(?int $id): void { $this->id = $id; } @@ -188,12 +188,12 @@ public function getDummyDate() return $this->dummyDate; } - public function getDummyDateWithFormat() + public function getDummyDateWithFormat(): ?\DateTime { return $this->dummyDateWithFormat; } - public function setDummyPrice($dummyPrice) + public function setDummyPrice($dummyPrice): static { $this->dummyPrice = $dummyPrice; diff --git a/tests/Fixtures/TestBundle/Document/DummyCarColor.php b/tests/Fixtures/TestBundle/Document/DummyCarColor.php index 6921b5ff51a..a86c8c95d4a 100644 --- a/tests/Fixtures/TestBundle/Document/DummyCarColor.php +++ b/tests/Fixtures/TestBundle/Document/DummyCarColor.php @@ -48,10 +48,7 @@ public function getCar(): ?DummyCar return $this->car; } - /** - * @return static - */ - public function setCar(DummyCar $car) + public function setCar(DummyCar $car): static { $this->car = $car; @@ -63,12 +60,7 @@ public function getProp(): string return $this->prop; } - /** - * @param string $prop - * - * @return static - */ - public function setProp($prop) + public function setProp(string $prop): static { $this->prop = $prop; diff --git a/tests/Fixtures/TestBundle/Document/DummyFriend.php b/tests/Fixtures/TestBundle/Document/DummyFriend.php index dbee6c9a427..9ffae70f0f1 100644 --- a/tests/Fixtures/TestBundle/Document/DummyFriend.php +++ b/tests/Fixtures/TestBundle/Document/DummyFriend.php @@ -56,7 +56,7 @@ public function getId(): ?int * * @param int $id the value to set */ - public function setId($id): void + public function setId(?int $id): void { $this->id = $id; } diff --git a/tests/Fixtures/TestBundle/Document/DummyTableInheritanceNotApiResourceChild.php b/tests/Fixtures/TestBundle/Document/DummyTableInheritanceNotApiResourceChild.php index 1d95fb60ab2..ea32e7531f7 100644 --- a/tests/Fixtures/TestBundle/Document/DummyTableInheritanceNotApiResourceChild.php +++ b/tests/Fixtures/TestBundle/Document/DummyTableInheritanceNotApiResourceChild.php @@ -24,10 +24,6 @@ class DummyTableInheritanceNotApiResourceChild extends DummyTableInheritance #[ODM\Field(type: 'bool')] private bool $swaggerThanParent = true; - public function __construct() - { - } - public function isSwaggerThanParent(): bool { return $this->swaggerThanParent; diff --git a/tests/Fixtures/TestBundle/Document/DummyTableInheritanceRelated.php b/tests/Fixtures/TestBundle/Document/DummyTableInheritanceRelated.php index 2df83b891b1..41b26752afb 100644 --- a/tests/Fixtures/TestBundle/Document/DummyTableInheritanceRelated.php +++ b/tests/Fixtures/TestBundle/Document/DummyTableInheritanceRelated.php @@ -51,14 +51,14 @@ public function getChildren(): Collection|iterable return $this->children; } - public function setChildren(Collection|iterable $children) + public function setChildren(Collection|iterable $children): static { $this->children = $children; return $this; } - public function addChild($child) + public function addChild($child): static { $this->children->add($child); $child->setParent($this); @@ -66,7 +66,7 @@ public function addChild($child) return $this; } - public function removeChild($child) + public function removeChild(string|int $child): static { $this->children->remove($child); diff --git a/tests/Fixtures/TestBundle/Document/DummyValidation.php b/tests/Fixtures/TestBundle/Document/DummyValidation.php index 25210cbd70f..d7bc66c8856 100644 --- a/tests/Fixtures/TestBundle/Document/DummyValidation.php +++ b/tests/Fixtures/TestBundle/Document/DummyValidation.php @@ -69,10 +69,7 @@ public function getName(): ?string return $this->name; } - /** - * @param string|null $name - */ - public function setName($name): self + public function setName(?string $name): self { $this->name = $name; @@ -84,10 +81,7 @@ public function getTitle(): ?string return $this->title; } - /** - * @param string|null $title - */ - public function setTitle($title): self + public function setTitle(?string $title): self { $this->title = $title; @@ -99,10 +93,7 @@ public function getCode(): ?string return $this->code; } - /** - * @param string $code - */ - public function setCode($code): self + public function setCode(?string $code): self { $this->code = $code; diff --git a/tests/Fixtures/TestBundle/Document/EmbeddableDummy.php b/tests/Fixtures/TestBundle/Document/EmbeddableDummy.php index 7e09b431f08..1c773aed9f5 100644 --- a/tests/Fixtures/TestBundle/Document/EmbeddableDummy.php +++ b/tests/Fixtures/TestBundle/Document/EmbeddableDummy.php @@ -61,10 +61,6 @@ public static function staticMethod(): void { } - public function __construct() - { - } - public function getDummyName(): ?string { return $this->dummyName; diff --git a/tests/Fixtures/TestBundle/Document/FooDummy.php b/tests/Fixtures/TestBundle/Document/FooDummy.php index c29cab1a41c..ac2c12b2ea9 100644 --- a/tests/Fixtures/TestBundle/Document/FooDummy.php +++ b/tests/Fixtures/TestBundle/Document/FooDummy.php @@ -43,7 +43,7 @@ class FooDummy private $name; #[ODM\Field(nullable: true)] - private $nonWritableProp; + private string $nonWritableProp; /** * @var Dummy The foo dummy @@ -82,7 +82,7 @@ public function getName() return $this->name; } - public function getNonWritableProp() + public function getNonWritableProp(): string { return $this->nonWritableProp; } diff --git a/tests/Fixtures/TestBundle/Document/FooEmbeddable.php b/tests/Fixtures/TestBundle/Document/FooEmbeddable.php index bf12471cfa9..c2191eb5f97 100644 --- a/tests/Fixtures/TestBundle/Document/FooEmbeddable.php +++ b/tests/Fixtures/TestBundle/Document/FooEmbeddable.php @@ -32,10 +32,6 @@ class FooEmbeddable #[ODM\Field(nullable: true)] private $nonWritableProp; - public function __construct() - { - } - public function getDummyName(): ?string { return $this->dummyName; diff --git a/tests/Fixtures/TestBundle/Document/JsonSchemaContextDummy.php b/tests/Fixtures/TestBundle/Document/JsonSchemaContextDummy.php index 020f06b1145..730a5e29fc0 100644 --- a/tests/Fixtures/TestBundle/Document/JsonSchemaContextDummy.php +++ b/tests/Fixtures/TestBundle/Document/JsonSchemaContextDummy.php @@ -36,8 +36,6 @@ class JsonSchemaContextDummy private $id; /** - * @var array - * * @ApiProperty( * attributes={ * "json_schema_context"={ @@ -49,14 +47,14 @@ class JsonSchemaContextDummy * }, * ) */ - private $things = ['pool', 'bag']; + private array $things = ['pool', 'bag']; public function getId() { return $this->id; } - public function getThings() + public function getThings(): array { return $this->things; } diff --git a/tests/Fixtures/TestBundle/Document/MultiRelationsDummy.php b/tests/Fixtures/TestBundle/Document/MultiRelationsDummy.php index 286f5465b2d..5ee4a1b254e 100644 --- a/tests/Fixtures/TestBundle/Document/MultiRelationsDummy.php +++ b/tests/Fixtures/TestBundle/Document/MultiRelationsDummy.php @@ -104,7 +104,7 @@ public function addOneToManyRelation(MultiRelationsRelatedDummy $relatedMultiUse public function getNestedCollection(): Collection { - return $this->nestedCollection->map(static fn ($entry) => ['name' => $entry->name]); + return $this->nestedCollection->map(static fn ($entry): array => ['name' => $entry->name]); } public function setNestedCollection(Collection $nestedCollection): self @@ -116,7 +116,7 @@ public function setNestedCollection(Collection $nestedCollection): self public function getNestedPaginatedCollection(): Collection { - return $this->nestedPaginatedCollection->map(static fn ($entry) => ['name' => $entry->name]); + return $this->nestedPaginatedCollection->map(static fn ($entry): array => ['name' => $entry->name]); } public function setNestedPaginatedCollection(Collection $nestedPaginatedCollection): self diff --git a/tests/Fixtures/TestBundle/Document/Question.php b/tests/Fixtures/TestBundle/Document/Question.php index 881d70fc540..aba19faba65 100644 --- a/tests/Fixtures/TestBundle/Document/Question.php +++ b/tests/Fixtures/TestBundle/Document/Question.php @@ -33,10 +33,8 @@ class Question /** * Set content. - * - * @param string $content */ - public function setContent($content): self + public function setContent(string $content): self { $this->content = $content; diff --git a/tests/Fixtures/TestBundle/Document/ReadableOnlyProperty.php b/tests/Fixtures/TestBundle/Document/ReadableOnlyProperty.php index 3626bf5994d..e2f20c05261 100644 --- a/tests/Fixtures/TestBundle/Document/ReadableOnlyProperty.php +++ b/tests/Fixtures/TestBundle/Document/ReadableOnlyProperty.php @@ -28,10 +28,6 @@ class ReadableOnlyProperty #[ODM\Field] private string $name = 'Read only'; - public function __construct() - { - } - public function getId(): ?int { return $this->id; diff --git a/tests/Fixtures/TestBundle/Document/RelatedDummy.php b/tests/Fixtures/TestBundle/Document/RelatedDummy.php index d61a7adfa35..00ac0767f66 100644 --- a/tests/Fixtures/TestBundle/Document/RelatedDummy.php +++ b/tests/Fixtures/TestBundle/Document/RelatedDummy.php @@ -135,10 +135,7 @@ public function isDummyBoolean(): ?bool return $this->dummyBoolean; } - /** - * @param bool $dummyBoolean - */ - public function setDummyBoolean($dummyBoolean): void + public function setDummyBoolean(?bool $dummyBoolean): void { $this->dummyBoolean = $dummyBoolean; } diff --git a/tests/Fixtures/TestBundle/Document/RelatedNormalizedDummy.php b/tests/Fixtures/TestBundle/Document/RelatedNormalizedDummy.php index e7ff4782cbc..74047cf0b7b 100644 --- a/tests/Fixtures/TestBundle/Document/RelatedNormalizedDummy.php +++ b/tests/Fixtures/TestBundle/Document/RelatedNormalizedDummy.php @@ -59,10 +59,7 @@ public function getId(): ?int return $this->id; } - /** - * @param string $name - */ - public function setName($name): void + public function setName(?string $name): void { $this->name = $name; } diff --git a/tests/Fixtures/TestBundle/Document/RelatedToDummyFriend.php b/tests/Fixtures/TestBundle/Document/RelatedToDummyFriend.php index f68b87cf7d7..5c2228aa5e1 100644 --- a/tests/Fixtures/TestBundle/Document/RelatedToDummyFriend.php +++ b/tests/Fixtures/TestBundle/Document/RelatedToDummyFriend.php @@ -82,10 +82,7 @@ public function getDescription(): ?string return $this->description; } - /** - * @param string|null $description - */ - public function setDescription($description): void + public function setDescription(?string $description): void { $this->description = $description; } diff --git a/tests/Fixtures/TestBundle/Document/SlugParentDummy.php b/tests/Fixtures/TestBundle/Document/SlugParentDummy.php index ed34ea94bd6..bfa1eff9b11 100644 --- a/tests/Fixtures/TestBundle/Document/SlugParentDummy.php +++ b/tests/Fixtures/TestBundle/Document/SlugParentDummy.php @@ -94,7 +94,7 @@ public function removeChildDummy(SlugChildDummy $childDummy): self $this->childDummies->removeElement($childDummy); // set the owning side to null (unless already changed) if ($childDummy->getParentDummy() === $this) { - $childDummy->setParentDummy(null); + $childDummy->setParentDummy(); } } diff --git a/tests/Fixtures/TestBundle/Document/VoDummyInspection.php b/tests/Fixtures/TestBundle/Document/VoDummyInspection.php index 29ef49d9017..ccdbf6e17c6 100644 --- a/tests/Fixtures/TestBundle/Document/VoDummyInspection.php +++ b/tests/Fixtures/TestBundle/Document/VoDummyInspection.php @@ -26,7 +26,7 @@ class VoDummyInspection #[ODM\Field(type: 'date')] private \DateTime $performed; - private $attributeWithoutConstructorEquivalent; + private string $attributeWithoutConstructorEquivalent; public function __construct(#[Groups(['car_read', 'car_write', 'inspection_read', 'inspection_write'])] #[ODM\Field(type: 'bool')] private bool $accepted, #[Groups(['inspection_read', 'inspection_write'])] #[ODM\ReferenceOne(targetDocument: VoDummyCar::class, inversedBy: 'inspections')] private VoDummyCar $car, ?\DateTime $performed = null, string $parameterWhichIsNotClassAttribute = '') { @@ -49,7 +49,7 @@ public function getPerformed(): \DateTime return $this->performed; } - public function setPerformed(\DateTime $performed) + public function setPerformed(\DateTime $performed): static { $this->performed = $performed; diff --git a/tests/Fixtures/TestBundle/Entity/Answer.php b/tests/Fixtures/TestBundle/Entity/Answer.php index 0eda5f4063a..0465d1dd8b7 100644 --- a/tests/Fixtures/TestBundle/Entity/Answer.php +++ b/tests/Fixtures/TestBundle/Entity/Answer.php @@ -67,10 +67,8 @@ public function getId(): ?int /** * Set content. - * - * @param string $content */ - public function setContent($content): self + public function setContent(?string $content): self { $this->content = $content; diff --git a/tests/Fixtures/TestBundle/Entity/CompositeItem.php b/tests/Fixtures/TestBundle/Entity/CompositeItem.php index 5954245ba48..2a27ff1dcd7 100644 --- a/tests/Fixtures/TestBundle/Entity/CompositeItem.php +++ b/tests/Fixtures/TestBundle/Entity/CompositeItem.php @@ -63,7 +63,7 @@ public function getField1(): ?string * * @param string|null $field1 the value to set */ - public function setField1($field1 = null): void + public function setField1(?string $field1 = null): void { $this->field1 = $field1; } diff --git a/tests/Fixtures/TestBundle/Entity/CompositeRelation.php b/tests/Fixtures/TestBundle/Entity/CompositeRelation.php index a876c6088df..b810cc96f90 100644 --- a/tests/Fixtures/TestBundle/Entity/CompositeRelation.php +++ b/tests/Fixtures/TestBundle/Entity/CompositeRelation.php @@ -51,7 +51,7 @@ public function getValue(): ?string * * @param string|null $value the value to set */ - public function setValue($value = null): void + public function setValue(?string $value = null): void { $this->value = $value; } diff --git a/tests/Fixtures/TestBundle/Entity/CustomIdentifierDummy.php b/tests/Fixtures/TestBundle/Entity/CustomIdentifierDummy.php index 1427ed4182a..8ec7a4627e0 100644 --- a/tests/Fixtures/TestBundle/Entity/CustomIdentifierDummy.php +++ b/tests/Fixtures/TestBundle/Entity/CustomIdentifierDummy.php @@ -46,10 +46,7 @@ public function getName(): string return $this->name; } - /** - * @param string $name - */ - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } diff --git a/tests/Fixtures/TestBundle/Entity/CustomWritableIdentifierDummy.php b/tests/Fixtures/TestBundle/Entity/CustomWritableIdentifierDummy.php index 4b5dd9ff316..f3d6946c47f 100644 --- a/tests/Fixtures/TestBundle/Entity/CustomWritableIdentifierDummy.php +++ b/tests/Fixtures/TestBundle/Entity/CustomWritableIdentifierDummy.php @@ -35,10 +35,7 @@ class CustomWritableIdentifierDummy #[ORM\Column(name: 'name', type: 'string', length: 30)] private string $name; - /** - * @param string $slug - */ - public function setSlug($slug): void + public function setSlug(string $slug): void { $this->slug = $slug; } @@ -53,10 +50,7 @@ public function getName(): string return $this->name; } - /** - * @param string $name - */ - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } diff --git a/tests/Fixtures/TestBundle/Entity/Dummy.php b/tests/Fixtures/TestBundle/Entity/Dummy.php index c3cfde6c23f..71bc5ef9947 100644 --- a/tests/Fixtures/TestBundle/Entity/Dummy.php +++ b/tests/Fixtures/TestBundle/Entity/Dummy.php @@ -95,7 +95,7 @@ class Dummy #[Context(denormalizationContext: ['datetime_format' => 'Y-m-d'])] #[ApiProperty(iris: ['https://schema.org/DateTime'])] #[ORM\Column(type: 'datetime', nullable: true)] - private $dummyDateWithFormat; + private ?\DateTime $dummyDateWithFormat; /** * @var float|null A dummy float @@ -220,12 +220,12 @@ public function getDummyDate() return $this->dummyDate; } - public function getDummyDateWithFormat() + public function getDummyDateWithFormat(): ?\DateTime { return $this->dummyDateWithFormat; } - public function setDummyPrice($dummyPrice) + public function setDummyPrice($dummyPrice): static { $this->dummyPrice = $dummyPrice; @@ -300,10 +300,7 @@ public function isDummyBoolean(): ?bool return $this->dummyBoolean; } - /** - * @param bool $dummyBoolean - */ - public function setDummyBoolean($dummyBoolean): void + public function setDummyBoolean(?bool $dummyBoolean): void { $this->dummyBoolean = $dummyBoolean; } diff --git a/tests/Fixtures/TestBundle/Entity/DummyCar.php b/tests/Fixtures/TestBundle/Entity/DummyCar.php index 7749d3ccc9b..db767ad476a 100644 --- a/tests/Fixtures/TestBundle/Entity/DummyCar.php +++ b/tests/Fixtures/TestBundle/Entity/DummyCar.php @@ -110,7 +110,7 @@ public function getSecondColors(): ?iterable return $this->secondColors; } - public function setSecondColors($secondColors): void + public function setSecondColors(?iterable $secondColors): void { $this->secondColors = $secondColors; } @@ -120,7 +120,7 @@ public function getThirdColors(): ?iterable return $this->thirdColors; } - public function setThirdColors($thirdColors): void + public function setThirdColors(?iterable $thirdColors): void { $this->thirdColors = $thirdColors; } @@ -130,7 +130,7 @@ public function getUuid(): ?iterable return $this->uuid; } - public function setUuid($uuid): void + public function setUuid(?iterable $uuid): void { $this->uuid = $uuid; } diff --git a/tests/Fixtures/TestBundle/Entity/DummyCarColor.php b/tests/Fixtures/TestBundle/Entity/DummyCarColor.php index f1d90e2ebac..b7593d18f73 100644 --- a/tests/Fixtures/TestBundle/Entity/DummyCarColor.php +++ b/tests/Fixtures/TestBundle/Entity/DummyCarColor.php @@ -51,10 +51,7 @@ public function getCar(): ?DummyCar return $this->car; } - /** - * @return static - */ - public function setCar(DummyCar $car) + public function setCar(DummyCar $car): static { $this->car = $car; @@ -66,12 +63,7 @@ public function getProp(): string return $this->prop; } - /** - * @param string $prop - * - * @return static - */ - public function setProp($prop) + public function setProp(string $prop): static { $this->prop = $prop; diff --git a/tests/Fixtures/TestBundle/Entity/DummyProblem.php b/tests/Fixtures/TestBundle/Entity/DummyProblem.php index a6bf31b5dc9..e064a9ae74c 100644 --- a/tests/Fixtures/TestBundle/Entity/DummyProblem.php +++ b/tests/Fixtures/TestBundle/Entity/DummyProblem.php @@ -206,7 +206,7 @@ public function getDummyDate() return $this->dummyDate; } - public function setDummyPrice($dummyPrice) + public function setDummyPrice($dummyPrice): static { $this->dummyPrice = $dummyPrice; @@ -278,10 +278,7 @@ public function isDummyBoolean(): ?bool return $this->dummyBoolean; } - /** - * @param bool $dummyBoolean - */ - public function setDummyBoolean($dummyBoolean): void + public function setDummyBoolean(?bool $dummyBoolean): void { $this->dummyBoolean = $dummyBoolean; } diff --git a/tests/Fixtures/TestBundle/Entity/DummyResourceWithComplexConstructor.php b/tests/Fixtures/TestBundle/Entity/DummyResourceWithComplexConstructor.php index 224206c15bf..0393c0200e4 100644 --- a/tests/Fixtures/TestBundle/Entity/DummyResourceWithComplexConstructor.php +++ b/tests/Fixtures/TestBundle/Entity/DummyResourceWithComplexConstructor.php @@ -36,7 +36,7 @@ public function __construct(private int $id, private string $name) $this->someInternalTimestamp = new \DateTimeImmutable(); } - public function getId() + public function getId(): int { return $this->id; } diff --git a/tests/Fixtures/TestBundle/Entity/DummySubEntity.php b/tests/Fixtures/TestBundle/Entity/DummySubEntity.php index 1743843c299..da8c9090d96 100644 --- a/tests/Fixtures/TestBundle/Entity/DummySubEntity.php +++ b/tests/Fixtures/TestBundle/Entity/DummySubEntity.php @@ -28,7 +28,7 @@ class DummySubEntity #[ORM\OneToOne(inversedBy: 'subEntity', cascade: ['persist'])] private ?DummyWithSubEntity $mainEntity = null; - public function __construct($strId, $name) + public function __construct(string $strId, string $name) { $this->strId = $strId; $this->name = $name; diff --git a/tests/Fixtures/TestBundle/Entity/DummyTableInheritanceNotApiResourceChild.php b/tests/Fixtures/TestBundle/Entity/DummyTableInheritanceNotApiResourceChild.php index 94e1348dae1..40fe3ace9f6 100644 --- a/tests/Fixtures/TestBundle/Entity/DummyTableInheritanceNotApiResourceChild.php +++ b/tests/Fixtures/TestBundle/Entity/DummyTableInheritanceNotApiResourceChild.php @@ -24,10 +24,6 @@ class DummyTableInheritanceNotApiResourceChild extends DummyTableInheritance #[ORM\Column(type: 'boolean')] private bool $swaggerThanParent = true; - public function __construct() - { - } - public function isSwaggerThanParent(): bool { return $this->swaggerThanParent; diff --git a/tests/Fixtures/TestBundle/Entity/DummyTableInheritanceRelated.php b/tests/Fixtures/TestBundle/Entity/DummyTableInheritanceRelated.php index f9359f1f2b7..368702b75bc 100644 --- a/tests/Fixtures/TestBundle/Entity/DummyTableInheritanceRelated.php +++ b/tests/Fixtures/TestBundle/Entity/DummyTableInheritanceRelated.php @@ -54,14 +54,14 @@ public function getChildren(): Collection|iterable return $this->children; } - public function setChildren(Collection|iterable $children) + public function setChildren(Collection|iterable $children): static { $this->children = $children; return $this; } - public function addChild($child) + public function addChild($child): static { $this->children->add($child); $child->setParent($this); @@ -69,7 +69,7 @@ public function addChild($child) return $this; } - public function removeChild($child) + public function removeChild(string|int $child): static { $this->children->remove($child); diff --git a/tests/Fixtures/TestBundle/Entity/EmbeddableDummy.php b/tests/Fixtures/TestBundle/Entity/EmbeddableDummy.php index 70aa043b522..45f97d9ae22 100644 --- a/tests/Fixtures/TestBundle/Entity/EmbeddableDummy.php +++ b/tests/Fixtures/TestBundle/Entity/EmbeddableDummy.php @@ -62,10 +62,6 @@ public static function staticMethod(): void { } - public function __construct() - { - } - public function getDummyName(): ?string { return $this->dummyName; diff --git a/tests/Fixtures/TestBundle/Entity/FooDummy.php b/tests/Fixtures/TestBundle/Entity/FooDummy.php index ae6e98e8a1c..e96c2144d19 100644 --- a/tests/Fixtures/TestBundle/Entity/FooDummy.php +++ b/tests/Fixtures/TestBundle/Entity/FooDummy.php @@ -45,7 +45,7 @@ class FooDummy private $name; #[ORM\Column(nullable: true)] - private $nonWritableProp; + private ?string $nonWritableProp = null; #[ApiProperty(readableLink: true, writableLink: true)] #[ORM\Embedded(class: FooEmbeddable::class)] @@ -84,7 +84,7 @@ public function getName() return $this->name; } - public function getNonWritableProp() + public function getNonWritableProp(): string { return $this->nonWritableProp; } diff --git a/tests/Fixtures/TestBundle/Entity/FooEmbeddable.php b/tests/Fixtures/TestBundle/Entity/FooEmbeddable.php index 5ae58ed07f0..28cfa6aff30 100644 --- a/tests/Fixtures/TestBundle/Entity/FooEmbeddable.php +++ b/tests/Fixtures/TestBundle/Entity/FooEmbeddable.php @@ -34,11 +34,7 @@ class FooEmbeddable private ?string $dummyName = null; #[ORM\Column(nullable: true)] - private $nonWritableProp; // @phpstan-ignore-line - - public function __construct() - { - } + private $nonWritableProp; public function getDummyName(): ?string { diff --git a/tests/Fixtures/TestBundle/Entity/Issue5722/Event.php b/tests/Fixtures/TestBundle/Entity/Issue5722/Event.php index 159445c22c5..14c4da60cb1 100644 --- a/tests/Fixtures/TestBundle/Entity/Issue5722/Event.php +++ b/tests/Fixtures/TestBundle/Entity/Issue5722/Event.php @@ -38,6 +38,9 @@ class Event #[ApiProperty(readable: false, writable: false, identifier: false)] public $id; + /** + * @var \Ramsey\Uuid\UuidInterface + */ #[ApiProperty(writable: false, identifier: true)] #[ORM\Column(type: 'uuid', unique: true)] public $uuid; diff --git a/tests/Fixtures/TestBundle/Entity/Issue5722/ItemLog.php b/tests/Fixtures/TestBundle/Entity/Issue5722/ItemLog.php index 699a561666a..868a6b39d9b 100644 --- a/tests/Fixtures/TestBundle/Entity/Issue5722/ItemLog.php +++ b/tests/Fixtures/TestBundle/Entity/Issue5722/ItemLog.php @@ -44,6 +44,9 @@ class ItemLog #[ApiProperty(readable: false, writable: false, identifier: false)] // identifier was false before 3.1.14, changing this to true fixed some errors private ?int $id = null; + /** + * @var \Ramsey\Uuid\UuidInterface + */ #[ApiProperty(writable: false, identifier: true)] #[ORM\Column(type: 'uuid', unique: true)] public $uuid; @@ -55,11 +58,8 @@ class ItemLog #[ORM\Column] public string $action = 'insert'; - private \DateTimeInterface $createdAt; - public function __construct() { - $this->createdAt = new \DateTime(); $this->uuid = Uuid::uuid4(); } diff --git a/tests/Fixtures/TestBundle/Entity/Issue5735/Issue5735User.php b/tests/Fixtures/TestBundle/Entity/Issue5735/Issue5735User.php index f5018064b6c..5541adee21c 100644 --- a/tests/Fixtures/TestBundle/Entity/Issue5735/Issue5735User.php +++ b/tests/Fixtures/TestBundle/Entity/Issue5735/Issue5735User.php @@ -60,7 +60,7 @@ public function getUuid(): Uuid return $this->uuid; } - public function setUuid($uuid): void + public function setUuid(Uuid $uuid): void { $this->uuid = $uuid; } diff --git a/tests/Fixtures/TestBundle/Entity/JsonSchemaContextDummy.php b/tests/Fixtures/TestBundle/Entity/JsonSchemaContextDummy.php index 82b01b6c923..5a23112f084 100644 --- a/tests/Fixtures/TestBundle/Entity/JsonSchemaContextDummy.php +++ b/tests/Fixtures/TestBundle/Entity/JsonSchemaContextDummy.php @@ -33,9 +33,6 @@ class JsonSchemaContextDummy #[ORM\GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var array - */ #[ApiProperty( jsonSchemaContext: [ 'type' => 'array', @@ -44,14 +41,14 @@ class JsonSchemaContextDummy 'maxItems' => 2, ] )] - private $things = ['pool', 'bag']; + private array $things = ['pool', 'bag']; public function getId() { return $this->id; } - public function getThings() + public function getThings(): array { return $this->things; } diff --git a/tests/Fixtures/TestBundle/Entity/MappedResourceWithRelationEntity.php b/tests/Fixtures/TestBundle/Entity/MappedResourceWithRelationEntity.php index c948283e35a..61baa33b66e 100644 --- a/tests/Fixtures/TestBundle/Entity/MappedResourceWithRelationEntity.php +++ b/tests/Fixtures/TestBundle/Entity/MappedResourceWithRelationEntity.php @@ -40,7 +40,7 @@ public function getId(): ?int return $this->id; } - public function setId(?int $id = null) + public function setId(?int $id = null): static { $this->id = $id; diff --git a/tests/Fixtures/TestBundle/Entity/MappedResourceWithRelationRelatedEntity.php b/tests/Fixtures/TestBundle/Entity/MappedResourceWithRelationRelatedEntity.php index 5f10689fdd5..4af48f8ecc1 100644 --- a/tests/Fixtures/TestBundle/Entity/MappedResourceWithRelationRelatedEntity.php +++ b/tests/Fixtures/TestBundle/Entity/MappedResourceWithRelationRelatedEntity.php @@ -32,7 +32,7 @@ public function getId(): ?int return $this->id; } - public function setId(?int $id = null) + public function setId(?int $id = null): void { $this->id = $id; } diff --git a/tests/Fixtures/TestBundle/Entity/NonCloneableDummy.php b/tests/Fixtures/TestBundle/Entity/NonCloneableDummy.php index 6c2ed38959d..6836508abe1 100644 --- a/tests/Fixtures/TestBundle/Entity/NonCloneableDummy.php +++ b/tests/Fixtures/TestBundle/Entity/NonCloneableDummy.php @@ -41,7 +41,7 @@ class NonCloneableDummy #[ApiProperty(iris: ['http://schema.org/name'])] #[ORM\Column] #[Assert\NotBlank] - private $name; + private string $name; public function getId() { diff --git a/tests/Fixtures/TestBundle/Entity/PlainObjectDummy.php b/tests/Fixtures/TestBundle/Entity/PlainObjectDummy.php index d46aeb65d8d..cc78a396198 100644 --- a/tests/Fixtures/TestBundle/Entity/PlainObjectDummy.php +++ b/tests/Fixtures/TestBundle/Entity/PlainObjectDummy.php @@ -29,10 +29,6 @@ class PlainObjectDummy #[ORM\Column(type: 'integer')] #[ORM\GeneratedValue(strategy: 'AUTO')] private $id; - /** - * @var string - */ - private $content; /** * @var array */ @@ -40,7 +36,6 @@ class PlainObjectDummy public function setContent($content): void { - $this->content = $content; $this->data = (array) json_decode($content, null, 512, \JSON_THROW_ON_ERROR); } diff --git a/tests/Fixtures/TestBundle/Entity/Question.php b/tests/Fixtures/TestBundle/Entity/Question.php index aa1b82cd74e..a854883773a 100644 --- a/tests/Fixtures/TestBundle/Entity/Question.php +++ b/tests/Fixtures/TestBundle/Entity/Question.php @@ -36,10 +36,8 @@ class Question /** * Set content. - * - * @param string $content */ - public function setContent($content): self + public function setContent(?string $content): self { $this->content = $content; diff --git a/tests/Fixtures/TestBundle/Entity/ReadableOnlyProperty.php b/tests/Fixtures/TestBundle/Entity/ReadableOnlyProperty.php index d10382cc2bc..5a7f6add458 100644 --- a/tests/Fixtures/TestBundle/Entity/ReadableOnlyProperty.php +++ b/tests/Fixtures/TestBundle/Entity/ReadableOnlyProperty.php @@ -30,10 +30,6 @@ class ReadableOnlyProperty #[ORM\Column] private string $name = 'Read only'; - public function __construct() - { - } - public function getId(): ?int { return $this->id; diff --git a/tests/Fixtures/TestBundle/Entity/RelatedDummy.php b/tests/Fixtures/TestBundle/Entity/RelatedDummy.php index b8a3f562363..56afa6f6e9d 100644 --- a/tests/Fixtures/TestBundle/Entity/RelatedDummy.php +++ b/tests/Fixtures/TestBundle/Entity/RelatedDummy.php @@ -156,10 +156,7 @@ public function isDummyBoolean(): ?bool return $this->dummyBoolean; } - /** - * @param bool $dummyBoolean - */ - public function setDummyBoolean($dummyBoolean): void + public function setDummyBoolean(?bool $dummyBoolean): void { $this->dummyBoolean = $dummyBoolean; } diff --git a/tests/Fixtures/TestBundle/Entity/RelatedToDummyFriend.php b/tests/Fixtures/TestBundle/Entity/RelatedToDummyFriend.php index d550249dd03..6ce71710b9b 100644 --- a/tests/Fixtures/TestBundle/Entity/RelatedToDummyFriend.php +++ b/tests/Fixtures/TestBundle/Entity/RelatedToDummyFriend.php @@ -74,10 +74,7 @@ public function getDescription(): ?string return $this->description; } - /** - * @param string|null $description - */ - public function setDescription($description): void + public function setDescription(?string $description): void { $this->description = $description; } diff --git a/tests/Fixtures/TestBundle/Entity/Relation3.php b/tests/Fixtures/TestBundle/Entity/Relation3.php index 412b0019544..97d07146f8b 100644 --- a/tests/Fixtures/TestBundle/Entity/Relation3.php +++ b/tests/Fixtures/TestBundle/Entity/Relation3.php @@ -42,14 +42,14 @@ public function getRelation2s(): Collection|iterable return $this->relation2s; } - public function addRelation2(Relation2 $relation) + public function addRelation2(Relation2 $relation): static { $this->relation2s->add($relation); return $this; } - public function removeRelation2(Relation2 $relation) + public function removeRelation2(Relation2 $relation): static { $this->relation2s->removeElement($relation); diff --git a/tests/Fixtures/TestBundle/Entity/SecuredDummyWithPropertiesDependingOnThemselves.php b/tests/Fixtures/TestBundle/Entity/SecuredDummyWithPropertiesDependingOnThemselves.php index f33129df6b9..9a4493af742 100644 --- a/tests/Fixtures/TestBundle/Entity/SecuredDummyWithPropertiesDependingOnThemselves.php +++ b/tests/Fixtures/TestBundle/Entity/SecuredDummyWithPropertiesDependingOnThemselves.php @@ -50,10 +50,6 @@ class SecuredDummyWithPropertiesDependingOnThemselves #[ORM\Column] private bool $property = false; - public function __construct() - { - } - public function getId(): ?int { return $this->id; diff --git a/tests/Fixtures/TestBundle/Entity/SlugParentDummy.php b/tests/Fixtures/TestBundle/Entity/SlugParentDummy.php index 104ca2cc97e..c6e55121355 100644 --- a/tests/Fixtures/TestBundle/Entity/SlugParentDummy.php +++ b/tests/Fixtures/TestBundle/Entity/SlugParentDummy.php @@ -95,7 +95,7 @@ public function removeChildDummy(SlugChildDummy $childDummy): self $this->childDummies->removeElement($childDummy); // set the owning side to null (unless already changed) if ($childDummy->getParentDummy() === $this) { - $childDummy->setParentDummy(null); + $childDummy->setParentDummy(); } } diff --git a/tests/Fixtures/TestBundle/Entity/ThirdLevel.php b/tests/Fixtures/TestBundle/Entity/ThirdLevel.php index 4f48aaf0fcc..a2830c247c0 100644 --- a/tests/Fixtures/TestBundle/Entity/ThirdLevel.php +++ b/tests/Fixtures/TestBundle/Entity/ThirdLevel.php @@ -71,10 +71,7 @@ public function getLevel(): ?int return $this->level; } - /** - * @param int $level - */ - public function setLevel($level): void + public function setLevel(int $level): void { $this->level = $level; } @@ -84,10 +81,7 @@ public function isTest(): bool return $this->test; } - /** - * @param bool $test - */ - public function setTest($test): void + public function setTest(bool $test): void { $this->test = $test; } diff --git a/tests/Fixtures/TestBundle/Entity/VoDummyInspection.php b/tests/Fixtures/TestBundle/Entity/VoDummyInspection.php index e5a3c805359..05249e43953 100644 --- a/tests/Fixtures/TestBundle/Entity/VoDummyInspection.php +++ b/tests/Fixtures/TestBundle/Entity/VoDummyInspection.php @@ -27,7 +27,7 @@ class VoDummyInspection #[Groups(['car_read', 'car_write', 'inspection_read', 'inspection_write'])] private \DateTime $performed; - private $attributeWithoutConstructorEquivalent; + private string $attributeWithoutConstructorEquivalent; public function __construct(#[ORM\Column(type: 'boolean')] #[Groups(['car_read', 'car_write', 'inspection_read', 'inspection_write'])] private bool $accepted, #[ORM\ManyToOne(targetEntity: VoDummyCar::class, inversedBy: 'inspections')] #[Groups(['inspection_read', 'inspection_write'])] private ?VoDummyCar $car, ?\DateTime $performed = null, string $parameterWhichIsNotClassAttribute = '') { @@ -50,7 +50,7 @@ public function getPerformed(): \DateTime return $this->performed; } - public function setPerformed(\DateTime $performed) + public function setPerformed(\DateTime $performed): static { $this->performed = $performed; diff --git a/tests/Fixtures/TestBundle/Exception/NotFoundException.php b/tests/Fixtures/TestBundle/Exception/NotFoundException.php index b81db1bd329..c6b4a29ff67 100644 --- a/tests/Fixtures/TestBundle/Exception/NotFoundException.php +++ b/tests/Fixtures/TestBundle/Exception/NotFoundException.php @@ -15,8 +15,4 @@ final class NotFoundException extends \Exception { - public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null) - { - parent::__construct($message, $code, $previous); - } } diff --git a/tests/Fixtures/TestBundle/Filter/DoesNotImplementInterfaceFilter.php b/tests/Fixtures/TestBundle/Filter/DoesNotImplementInterfaceFilter.php index fe0e71eb57d..b1aebcce219 100644 --- a/tests/Fixtures/TestBundle/Filter/DoesNotImplementInterfaceFilter.php +++ b/tests/Fixtures/TestBundle/Filter/DoesNotImplementInterfaceFilter.php @@ -15,7 +15,7 @@ final class DoesNotImplementInterfaceFilter { - public function getDescription(string $resourceClass): array + public function getDescription(): array { return []; } diff --git a/tests/Fixtures/TestBundle/Metadata/ProviderResourceMetadatatCollectionFactory.php b/tests/Fixtures/TestBundle/Metadata/ProviderResourceMetadatatCollectionFactory.php index 95bcbea3682..b5b7168d4b0 100644 --- a/tests/Fixtures/TestBundle/Metadata/ProviderResourceMetadatatCollectionFactory.php +++ b/tests/Fixtures/TestBundle/Metadata/ProviderResourceMetadatatCollectionFactory.php @@ -60,7 +60,7 @@ public function create(string $resourceClass): ResourceMetadataCollection return $resourceMetadataCollection; } - private function setProvider(ResourceMetadataCollection $resourceMetadataCollection, string $provider) + private function setProvider(ResourceMetadataCollection $resourceMetadataCollection, string $provider): ResourceMetadataCollection { foreach ($resourceMetadataCollection as $i => $resourceMetadata) { $operations = $resourceMetadata->getOperations(); diff --git a/tests/Fixtures/TestBundle/Model/ResourceInterfaceImplementation.php b/tests/Fixtures/TestBundle/Model/ResourceInterfaceImplementation.php index 5969df5fc0b..438fb3dc19d 100644 --- a/tests/Fixtures/TestBundle/Model/ResourceInterfaceImplementation.php +++ b/tests/Fixtures/TestBundle/Model/ResourceInterfaceImplementation.php @@ -22,7 +22,7 @@ class ResourceInterfaceImplementation implements ResourceInterface, ResourceBarI private ?string $bar = null; - public function setFoo(string $foo) + public function setFoo(string $foo): static { $this->foo = $foo; @@ -34,7 +34,7 @@ public function getFoo(): string return $this->foo; } - public function setBar(?string $bar) + public function setBar(?string $bar): static { $this->bar = $bar; diff --git a/tests/Fixtures/TestBundle/State/DummyDtoInputOutputProcessor.php b/tests/Fixtures/TestBundle/State/DummyDtoInputOutputProcessor.php index 3fb2498adbd..2603f5d8a9d 100644 --- a/tests/Fixtures/TestBundle/State/DummyDtoInputOutputProcessor.php +++ b/tests/Fixtures/TestBundle/State/DummyDtoInputOutputProcessor.php @@ -35,7 +35,7 @@ public function __construct(private readonly ManagerRegistry $registry) * * @param InputDto|InputDtoDocument|mixed $data */ - public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []) + public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): OutputDtoDocument|OutputDto { if (!($data instanceof InputDto || $data instanceof InputDtoDocument)) { throw new \RuntimeException('Data is not an InputDto'); diff --git a/tests/Fixtures/TestBundle/State/DummyDtoNoInputsProcessor.php b/tests/Fixtures/TestBundle/State/DummyDtoNoInputsProcessor.php index d0df8c73ddc..cc4af991fd0 100644 --- a/tests/Fixtures/TestBundle/State/DummyDtoNoInputsProcessor.php +++ b/tests/Fixtures/TestBundle/State/DummyDtoNoInputsProcessor.php @@ -25,7 +25,7 @@ public function __construct(private readonly ProcessorInterface $decorated) { } - public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []) + public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): OutputDto|OutputDtoDocument { $object = $this->decorated->process($data, $operation, $uriVariables, $context); diff --git a/tests/Fixtures/TestBundle/State/DummyDtoNoOutputProcessor.php b/tests/Fixtures/TestBundle/State/DummyDtoNoOutputProcessor.php index fc0d67e7889..555e0ffa68d 100644 --- a/tests/Fixtures/TestBundle/State/DummyDtoNoOutputProcessor.php +++ b/tests/Fixtures/TestBundle/State/DummyDtoNoOutputProcessor.php @@ -30,7 +30,7 @@ public function __construct(private readonly ManagerRegistry $registry) /** * {@inheritDoc} */ - public function process(mixed $data, ?Operation $operation = null, array $uriVariables = [], array $context = []) + public function process(mixed $data, ?Operation $operation = null, array $uriVariables = [], array $context = []): DummyDtoNoOutput|DummyDtoNoOutputDocument { $isOrm = true; $em = $this->registry->getManagerForClass(DummyDtoNoOutput::class); diff --git a/tests/Fixtures/TestBundle/State/OperationResourceProcessor.php b/tests/Fixtures/TestBundle/State/OperationResourceProcessor.php index 0d0d8333643..150644fe2ca 100644 --- a/tests/Fixtures/TestBundle/State/OperationResourceProcessor.php +++ b/tests/Fixtures/TestBundle/State/OperationResourceProcessor.php @@ -30,7 +30,7 @@ public function __construct(private readonly ManagerRegistry $managerRegistry) { } - private function persist($data, array $context = []) + private function persist($data) { if (!$manager = $this->getManager($data)) { return $data; @@ -78,7 +78,7 @@ private function getManager($data): ?DoctrineObjectManager /** * Checks if doctrine does not manage data automatically. */ - private function isDeferredExplicit(DoctrineObjectManager $manager, $data): bool + private function isDeferredExplicit(DoctrineObjectManager $manager, object $data): bool { $classMetadata = $manager->getClassMetadata($this->getObjectClass($data)); if (($classMetadata instanceof ClassMetadata || $classMetadata instanceof ODMClassMetadata) && method_exists($classMetadata, 'isChangeTrackingDeferredExplicit')) { diff --git a/tests/Fixtures/app/config/routing_mongodb.php b/tests/Fixtures/app/config/routing_mongodb.php index 744c393c0d0..746dc482550 100644 --- a/tests/Fixtures/app/config/routing_mongodb.php +++ b/tests/Fixtures/app/config/routing_mongodb.php @@ -14,7 +14,7 @@ use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; -return static function (RoutingConfigurator $routes) { +return static function (RoutingConfigurator $routes): void { $routes->import('routing_common.yml'); $routes->import('@TestBundle/Controller/MongoDbOdm', 'attribute'); diff --git a/tests/Fixtures/app/config/routing_test.php b/tests/Fixtures/app/config/routing_test.php index e9f7fbc01f3..75c954a03ae 100644 --- a/tests/Fixtures/app/config/routing_test.php +++ b/tests/Fixtures/app/config/routing_test.php @@ -14,7 +14,7 @@ use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; -return static function (RoutingConfigurator $routes) { +return static function (RoutingConfigurator $routes): void { $routes->import('routing_common.yml'); $routes->import('@TestBundle/Controller/Orm', 'attribute'); diff --git a/tests/Functional/Doctrine/ContextSwitchTest.php b/tests/Functional/Doctrine/ContextSwitchTest.php index 3fc1564492f..b2e3acfd59f 100644 --- a/tests/Functional/Doctrine/ContextSwitchTest.php +++ b/tests/Functional/Doctrine/ContextSwitchTest.php @@ -60,7 +60,7 @@ public function testPatialFetchWithContextSwitch(): void $manager->clear(); // this is important to avoid doctrine from reusing the objects instead of loading theme from SQL query $client = static::createClient(); - $response = $client->request('GET', '/dummy_contexts', ['headers' => ['Accept' => 'application/ld+json']]); + $client->request('GET', '/dummy_contexts', ['headers' => ['Accept' => 'application/ld+json']]); $this->assertResponseStatusCodeSame(200); $this->assertJsonContains([ @@ -105,7 +105,7 @@ public function testPatialFetchWithContextSwitchOnSameEntity(): void $manager->clear(); // this is important to avoid doctrine from reusing the objects instead of loading theme from SQL query $client = static::createClient(); - $response = $client->request('GET', '/dummy_contexts', ['headers' => ['Accept' => 'application/ld+json']]); + $client->request('GET', '/dummy_contexts', ['headers' => ['Accept' => 'application/ld+json']]); $this->assertResponseStatusCodeSame(200); $this->assertJsonContains([ diff --git a/tests/Functional/Doctrine/EntityReadOnlyTest.php b/tests/Functional/Doctrine/EntityReadOnlyTest.php index 106da2f173b..b7d0396f104 100644 --- a/tests/Functional/Doctrine/EntityReadOnlyTest.php +++ b/tests/Functional/Doctrine/EntityReadOnlyTest.php @@ -48,13 +48,13 @@ public function testCannotUpdateOrPatchReadonlyEntity(): void $manager->flush(); $client = static::createClient(); - $response = $client->request('GET', '/dummy_read_onlies', ['headers' => ['Accept' => 'application/ld+json']]); + $client->request('GET', '/dummy_read_onlies', ['headers' => ['Accept' => 'application/ld+json']]); $this->assertResponseStatusCodeSame(200); - $response = $client->request('GET', '/dummy_read_onlies/'.$dummy->getId(), ['headers' => ['Accept' => 'application/ld+json']]); + $client->request('GET', '/dummy_read_onlies/'.$dummy->getId(), ['headers' => ['Accept' => 'application/ld+json']]); $this->assertResponseStatusCodeSame(200); - $response = $client->request('POST', '/dummy_read_onlies', [ + $client->request('POST', '/dummy_read_onlies', [ 'headers' => ['Content-Type' => 'application/ld+json'], 'json' => [ 'name' => 'bar', @@ -62,10 +62,10 @@ public function testCannotUpdateOrPatchReadonlyEntity(): void ]); $this->assertResponseStatusCodeSame(201); - $response = $client->request('DELETE', '/dummy_read_onlies/'.$dummy->getId(), ['headers' => ['Content-Type' => 'application/ld+json']]); + $client->request('DELETE', '/dummy_read_onlies/'.$dummy->getId(), ['headers' => ['Content-Type' => 'application/ld+json']]); $this->assertResponseStatusCodeSame(204); - $response = $client->request('PUT', '/dummy_read_onlies'.$dummy->getId(), [ + $client->request('PUT', '/dummy_read_onlies'.$dummy->getId(), [ 'headers' => ['Content-Type' => 'application/ld+json'], 'json' => [ 'name' => 'baz', @@ -73,7 +73,7 @@ public function testCannotUpdateOrPatchReadonlyEntity(): void ]); $this->assertResponseStatusCodeSame(404); - $response = $client->request('PATCH', '/dummy_read_onlies'.$dummy->getId(), [ + $client->request('PATCH', '/dummy_read_onlies'.$dummy->getId(), [ 'headers' => ['Content-Type' => 'application/ld+json'], 'json' => [ 'name' => 'baz', diff --git a/tests/Functional/Doctrine/StateOptionTest.php b/tests/Functional/Doctrine/StateOptionTest.php index b77694aa74c..38a70bc5e3e 100644 --- a/tests/Functional/Doctrine/StateOptionTest.php +++ b/tests/Functional/Doctrine/StateOptionTest.php @@ -80,7 +80,7 @@ public function testPostWithEntityClassOption(): void $manager->flush(); $iri = '/issue7689_categories/'.$c->getId(); - $response = static::createClient()->request('POST', '/issue7689_products', ['json' => [ + static::createClient()->request('POST', '/issue7689_products', ['json' => [ 'name' => 'product', 'category' => $iri, ]]); diff --git a/tests/Functional/DocumentationActionTest.php b/tests/Functional/DocumentationActionTest.php index 74e80a27f1e..0789925efce 100644 --- a/tests/Functional/DocumentationActionTest.php +++ b/tests/Functional/DocumentationActionTest.php @@ -43,7 +43,7 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load { parent::configureContainer($c, $loader); - $loader->load(static function (ContainerBuilder $container) { + $loader->load(static function (ContainerBuilder $container): void { $container->loadFromExtension('api_platform', [ 'enable_swagger_ui' => DocumentationActionAppKernel::$swaggerUiEnabled, 'enable_re_doc' => DocumentationActionAppKernel::$reDocEnabled, diff --git a/tests/Functional/ErrorTest.php b/tests/Functional/ErrorTest.php index 3ec9c5aa44c..de46a5afbc3 100644 --- a/tests/Functional/ErrorTest.php +++ b/tests/Functional/ErrorTest.php @@ -34,7 +34,7 @@ public static function getResources(): array } #[DataProvider('formatsProvider')] - public function testRetrieveError(string $format, string $status, $expected): void + public function testRetrieveError(string $format, string $status, array $expected): void { self::createClient()->request('GET', '/errors/'.$status, ['headers' => ['accept' => $format]]); $this->assertJsonContains($expected); diff --git a/tests/Functional/JsonSchema/JsonSchemaTest.php b/tests/Functional/JsonSchema/JsonSchemaTest.php index d32ae3fec53..4cb366af8a8 100644 --- a/tests/Functional/JsonSchema/JsonSchemaTest.php +++ b/tests/Functional/JsonSchema/JsonSchemaTest.php @@ -224,7 +224,7 @@ public function testReadOnlySchema(): void $this->assertTrue($schema['definitions']['Resource']['properties']['resourceRelated']['readOnly'] ?? false); } - public function testGenIdFalse() + public function testGenIdFalse(): void { $schema = $this->schemaFactory->buildSchema(Product::class, 'jsonld', Schema::TYPE_OUTPUT, $this->operationMetadataFactory->create('_api_/json-stream-products_get_collection')); $this->assertThat(['member' => [['aggregateRating' => ['ratingValue' => '1.0', 'reviewCount' => 1]]]], new MatchesJsonSchema($schema)); diff --git a/tests/Functional/ListenerTest.php b/tests/Functional/ListenerTest.php index 28fbd1bf38b..71488e78259 100644 --- a/tests/Functional/ListenerTest.php +++ b/tests/Functional/ListenerTest.php @@ -32,7 +32,7 @@ public static function getResources(): array ]; } - public function testListener() + public function testListener(): void { self::createClient()->request('PATCH', '/original_data_with_listeners/123/verify', [ 'headers' => ['content-type' => 'application/merge-patch+json'], diff --git a/tests/Functional/MappingTest.php b/tests/Functional/MappingTest.php index b79db81672a..86c05f55524 100644 --- a/tests/Functional/MappingTest.php +++ b/tests/Functional/MappingTest.php @@ -96,10 +96,10 @@ public function testShouldMapBetweenResourceAndEntity(): void self::createClient()->request('GET', $uri); $this->assertJsonContains(['username' => 'so yuka']); - $r = self::createClient()->request('PATCH', $uri, ['json' => ['username' => 'ba zar'], 'headers' => ['content-type' => 'application/merge-patch+json']]); + self::createClient()->request('PATCH', $uri, ['json' => ['username' => 'ba zar'], 'headers' => ['content-type' => 'application/merge-patch+json']]); $this->assertJsonContains(['username' => 'ba zar']); - $r = self::createClient()->request('DELETE', $uri); + self::createClient()->request('DELETE', $uri); $this->assertResponseStatusCodeSame(204); } @@ -176,7 +176,7 @@ public function testShouldNotMapWhenInput(): void $this->recreateSchema([MappedEntity::class]); $this->loadFixtures(); - $r = self::createClient()->request('POST', 'mapped_resource_with_input', [ + self::createClient()->request('POST', 'mapped_resource_with_input', [ 'headers' => [ 'content-type' => 'application/ld+json', ], @@ -228,7 +228,7 @@ public function testShouldMapWithSourceOnly(): void self::createClient()->request('GET', $uri); $this->assertJsonContains(['username' => 'so yuka']); - $r = self::createClient()->request('PATCH', $uri, ['json' => ['username' => 'ba zar'], 'headers' => ['content-type' => 'application/merge-patch+json']]); + self::createClient()->request('PATCH', $uri, ['json' => ['username' => 'ba zar'], 'headers' => ['content-type' => 'application/merge-patch+json']]); $this->assertJsonContains(['username' => 'ba zar']); } @@ -434,7 +434,7 @@ public function testOutputDtoForCollectionRead(): void } // Test Get (single item) returns all fields from the full resource - $response = self::createClient()->request('GET', '/book_store_resources/1'); + self::createClient()->request('GET', '/book_store_resources/1'); self::assertResponseIsSuccessful(); self::assertJsonContains([ 'id' => 1, diff --git a/tests/Functional/McpTest.php b/tests/Functional/McpTest.php index 46ed75109ae..85573c07d10 100644 --- a/tests/Functional/McpTest.php +++ b/tests/Functional/McpTest.php @@ -59,7 +59,7 @@ private function isPsr17FactoryAvailable(): bool } } - private function callTool($client, string $sessionId, string $toolName, array $arguments = []): mixed + private function callTool(\ApiPlatform\Symfony\Bundle\Test\Client $client, string $sessionId, string $toolName, array $arguments = []): mixed { return $client->request('POST', '/mcp', [ 'headers' => [ @@ -349,7 +349,7 @@ public function testMarkdownWithCodeBlock(): void self::assertArrayNotHasKey('structuredContent', $result['result']); } - private function initializeMcpSession($client): string + private function initializeMcpSession(\ApiPlatform\Symfony\Bundle\Test\Client $client): string { $res = $client->request('POST', '/mcp', [ 'headers' => [ @@ -428,7 +428,7 @@ public function testToolsList(): void self::assertEquals('object', $tool['inputSchema']['type']); } - $listBooks = array_filter($tools, static function (array $input) { + $listBooks = array_filter($tools, static function (array $input): bool { return 'list_books' === $input['name']; }); @@ -483,7 +483,7 @@ public function testToolsList(): void ], ], $outputSchema); - $listBooksDto = array_filter($tools, static function (array $input) { + $listBooksDto = array_filter($tools, static function (array $input): bool { return 'list_books_dto' === $input['name']; }); diff --git a/tests/Functional/OpenApiTest.php b/tests/Functional/OpenApiTest.php index e65ad3134b7..4523b52e019 100644 --- a/tests/Functional/OpenApiTest.php +++ b/tests/Functional/OpenApiTest.php @@ -522,7 +522,7 @@ public function testRetrieveTheJsonOpenApiDocumentation(): void public function testRetrieveTheYamlOpenApiDocumentation(): void { - $response = self::createClient()->request('GET', '/docs', [ + self::createClient()->request('GET', '/docs', [ 'headers' => ['Accept' => 'application/vnd.openapi+yaml'], ]); $this->assertResponseIsSuccessful(); @@ -531,7 +531,7 @@ public function testRetrieveTheYamlOpenApiDocumentation(): void public function testRetrieveTheOpenApiDocumentationHtml(): void { - $response = self::createClient()->request('GET', '/', [ + self::createClient()->request('GET', '/', [ 'headers' => ['Accept' => 'text/html'], ]); $this->assertResponseIsSuccessful(); @@ -577,7 +577,7 @@ public function testRetrieveTheOpenApiDocumentationWith30Specification(): void public function testRetrieveTheOpenApiDocumentationInJson(): void { - $response = self::createClient()->request('GET', '/docs.jsonopenapi', [ + self::createClient()->request('GET', '/docs.jsonopenapi', [ 'headers' => ['Accept' => 'text/html,*/*;q=0.8'], ]); $this->assertResponseIsSuccessful(); @@ -588,7 +588,7 @@ public function testOpenApiUiIsEnabledForDocsEndpointWithDummyObject(): void { $this->recreateSchema([Dummy::class, RelatedDummy::class, RelatedOwnedDummy::class, RelatedOwningDummy::class]); self::createClient()->request('POST', '/dummies', ['json' => ['name' => 'test']]); - $response = self::createClient()->request('GET', '/dummies/1.html', [ + self::createClient()->request('GET', '/dummies/1.html', [ 'headers' => ['Accept' => 'text/html'], ]); $this->assertResponseIsSuccessful(); diff --git a/tests/Functional/Parameters/DoctrineTest.php b/tests/Functional/Parameters/DoctrineTest.php index 56b4bdbb1e0..65a96e0953f 100644 --- a/tests/Functional/Parameters/DoctrineTest.php +++ b/tests/Functional/Parameters/DoctrineTest.php @@ -203,7 +203,7 @@ public function testPartialSearchFilterWithSearchFilterParameter(string $url, in $this->assertCount($expectedCount, $filteredItems, \sprintf('Expected %d items for URL %s', $expectedCount, $url)); - $foos = array_map(static fn ($item) => $item['foo'], $filteredItems); + $foos = array_map(static fn (array $item) => $item['foo'], $filteredItems); sort($foos); sort($expectedFoos); diff --git a/tests/Functional/Parameters/ExactFilterTest.php b/tests/Functional/Parameters/ExactFilterTest.php index e440c1c3a7e..60c65785c96 100644 --- a/tests/Functional/Parameters/ExactFilterTest.php +++ b/tests/Functional/Parameters/ExactFilterTest.php @@ -67,7 +67,7 @@ public function testExactSearchFilter(string $url, int $expectedCount, array $ex $this->assertCount($expectedCount, $filteredItems, \sprintf('Expected %d items for URL %s', $expectedCount, $url)); - $names = array_map(static fn ($chicken) => $chicken['name'], $filteredItems); + $names = array_map(static fn (array $chicken) => $chicken['name'], $filteredItems); sort($names); sort($expectedNames); @@ -294,7 +294,7 @@ public function testExactFilterWithManyToOneRelation(string $url, int $expectedC $this->assertCount($expectedCount, $filteredChickens, \sprintf('Expected %d chickens for URL %s', $expectedCount, $url)); - $names = array_map(static fn ($chicken) => $chicken['name'], $filteredChickens); + $names = array_map(static fn (array $chicken) => $chicken['name'], $filteredChickens); sort($names); sort($expectedChickenNames); @@ -333,7 +333,7 @@ public function testExactFilterWithManyToOneRelationWithPropertyPlaceholder(stri $this->assertCount($expectedCount, $filteredChickens, \sprintf('Expected %d chickens for URL %s', $expectedCount, $url)); - $names = array_map(static fn ($chicken) => $chicken['name'], $filteredChickens); + $names = array_map(static fn (array $chicken) => $chicken['name'], $filteredChickens); sort($names); sort($expectedChickenNames); diff --git a/tests/Functional/Parameters/LinkProviderParameterTest.php b/tests/Functional/Parameters/LinkProviderParameterTest.php index 136044de8da..adf78e8dae0 100644 --- a/tests/Functional/Parameters/LinkProviderParameterTest.php +++ b/tests/Functional/Parameters/LinkProviderParameterTest.php @@ -219,7 +219,7 @@ public function testIssue7469IriGenerationFailsForLinkedResource(): void $manager->persist($issue7469Dummy); $manager->flush(); - $r = self::createClient()->request('GET', '/issue_7469_test_resources/'.$issue7469Dummy->id, ['headers' => ['Accept' => 'application/ld+json']]); + self::createClient()->request('GET', '/issue_7469_test_resources/'.$issue7469Dummy->id, ['headers' => ['Accept' => 'application/ld+json']]); $this->assertResponseIsSuccessful(); } } diff --git a/tests/Functional/Parameters/OrderFilterTest.php b/tests/Functional/Parameters/OrderFilterTest.php index 368ca970289..03eced9a940 100644 --- a/tests/Functional/Parameters/OrderFilterTest.php +++ b/tests/Functional/Parameters/OrderFilterTest.php @@ -57,7 +57,7 @@ public function testOrderFilterResponses(string $url, array $expectedOrder): voi $responseData = $response->toArray(); $orderedItems = $responseData['hydra:member']; - $actualOrder = array_map(static fn ($item) => $item['createdAt'] ?? null, $orderedItems); + $actualOrder = array_map(static fn (array $item) => $item['createdAt'] ?? null, $orderedItems); // Default NULL order is different in PostgreSQL. if ($this->isPostgres()) { @@ -109,7 +109,7 @@ public function testOrderFilterNullsComparisonResponses(string $url, array $expe $responseData = $response->toArray(); $orderedItems = $responseData['hydra:member']; - $actualOrder = array_map(static fn ($item) => $item['createdAt'] ?? null, $orderedItems); + $actualOrder = array_map(static fn (array $item) => $item['createdAt'] ?? null, $orderedItems); $this->assertSame($expectedOrder, $actualOrder, \sprintf('Expected order does not match for URL %s', $url)); } diff --git a/tests/Functional/Parameters/PartialSearchFilterTest.php b/tests/Functional/Parameters/PartialSearchFilterTest.php index 3a2bebe66da..ca016c4f8f4 100644 --- a/tests/Functional/Parameters/PartialSearchFilterTest.php +++ b/tests/Functional/Parameters/PartialSearchFilterTest.php @@ -67,7 +67,7 @@ public function testPartialSearchFilter(string $url, int $expectedCount, array $ $this->assertCount($expectedCount, $filteredItems, \sprintf('Expected %d items for URL %s', $expectedCount, $url)); - $names = array_map(static fn ($chicken) => $chicken['name'], $filteredItems); + $names = array_map(static fn (array $chicken) => $chicken['name'], $filteredItems); sort($names); sort($expectedNames); @@ -487,7 +487,7 @@ public function testPartialSearchFilterWithManyToOneRelation(string $url, int $e $this->assertCount($expectedCount, $filteredChickens, \sprintf('Expected %d chickens for URL %s', $expectedCount, $url)); - $names = array_map(static fn ($chicken) => $chicken['name'], $filteredChickens); + $names = array_map(static fn (array $chicken) => $chicken['name'], $filteredChickens); sort($names); sort($expectedChickenNames); @@ -526,7 +526,7 @@ public function testPartialSearchFilterWithManyToOneRelationWithPropertyPlacehol $this->assertCount($expectedCount, $filteredChickens, \sprintf('Expected %d chickens for URL %s', $expectedCount, $url)); - $names = array_map(static fn ($chicken) => $chicken['name'], $filteredChickens); + $names = array_map(static fn (array $chicken) => $chicken['name'], $filteredChickens); sort($names); sort($expectedChickenNames); diff --git a/tests/Functional/Parameters/ValidationTest.php b/tests/Functional/Parameters/ValidationTest.php index 7c243edd679..98a0f7c2886 100644 --- a/tests/Functional/Parameters/ValidationTest.php +++ b/tests/Functional/Parameters/ValidationTest.php @@ -38,7 +38,7 @@ public function testWithGroupFilter(): void { $response = self::createClient()->request('GET', 'with_parameters_collection'); $this->assertArraySubset(['violations' => [['message' => 'This value should not be null.']]], $response->toArray(false)); - $response = self::createClient()->request('GET', 'with_parameters_collection?hydra'); + self::createClient()->request('GET', 'with_parameters_collection?hydra'); $this->assertResponseIsSuccessful(); } diff --git a/tests/Functional/Uuid/UuidFilterBaseTestCase.php b/tests/Functional/Uuid/UuidFilterBaseTestCase.php index 7068423e967..9ccf8907904 100644 --- a/tests/Functional/Uuid/UuidFilterBaseTestCase.php +++ b/tests/Functional/Uuid/UuidFilterBaseTestCase.php @@ -292,7 +292,7 @@ public function testGetOpenApiDescription(): void 'format' => 'uuid', ], ], - array_map(static fn ($p) => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1]), $json['paths']['/'.$this->getUrlPrefix().'_device_endpoints']['get']['parameters']) + array_map(static fn ($p): array => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1]), $json['paths']['/'.$this->getUrlPrefix().'_device_endpoints']['get']['parameters']) ); self::assertContains( @@ -310,7 +310,7 @@ public function testGetOpenApiDescription(): void 'style' => 'deepObject', 'explode' => true, ], - array_map(static fn ($p) => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1, 'style' => 1, 'explode' => 1]), $json['paths']['/'.$this->getUrlPrefix().'_device_endpoints']['get']['parameters']) + array_map(static fn ($p): array => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1, 'style' => 1, 'explode' => 1]), $json['paths']['/'.$this->getUrlPrefix().'_device_endpoints']['get']['parameters']) ); } diff --git a/tests/Functional/Uuid/UuidFilterWithCustomSchemaTest.php b/tests/Functional/Uuid/UuidFilterWithCustomSchemaTest.php index 3db038da67b..f39d06d0eb9 100644 --- a/tests/Functional/Uuid/UuidFilterWithCustomSchemaTest.php +++ b/tests/Functional/Uuid/UuidFilterWithCustomSchemaTest.php @@ -62,7 +62,7 @@ public function testGetOpenApiDescriptionWhenNoCustomerSchema(): void 'format' => 'uuid', ], ], - array_map(static fn ($p) => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1]), $json['paths']['/uuid_filter_with_custom_schemas']['get']['parameters']) + array_map(static fn ($p): array => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1]), $json['paths']['/uuid_filter_with_custom_schemas']['get']['parameters']) ); self::assertContains( @@ -80,7 +80,7 @@ public function testGetOpenApiDescriptionWhenNoCustomerSchema(): void 'style' => 'deepObject', 'explode' => true, ], - array_map(static fn ($p) => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1, 'style' => 1, 'explode' => 1]), $json['paths']['/uuid_filter_with_custom_schemas']['get']['parameters']) + array_map(static fn ($p): array => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1, 'style' => 1, 'explode' => 1]), $json['paths']['/uuid_filter_with_custom_schemas']['get']['parameters']) ); } @@ -102,7 +102,7 @@ public function testGetOpenApiDescriptionWhenSchemaIsOnlyString(): void 'format' => 'uuid', ], ], - array_map(static fn ($p) => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1]), $json['paths']['/uuid_filter_with_custom_schemas']['get']['parameters']) + array_map(static fn ($p): array => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1]), $json['paths']['/uuid_filter_with_custom_schemas']['get']['parameters']) ); self::assertNotContains( @@ -138,7 +138,7 @@ public function testGetOpenApiDescriptionWhenSchemaIsOnlyArray(): void 'style' => 'deepObject', 'explode' => true, ], - array_map(static fn ($p) => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1, 'style' => 1, 'explode' => 1]), $json['paths']['/uuid_filter_with_custom_schemas']['get']['parameters']) + array_map(static fn ($p): array => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1, 'style' => 1, 'explode' => 1]), $json['paths']['/uuid_filter_with_custom_schemas']['get']['parameters']) ); } @@ -160,7 +160,7 @@ public function testGetOpenApiDescriptionIsOneOfArrayOrString(): void 'format' => 'uuid', ], ], - array_map(static fn ($p) => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1]), $json['paths']['/uuid_filter_with_custom_schemas']['get']['parameters']) + array_map(static fn ($p): array => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1]), $json['paths']['/uuid_filter_with_custom_schemas']['get']['parameters']) ); self::assertContains( @@ -178,7 +178,7 @@ public function testGetOpenApiDescriptionIsOneOfArrayOrString(): void 'style' => 'deepObject', 'explode' => true, ], - array_map(static fn ($p) => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1, 'style' => 1, 'explode' => 1]), $json['paths']['/uuid_filter_with_custom_schemas']['get']['parameters']) + array_map(static fn ($p): array => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1, 'style' => 1, 'explode' => 1]), $json['paths']['/uuid_filter_with_custom_schemas']['get']['parameters']) ); } diff --git a/tests/Functional/Uuid/UuidFilterWithSymfonyUlidTest.php b/tests/Functional/Uuid/UuidFilterWithSymfonyUlidTest.php index b70e74f32e0..1a70c75b74d 100644 --- a/tests/Functional/Uuid/UuidFilterWithSymfonyUlidTest.php +++ b/tests/Functional/Uuid/UuidFilterWithSymfonyUlidTest.php @@ -73,7 +73,7 @@ public function testGetOpenApiDescription(): void 'format' => 'ulid', ], ], - array_map(static fn ($p) => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1]), $json['paths']['/'.$this->getUrlPrefix().'_device_endpoints']['get']['parameters']) + array_map(static fn ($p): array => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1]), $json['paths']['/'.$this->getUrlPrefix().'_device_endpoints']['get']['parameters']) ); self::assertContains( @@ -91,7 +91,7 @@ public function testGetOpenApiDescription(): void 'style' => 'deepObject', 'explode' => true, ], - array_map(static fn ($p) => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1, 'style' => 1, 'explode' => 1]), $json['paths']['/'.$this->getUrlPrefix().'_device_endpoints']['get']['parameters']) + array_map(static fn ($p): array => array_intersect_key($p, ['name' => 1, 'in' => 1, 'required' => 1, 'schema' => 1, 'style' => 1, 'explode' => 1]), $json['paths']['/'.$this->getUrlPrefix().'_device_endpoints']['get']['parameters']) ); } } diff --git a/tests/Problem/Serializer/ConstraintViolationNormalizerTest.php b/tests/Problem/Serializer/ConstraintViolationNormalizerTest.php index 78f292fdf3c..81b288d9277 100644 --- a/tests/Problem/Serializer/ConstraintViolationNormalizerTest.php +++ b/tests/Problem/Serializer/ConstraintViolationNormalizerTest.php @@ -82,7 +82,7 @@ public static function nameConverterProvider(): iterable $nameConverterFactory = static function (self $that): NameConverterInterface { $nameConverterProphecy = $that->prophesize(NameConverterInterface::class); - $nameConverterProphecy->normalize(Argument::cetera())->will(static fn ($args) => '_'.$args[0]); + $nameConverterProphecy->normalize(Argument::cetera())->will(static fn ($args): string => '_'.$args[0]); return $nameConverterProphecy->reveal(); }; @@ -103,6 +103,6 @@ public static function nameConverterProvider(): iterable 'code' => null, ], ]; - yield [static fn () => null, $expected]; + yield [static fn (): null => null, $expected]; } } diff --git a/tests/State/Pagination/ArrayPaginatorTest.php b/tests/State/Pagination/ArrayPaginatorTest.php index 46cec3ccfb8..1ccf1053379 100644 --- a/tests/State/Pagination/ArrayPaginatorTest.php +++ b/tests/State/Pagination/ArrayPaginatorTest.php @@ -23,7 +23,7 @@ class ArrayPaginatorTest extends TestCase { #[DataProvider('initializeProvider')] - public function testInitialize(array $results, $firstResult, $maxResults, $currentItems, $totalItems, $currentPage, $lastPage, $hasNextPage): void + public function testInitialize(array $results, int $firstResult, int $maxResults, int $currentItems, int $totalItems, int $currentPage, int $lastPage, bool $hasNextPage): void { $paginator = new ArrayPaginator($results, $firstResult, $maxResults); diff --git a/tests/State/Provider/BackedEnumProviderTest.php b/tests/State/Provider/BackedEnumProviderTest.php index 9b5898b30a5..58d3a23388f 100644 --- a/tests/State/Provider/BackedEnumProviderTest.php +++ b/tests/State/Provider/BackedEnumProviderTest.php @@ -57,7 +57,7 @@ public function testProvideItem(string $class, string|int $id, \BackedEnum $expe $this->testProvide($expected, $operation, ['id' => $id]); } - private function testProvide($expected, Operation $operation, array $uriVariables = [], array $context = []): void + private function testProvide(array|\BackedEnum $expected, Operation $operation, array $uriVariables = [], array $context = []): void { $decorated = $this->prophesize(ProviderInterface::class); $decorated->provide(Argument::any())->shouldNotBeCalled(); diff --git a/tests/State/Provider/ObjectMapperProviderTest.php b/tests/State/Provider/ObjectMapperProviderTest.php index 5917c82474d..a0be47fe66d 100644 --- a/tests/State/Provider/ObjectMapperProviderTest.php +++ b/tests/State/Provider/ObjectMapperProviderTest.php @@ -114,7 +114,7 @@ public function testProvideMapsArray(): void $objectMapper = $this->createMock(ObjectMapperInterface::class); $objectMapper->expects($this->exactly(2)) ->method('map') - ->willReturnCallback(static function ($source, $target) use ($sourceEntity1, $sourceEntity2, $targetResource1, $targetResource2) { + ->willReturnCallback(static function ($source, $target) use ($sourceEntity1, $sourceEntity2, $targetResource1, $targetResource2): ?\ApiPlatform\Tests\State\Provider\TargetResource { if ($source === $sourceEntity1) { return $targetResource1; } @@ -146,7 +146,7 @@ public function testProvideMapsPaginator(): void $objectMapper = $this->createMock(ObjectMapperInterface::class); $objectMapper->expects($this->exactly(2)) ->method('map') - ->willReturnCallback(static function ($source, $target) use ($sourceEntity1, $sourceEntity2, $targetResource1, $targetResource2) { + ->willReturnCallback(static function ($source, $target) use ($sourceEntity1, $sourceEntity2, $targetResource1, $targetResource2): ?\ApiPlatform\Tests\State\Provider\TargetResource { if ($source === $sourceEntity1) { return $targetResource1; } diff --git a/tests/State/RespondProcessorTest.php b/tests/State/RespondProcessorTest.php index 34db1b78173..734404b2f42 100644 --- a/tests/State/RespondProcessorTest.php +++ b/tests/State/RespondProcessorTest.php @@ -105,7 +105,7 @@ class: Employee::class, public function testAddsExceptionHeaders(): void { - $operation = new Get(); + new Get(); $respondProcessor = new RespondProcessor(); $req = new Request(); @@ -171,9 +171,7 @@ public function testDoesNotAddLinkedDataPlatformHeadersWithoutFactory(): void $respondProcessor = new RespondProcessor( null, - $resourceClassResolver->reveal(), - null, - null // No ResourceMetadataCollectionFactory + $resourceClassResolver->reveal() // No ResourceMetadataCollectionFactory ); $req = new Request(); diff --git a/tests/Symfony/Bundle/DependencyInjection/Compiler/ElasticsearchClientPassTest.php b/tests/Symfony/Bundle/DependencyInjection/Compiler/ElasticsearchClientPassTest.php index 70e954540ee..a0b0ddd44d7 100644 --- a/tests/Symfony/Bundle/DependencyInjection/Compiler/ElasticsearchClientPassTest.php +++ b/tests/Symfony/Bundle/DependencyInjection/Compiler/ElasticsearchClientPassTest.php @@ -123,7 +123,7 @@ public function testProcessWithSslCaBundle(): void $clientDefinition->expects($this->once()) ->method('setArguments') - ->with($this->callback(static function ($arguments) { + ->with($this->callback(static function ($arguments): bool { $config = $arguments[0]; return isset($config['hosts']) @@ -171,7 +171,7 @@ public function testProcessWithSslVerificationDisabled(): void $clientDefinition->expects($this->once()) ->method('setArguments') - ->with($this->callback(static function ($arguments) { + ->with($this->callback(static function ($arguments): bool { $config = $arguments[0]; return isset($config['hosts']) diff --git a/tests/Symfony/Bundle/DependencyInjection/Compiler/FilterPassTest.php b/tests/Symfony/Bundle/DependencyInjection/Compiler/FilterPassTest.php index 0c856126ab6..bf1f4ca8174 100644 --- a/tests/Symfony/Bundle/DependencyInjection/Compiler/FilterPassTest.php +++ b/tests/Symfony/Bundle/DependencyInjection/Compiler/FilterPassTest.php @@ -36,7 +36,7 @@ public function testProcess(): void $this->assertInstanceOf(CompilerPassInterface::class, $filterPass); $filterLocatorDefinitionProphecy = $this->prophesize(Definition::class); - $filterLocatorDefinitionProphecy->addArgument(Argument::that(static fn (array $arg) => !isset($arg['foo']) && isset($arg['my_id']) && $arg['my_id'] instanceof Reference))->willReturn($filterLocatorDefinitionProphecy->reveal())->shouldBeCalled(); + $filterLocatorDefinitionProphecy->addArgument(Argument::that(static fn (array $arg): bool => !isset($arg['foo']) && isset($arg['my_id']) && $arg['my_id'] instanceof Reference))->willReturn($filterLocatorDefinitionProphecy->reveal())->shouldBeCalled(); $containerBuilderProphecy = $this->prophesize(ContainerBuilder::class); $containerBuilderProphecy->findTaggedServiceIds('api_platform.filter', true)->willReturn(['foo' => [], 'bar' => [['id' => 'my_id']]])->shouldBeCalled(); @@ -52,7 +52,7 @@ public function testIdNotExist(): void $this->assertInstanceOf(CompilerPassInterface::class, $filterPass); $filterLocatorDefinitionProphecy = $this->prophesize(Definition::class); - $filterLocatorDefinitionProphecy->addArgument(Argument::that(static fn (array $arg) => !isset($arg['foo']) && isset($arg['bar']) && $arg['bar'] instanceof Reference))->willReturn($filterLocatorDefinitionProphecy->reveal())->shouldBeCalled(); + $filterLocatorDefinitionProphecy->addArgument(Argument::that(static fn (array $arg): bool => !isset($arg['foo']) && isset($arg['bar']) && $arg['bar'] instanceof Reference))->willReturn($filterLocatorDefinitionProphecy->reveal())->shouldBeCalled(); $containerBuilderProphecy = $this->prophesize(ContainerBuilder::class); $containerBuilderProphecy->findTaggedServiceIds('api_platform.filter', true)->willReturn(['foo' => [], 'bar' => [['hi' => 'hello']]])->shouldBeCalled(); diff --git a/tests/Symfony/Bundle/DependencyInjection/Compiler/GraphQlResolverPassTest.php b/tests/Symfony/Bundle/DependencyInjection/Compiler/GraphQlResolverPassTest.php index eee98a43ae9..7e376ff2370 100644 --- a/tests/Symfony/Bundle/DependencyInjection/Compiler/GraphQlResolverPassTest.php +++ b/tests/Symfony/Bundle/DependencyInjection/Compiler/GraphQlResolverPassTest.php @@ -31,7 +31,7 @@ public function testProcess(): void $this->assertInstanceOf(CompilerPassInterface::class, $filterPass); $typeLocatorDefinition = $this->createMock(Definition::class); - $typeLocatorDefinition->expects($this->once())->method('addArgument')->with($this->callback(static function () { + $typeLocatorDefinition->expects($this->once())->method('addArgument')->with($this->callback(static function (): true { return true; })); diff --git a/tests/Symfony/Bundle/DependencyInjection/Compiler/GraphQlTypePassTest.php b/tests/Symfony/Bundle/DependencyInjection/Compiler/GraphQlTypePassTest.php index f86bbf4cc56..9f774fb368a 100644 --- a/tests/Symfony/Bundle/DependencyInjection/Compiler/GraphQlTypePassTest.php +++ b/tests/Symfony/Bundle/DependencyInjection/Compiler/GraphQlTypePassTest.php @@ -36,7 +36,7 @@ public function testProcess(): void $this->assertInstanceOf(CompilerPassInterface::class, $filterPass); $typeLocatorDefinitionProphecy = $this->prophesize(Definition::class); - $typeLocatorDefinitionProphecy->addArgument(Argument::that(static fn (array $arg) => !isset($arg['foo']) && isset($arg['my_id']) && $arg['my_id'] instanceof Reference))->willReturn($typeLocatorDefinitionProphecy->reveal())->shouldBeCalled(); + $typeLocatorDefinitionProphecy->addArgument(Argument::that(static fn (array $arg): bool => !isset($arg['foo']) && isset($arg['my_id']) && $arg['my_id'] instanceof Reference))->willReturn($typeLocatorDefinitionProphecy->reveal())->shouldBeCalled(); $typesFactoryDefinitionProphecy = $this->prophesize(Definition::class); $typesFactoryDefinitionProphecy->addArgument(['my_id'])->willReturn($typesFactoryDefinitionProphecy->reveal())->shouldBeCalled(); @@ -57,7 +57,7 @@ public function testIdNotExist(): void $this->assertInstanceOf(CompilerPassInterface::class, $filterPass); $typeLocatorDefinitionProphecy = $this->prophesize(Definition::class); - $typeLocatorDefinitionProphecy->addArgument(Argument::that(static fn (array $arg) => !isset($arg['foo']) && isset($arg['bar']) && $arg['bar'] instanceof Reference))->willReturn($typeLocatorDefinitionProphecy->reveal())->shouldBeCalled(); + $typeLocatorDefinitionProphecy->addArgument(Argument::that(static fn (array $arg): bool => !isset($arg['foo']) && isset($arg['bar']) && $arg['bar'] instanceof Reference))->willReturn($typeLocatorDefinitionProphecy->reveal())->shouldBeCalled(); $typesFactoryDefinitionProphecy = $this->prophesize(Definition::class); $typesFactoryDefinitionProphecy->addArgument(['bar'])->willReturn($typesFactoryDefinitionProphecy->reveal())->shouldBeCalled(); diff --git a/tests/Symfony/Bundle/DependencyInjection/Compiler/TestClientPassTest.php b/tests/Symfony/Bundle/DependencyInjection/Compiler/TestClientPassTest.php index 37284d9f824..66ca96b20a6 100644 --- a/tests/Symfony/Bundle/DependencyInjection/Compiler/TestClientPassTest.php +++ b/tests/Symfony/Bundle/DependencyInjection/Compiler/TestClientPassTest.php @@ -57,7 +57,7 @@ public function testProcess(): void 'test.api_platform.client', Argument::allOf( Argument::type(Definition::class), - Argument::that(static fn (Definition $testClientDefinition) => Client::class === $testClientDefinition->getClass() + Argument::that(static fn (Definition $testClientDefinition): bool => Client::class === $testClientDefinition->getClass() && !$testClientDefinition->isShared() && $testClientDefinition->isPublic()) ) diff --git a/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php b/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php index 9b1a5f87936..59805943c63 100644 --- a/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php +++ b/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php @@ -257,7 +257,7 @@ public static function invalidHttpStatusCodeProvider(): array } #[DataProvider('invalidHttpStatusCodeProvider')] - public function testExceptionToStatusConfigWithInvalidHttpStatusCode($invalidHttpStatusCode): void + public function testExceptionToStatusConfigWithInvalidHttpStatusCode(int $invalidHttpStatusCode): void { $this->expectException(InvalidConfigurationException::class); $this->expectExceptionMessageMatches('/The HTTP status code ".+" is not valid\\./'); @@ -284,7 +284,7 @@ public static function invalidHttpStatusCodeValueProvider(): array } #[DataProvider('invalidHttpStatusCodeValueProvider')] - public function testExceptionToStatusConfigWithInvalidHttpStatusCodeValue($invalidHttpStatusCodeValue): void + public function testExceptionToStatusConfigWithInvalidHttpStatusCodeValue(bool|float|string|null $invalidHttpStatusCodeValue): void { $this->expectException(InvalidTypeException::class); $this->expectExceptionMessageMatches('/Invalid type for path "api_platform\\.exception_to_status\\.Exception". Expected "?int"?, but got .+\\./'); @@ -309,7 +309,7 @@ public function testInvalidApiKeysConfig(): void 'type' => 'query', ]; - $config = $this->processor->processConfiguration($this->configuration, [ + $this->processor->processConfiguration($this->configuration, [ 'api_platform' => [ 'swagger' => [ 'api_keys' => ['Some Authorization name, like JWT' => $exampleConfig, 'Another-Auth' => $exampleConfig], diff --git a/tests/Symfony/Bundle/Test/ApiTestCaseTest.php b/tests/Symfony/Bundle/Test/ApiTestCaseTest.php index 422d1e558c6..6e5bea9a56c 100644 --- a/tests/Symfony/Bundle/Test/ApiTestCaseTest.php +++ b/tests/Symfony/Bundle/Test/ApiTestCaseTest.php @@ -319,7 +319,7 @@ public function testFindIriBy(): void public function testGetPrioritizedOperation(): void { - $r = self::createClient()->request('GET', '/operation_priority/1', [ + self::createClient()->request('GET', '/operation_priority/1', [ 'headers' => [ 'accept' => 'application/ld+json', ], diff --git a/tests/Symfony/Bundle/Test/ClientTest.php b/tests/Symfony/Bundle/Test/ClientTest.php index 9fb196f87ce..6a668646a5a 100644 --- a/tests/Symfony/Bundle/Test/ClientTest.php +++ b/tests/Symfony/Bundle/Test/ClientTest.php @@ -101,7 +101,7 @@ public function testDefaultHeaders(): void } #[DataProvider('authBasicProvider')] - public function testAuthBasic($basic): void + public function testAuthBasic(string|array $basic): void { $this->recreateSchema([SecuredDummy::class, RelatedDummy::class]); $client = self::createClient(); diff --git a/tests/Symfony/Controller/MainControllerTest.php b/tests/Symfony/Controller/MainControllerTest.php index 2a9d15b5e3e..896a53e2cce 100644 --- a/tests/Symfony/Controller/MainControllerTest.php +++ b/tests/Symfony/Controller/MainControllerTest.php @@ -70,8 +70,8 @@ public function testControllerWithNonExistentUriVariables(): void $processor = $this->createMock(ProcessorInterface::class); $controller = new MainController($resourceMetadataFactory, $provider, $processor); - $body = new \stdClass(); - $response = new Response(); + new \stdClass(); + new Response(); $request = new Request(); $request->attributes->set('_api_operation', new Get(uriVariables: ['id' => new Link()])); @@ -142,7 +142,7 @@ public function testControllerErrorWithUriVariablesDuringProvider(): void $provider->expects($this->once()) ->method('provide') - ->willReturnCallback(static function () use ($request) { + ->willReturnCallback(static function () use ($request): \stdClass { $request->attributes->set('_api_operation', new Error(uriVariables: ['status' => new Link()])); $request->attributes->remove('id'); diff --git a/tests/Symfony/Messenger/ProcessorTest.php b/tests/Symfony/Messenger/ProcessorTest.php index 098d0aedc32..8c323361dff 100644 --- a/tests/Symfony/Messenger/ProcessorTest.php +++ b/tests/Symfony/Messenger/ProcessorTest.php @@ -35,7 +35,7 @@ public function testPersist(): void $dummy = new Dummy(); $messageBus = $this->prophesize(MessageBusInterface::class); - $messageBus->dispatch(Argument::that(static fn (Envelope $envelope) => $dummy === $envelope->getMessage() && null !== $envelope->last(ContextStamp::class)))->willReturn(new Envelope($dummy))->shouldBeCalled(); + $messageBus->dispatch(Argument::that(static fn (Envelope $envelope): bool => $dummy === $envelope->getMessage() && null !== $envelope->last(ContextStamp::class)))->willReturn(new Envelope($dummy))->shouldBeCalled(); $processor = new Processor($messageBus->reveal()); $this->assertSame($dummy, $processor->process($dummy, new Get())); @@ -47,7 +47,7 @@ public function testRemove(): void $messageBus = $this->prophesize(MessageBusInterface::class); - $messageBus->dispatch(Argument::that(static fn (Envelope $envelope) => $dummy === $envelope->getMessage() && null !== $envelope->last(RemoveStamp::class)))->willReturn(new Envelope($dummy))->shouldBeCalled(); + $messageBus->dispatch(Argument::that(static fn (Envelope $envelope): bool => $dummy === $envelope->getMessage() && null !== $envelope->last(RemoveStamp::class)))->willReturn(new Envelope($dummy))->shouldBeCalled(); $processor = new Processor($messageBus->reveal()); $processor->process($dummy, new Delete()); @@ -58,7 +58,7 @@ public function testHandle(): void $dummy = new Dummy(); $messageBus = $this->prophesize(MessageBusInterface::class); - $messageBus->dispatch(Argument::that(static fn (Envelope $envelope) => $dummy === $envelope->getMessage() && null !== $envelope->last(ContextStamp::class)))->willReturn((new Envelope($dummy))->with(new HandledStamp($dummy, 'DummyHandler::__invoke')))->shouldBeCalled(); + $messageBus->dispatch(Argument::that(static fn (Envelope $envelope): bool => $dummy === $envelope->getMessage() && null !== $envelope->last(ContextStamp::class)))->willReturn((new Envelope($dummy))->with(new HandledStamp($dummy, 'DummyHandler::__invoke')))->shouldBeCalled(); $processor = new Processor($messageBus->reveal()); $this->assertSame($dummy, $processor->process($dummy, new Get())); diff --git a/tests/Symfony/Routing/ApiLoaderTest.php b/tests/Symfony/Routing/ApiLoaderTest.php index da4d2256e05..6038528bbd6 100644 --- a/tests/Symfony/Routing/ApiLoaderTest.php +++ b/tests/Symfony/Routing/ApiLoaderTest.php @@ -76,7 +76,6 @@ public function testApiLoader(): void 'api_platform.action.get_item', null, RelatedDummyEntity::class, - [], 'api_dummies_get_item', ['my_default' => 'default_value', '_controller' => 'should_not_be_overriden'], ['GET'], @@ -91,7 +90,6 @@ public function testApiLoader(): void 'api_platform.action.placeholder', null, RelatedDummyEntity::class, - [], 'api_dummies_delete_item', [], ['DELETE'], @@ -106,7 +104,6 @@ public function testApiLoader(): void 'api_platform.action.placeholder', null, RelatedDummyEntity::class, - [], 'api_dummies_put_item', [], ['PUT'], @@ -121,7 +118,6 @@ public function testApiLoader(): void 'some.service.name', null, RelatedDummyEntity::class, - [], 'api_dummies_my_op_collection', ['my_default' => 'default_value', '_format' => 'a valid format'], ['GET'], @@ -140,7 +136,6 @@ public function testApiLoader(): void 'api_platform.action.placeholder', null, RelatedDummyEntity::class, - [], 'api_dummies_my_second_op_collection', [], ['POST'], @@ -158,7 +153,6 @@ public function testApiLoader(): void 'api_platform.action.placeholder', null, RelatedDummyEntity::class, - [], 'api_dummies_my_path_op_collection', [], ['GET'], @@ -173,7 +167,6 @@ public function testApiLoader(): void 'api_platform.action.placeholder', true, RelatedDummyEntity::class, - [], 'api_dummies_my_stateless_op_collection', [], ['GET'], @@ -188,7 +181,6 @@ public function testApiLoader(): void 'Foo\\Bar\\MyController::method', null, RelatedDummyEntity::class, - [], 'api_dummies_my_controller_method_item', [], ['GET'], @@ -219,7 +211,6 @@ public function testApiLoaderWithPrefix(): void 'api_platform.action.placeholder', null, RelatedDummyEntity::class, - [], 'api_dummies_get_item', ['my_default' => 'default_value', '_controller' => 'should_not_be_overriden'], ['GET'], @@ -234,7 +225,6 @@ public function testApiLoaderWithPrefix(): void 'api_platform.action.placeholder', null, RelatedDummyEntity::class, - [], 'api_dummies_delete_item', [], ['DELETE'] @@ -248,7 +238,6 @@ public function testApiLoaderWithPrefix(): void 'api_platform.action.placeholder', null, RelatedDummyEntity::class, - [], 'api_dummies_put_item', [], ['PUT'] @@ -315,7 +304,7 @@ private function getApiLoaderWithResourceMetadataCollection(ResourceMetadataColl return new ApiLoader($kernelProphecy->reveal(), $resourceNameCollectionFactoryProphecy->reveal(), $resourceMetadataFactory, $containerProphecy->reveal(), ['jsonld' => ['application/ld+json']], [], false, true, true, false); } - private function getRoute(string $path, string $controller, ?bool $stateless, string $resourceClass, array $identifiers, string $operationName, array $extraDefaults = [], array $methods = [], array $requirements = [], array $options = [], string $host = '', array $schemes = [], string $condition = ''): Route + private function getRoute(string $path, string $controller, ?bool $stateless, string $resourceClass, string $operationName, array $extraDefaults = [], array $methods = [], array $requirements = [], array $options = [], string $host = '', array $schemes = [], string $condition = ''): Route { return new Route( $path, diff --git a/tests/Symfony/Routing/IriConverterTest.php b/tests/Symfony/Routing/IriConverterTest.php index 0e05743a303..b1da08caad4 100644 --- a/tests/Symfony/Routing/IriConverterTest.php +++ b/tests/Symfony/Routing/IriConverterTest.php @@ -316,14 +316,14 @@ public function testGetNoItemFromIri(): void private function getResourceClassResolver() { $resourceClassResolver = $this->prophesize(ResourceClassResolverInterface::class); - $resourceClassResolver->isResourceClass(Argument::type('string'))->will(static fn ($args) => true); + $resourceClassResolver->isResourceClass(Argument::type('string'))->will(static fn ($args): true => true); $resourceClassResolver->getResourceClass(Argument::cetera())->will(static fn ($args) => $args[0]::class); return $resourceClassResolver->reveal(); } - private function getIriConverter(?ObjectProphecy $stateProviderProphecy = null, ?ObjectProphecy $routerProphecy = null, ?ObjectProphecy $identifiersExtractorProphecy = null, $resourceMetadataCollectionFactoryProphecy = null, $uriVariablesConverter = null, $decorated = null, ?ObjectProphecy $operationMetadataFactory = null): IriConverter + private function getIriConverter(?ObjectProphecy $stateProviderProphecy = null, ?ObjectProphecy $routerProphecy = null, ?ObjectProphecy $identifiersExtractorProphecy = null, $resourceMetadataCollectionFactoryProphecy = null, $uriVariablesConverter = null, ?SkolemIriConverter $decorated = null, ?ObjectProphecy $operationMetadataFactory = null): IriConverter { if (!$stateProviderProphecy) { $stateProviderProphecy = $this->prophesize(ProviderInterface::class); diff --git a/tests/WithResourcesTrait.php b/tests/WithResourcesTrait.php index 464c653c263..7925fceddde 100644 --- a/tests/WithResourcesTrait.php +++ b/tests/WithResourcesTrait.php @@ -20,7 +20,7 @@ trait WithResourcesTrait */ protected static function writeResources(array $resources): void { - file_put_contents(__DIR__.'/Fixtures/app/var/resources.php', \sprintf(' $v.'::class', $resources)))); + file_put_contents(__DIR__.'/Fixtures/app/var/resources.php', \sprintf(' $v.'::class', $resources)))); } protected static function removeResources(): void