Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <dunglas@gmail.com>
*
* 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;

return RectorConfig::configure()
->withPaths([
__DIR__.'/docs',
__DIR__.'/src',
__DIR__.'/tests',
])
// uncomment to reach your current PHP version
// ->withPhpSets()
->withTypeCoverageLevel(0)
->withDeadCodeLevel(0)
->withCodeQualityLevel(0);
2 changes: 1 addition & 1 deletion src/Doctrine/Orm/Util/QueryChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Laravel/Tests/CustomExceptionHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
}
Expand Down Expand Up @@ -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');
});

Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/Operations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/argument_resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/data_collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/doctrine_orm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/elasticsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/graphql.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/graphql/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/graphql/validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/graphql_mercure.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/hal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/http_cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/http_cache_purger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/hydra.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/json_schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/json_streamer/json.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/jsonapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/jsonld.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/link_security.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/maker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/mcp/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/mcp/mcp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading
Loading