diff --git a/src/Collector/MigrationsCollector.php b/src/Collector/MigrationsCollector.php index bf93e75..8bf02a3 100644 --- a/src/Collector/MigrationsCollector.php +++ b/src/Collector/MigrationsCollector.php @@ -19,8 +19,8 @@ class MigrationsCollector extends DataCollector { public function __construct( - private DependencyFactory $dependencyFactory, - private MigrationsFlattener $flattener, + private readonly DependencyFactory $dependencyFactory, + private readonly MigrationsFlattener $flattener, ) { } diff --git a/src/Collector/MigrationsFlattener.php b/src/Collector/MigrationsFlattener.php index bf4df28..cc97951 100644 --- a/src/Collector/MigrationsFlattener.php +++ b/src/Collector/MigrationsFlattener.php @@ -28,17 +28,15 @@ class MigrationsFlattener */ public function flattenAvailableMigrations(AvailableMigrationsList $migrationsList): array { - return array_map(static function (AvailableMigration $migration) { - return [ - 'version' => (string) $migration->getVersion(), - 'is_new' => true, - 'is_unavailable' => false, - 'description' => $migration->getMigration()->getDescription(), - 'executed_at' => null, - 'execution_time' => null, - 'file' => (new ReflectionClass($migration->getMigration()))->getFileName(), - ]; - }, $migrationsList->getItems()); + return array_map(static fn (AvailableMigration $migration) => [ + 'version' => (string) $migration->getVersion(), + 'is_new' => true, + 'is_unavailable' => false, + 'description' => $migration->getMigration()->getDescription(), + 'executed_at' => null, + 'execution_time' => null, + 'file' => (new ReflectionClass($migration->getMigration()))->getFileName(), + ], $migrationsList->getItems()); } /** diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index dd0c61b..af39f35 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -14,8 +14,8 @@ use function count; use function in_array; use function is_string; +use function str_starts_with; use function strlen; -use function strpos; use function strtoupper; use function substr; @@ -45,11 +45,10 @@ public function getConfigTreeBuilder(): TreeBuilder ->useAttributeAsKey('service') ->defaultValue([]) ->validate() - ->ifTrue(static function (array $v): bool { - return count(array_filter(array_keys($v), static function (string $doctrineService): bool { - return strpos($doctrineService, 'Doctrine\Migrations\\') !== 0; - })) !== 0; - }) + ->ifTrue(static fn (array $v): bool => count(array_filter( + array_keys($v), + static fn (string $doctrineService): bool => ! str_starts_with($doctrineService, 'Doctrine\Migrations\\'), + )) !== 0) ->thenInvalid('Valid services for the DoctrineMigrationsBundle must be in the "Doctrine\Migrations" namespace.') ->end() ->prototype('scalar')->end() @@ -60,11 +59,10 @@ public function getConfigTreeBuilder(): TreeBuilder ->useAttributeAsKey('factory') ->defaultValue([]) ->validate() - ->ifTrue(static function (array $v): bool { - return count(array_filter(array_keys($v), static function (string $doctrineService): bool { - return strpos($doctrineService, 'Doctrine\Migrations\\') !== 0; - })) !== 0; - }) + ->ifTrue(static fn (array $v): bool => count(array_filter( + array_keys($v), + static fn (string $doctrineService): bool => ! str_starts_with($doctrineService, 'Doctrine\Migrations\\'), + )) !== 0) ->thenInvalid('Valid callables for the DoctrineMigrationsBundle must be in the "Doctrine\Migrations" namespace.') ->end() ->prototype('scalar')->end() @@ -128,9 +126,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->end() ->validate() ->ifString() - ->then(static function ($v) { - return constant('Doctrine\Migrations\Configuration\Configuration::VERSIONS_ORGANIZATION_' . strtoupper($v)); - }) + ->then(static fn (string $v): string => constant('Doctrine\Migrations\Configuration\Configuration::VERSIONS_ORGANIZATION_' . strtoupper($v))) ->end() ->end() ->booleanNode('enable_profiler') @@ -160,7 +156,7 @@ private function getOrganizeMigrationsModes(): array $namesArray = []; foreach ($constsArray as $constant) { - if (strpos($constant, $constPrefix) !== 0) { + if (! str_starts_with($constant, $constPrefix)) { continue; } diff --git a/tests/Collector/MigrationsFlattenerTest.php b/tests/Collector/MigrationsFlattenerTest.php index 915102e..80787a3 100644 --- a/tests/Collector/MigrationsFlattenerTest.php +++ b/tests/Collector/MigrationsFlattenerTest.php @@ -20,8 +20,7 @@ class MigrationsFlattenerTest extends TestCase { - /** @var MigrationsFlattener */ - private $flattener; + private MigrationsFlattener $flattener; protected function setUp(): void { diff --git a/tests/DependencyInjection/DoctrineCommandsTest.php b/tests/DependencyInjection/DoctrineCommandsTest.php index 3b32c0e..1a9dce8 100644 --- a/tests/DependencyInjection/DoctrineCommandsTest.php +++ b/tests/DependencyInjection/DoctrineCommandsTest.php @@ -70,8 +70,7 @@ public static function getCommands(): array ]; } - /** @return KernelInterface&MockObject */ - private function getKernel(ContainerBuilder $container): KernelInterface + private function getKernel(ContainerBuilder $container): KernelInterface&MockObject { $kernel = $this->createMock(KernelInterface::class); diff --git a/tests/DependencyInjection/DoctrineMigrationsExtensionTest.php b/tests/DependencyInjection/DoctrineMigrationsExtensionTest.php index 7b1aa4c..749a7cc 100644 --- a/tests/DependencyInjection/DoctrineMigrationsExtensionTest.php +++ b/tests/DependencyInjection/DoctrineMigrationsExtensionTest.php @@ -202,12 +202,9 @@ public function testServiceFactory(): void $container = $this->getContainer($config); $sorterFactory = new class ($mockComparator) { - /** @var Comparator */ - private $comparator; - - public function __construct(Comparator $comparator) - { - $this->comparator = $comparator; + public function __construct( + private readonly Comparator $comparator, + ) { } public function __invoke(DependencyFactory $di): Comparator