Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PHP 7.4 syntax #769

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions CacheWarmer/ProxyCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ public function warmUp($cacheDir)
/** @return ClassMetadata[] */
private function getClassesForProxyGeneration(DocumentManager $dm)
{
return array_filter($dm->getMetadataFactory()->getAllMetadata(), static function (ClassMetadata $metadata) {
return ! $metadata->isEmbeddedDocument && ! $metadata->isMappedSuperclass;
});
return array_filter($dm->getMetadataFactory()->getAllMetadata(), static fn (ClassMetadata $metadata) => ! $metadata->isEmbeddedDocument && ! $metadata->isMappedSuperclass);
}
}
4 changes: 1 addition & 3 deletions Command/InfoDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ protected function configure()
/** @return int */
protected function execute(InputInterface $input, OutputInterface $output)
{
$documentManagerName = $input->getOption('dm') ?
$input->getOption('dm') :
$this->getManagerRegistry()->getDefaultManagerName();
$documentManagerName = $input->hasOption('dm') ? $input->getOption('dm') : $this->getManagerRegistry()->getDefaultManagerName();

$documentManager = $this->getManagerRegistry()->getManager($documentManagerName);
assert($documentManager instanceof DocumentManager);
Expand Down
4 changes: 1 addition & 3 deletions DataCollector/CommandDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ static function (Command $command): array {
),
'time' => array_reduce(
$this->commandLogger->getAll(),
static function (int $total, Command $command): int {
return $total + $command->getDurationMicros();
},
static fn (int $total, Command $command): int => $total + $command->getDurationMicros(),
0
),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ public function process(ContainerBuilder $container)

$repoServiceIds = array_keys($container->findTaggedServiceIds(self::REPOSITORY_SERVICE_TAG));

$repoReferences = array_map(static function ($id) {
return new Reference($id);
}, $repoServiceIds);
$repoReferences = array_map(static fn ($id) => new Reference($id), $repoServiceIds);

$locatorDef->replaceArgument(0, ServiceLocatorTagPass::register($container, array_combine($repoServiceIds, $repoReferences)));
}
Expand Down
4 changes: 1 addition & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,7 @@ private function addTypesSection(ArrayNodeDefinition $rootNode)
->prototype('array')
->beforeNormalization()
->ifString()
->then(static function ($v) {
return ['class' => $v];
})
->then(static fn ($v) => ['class' => $v])
->end()
->children()
->scalarNode('class')->isRequired()->end()
Expand Down
4 changes: 1 addition & 3 deletions Tests/DependencyInjection/AbstractMongoDBExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ public function testLoadSimpleSingleConnection(): void

$definition = $container->getDefinition('doctrine_mongodb.odm.default_configuration');
$methodCalls = $definition->getMethodCalls();
$methodNames = array_map(static function ($call) {
return $call[0];
}, $methodCalls);
$methodNames = array_map(static fn ($call) => $call[0], $methodCalls);
$this->assertIsInt($pos = array_search('setDefaultDB', $methodNames));
$this->assertEquals('mydb', $methodCalls[$pos][1][0]);

Expand Down
20 changes: 5 additions & 15 deletions Tests/FixtureIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ public function testFixturesLoader(): void

$actualFixtures = $loader->getFixtures();
$this->assertCount(2, $actualFixtures);
$actualFixtureClasses = array_map(static function ($fixture) {
return get_class($fixture);
}, $actualFixtures);
$actualFixtureClasses = array_map(static fn ($fixture) => get_class($fixture), $actualFixtures);

$this->assertSame([
OtherFixtures::class,
Expand Down Expand Up @@ -85,9 +83,7 @@ public function testFixturesLoaderWhenFixtureHasDependencyThatIsNotYetLoaded():

$actualFixtures = $loader->getFixtures();
$this->assertCount(2, $actualFixtures);
$actualFixtureClasses = array_map(static function ($fixture) {
return get_class($fixture);
}, $actualFixtures);
$actualFixtureClasses = array_map(static fn ($fixture) => get_class($fixture), $actualFixtures);

$this->assertSame([
OtherFixtures::class,
Expand Down Expand Up @@ -143,9 +139,7 @@ public function testFixturesLoaderWithGroupsOptionViaInterface(): void

$actualFixtures = $loader->getFixtures(['staging']);
$this->assertCount(1, $actualFixtures);
$actualFixtureClasses = array_map(static function ($fixture) {
return get_class($fixture);
}, $actualFixtures);
$actualFixtureClasses = array_map(static fn ($fixture) => get_class($fixture), $actualFixtures);

$this->assertSame([
OtherFixtures::class,
Expand Down Expand Up @@ -234,9 +228,7 @@ public function testLoadFixturesViaGroupWithFulfilledDependency(): void
$actualFixtures = $loader->getFixtures(['fulfilledDependencyGroup']);

$this->assertCount(2, $actualFixtures);
$actualFixtureClasses = array_map(static function ($fixture) {
return get_class($fixture);
}, $actualFixtures);
$actualFixtureClasses = array_map(static fn ($fixture) => get_class($fixture), $actualFixtures);

$this->assertSame([
OtherFixtures::class,
Expand Down Expand Up @@ -267,9 +259,7 @@ public function testLoadFixturesByShortName(): void
$actualFixtures = $loader->getFixtures(['OtherFixtures']);

$this->assertCount(1, $actualFixtures);
$actualFixtureClasses = array_map(static function ($fixture) {
return get_class($fixture);
}, $actualFixtures);
$actualFixtureClasses = array_map(static fn ($fixture) => get_class($fixture), $actualFixtures);

$this->assertSame([
OtherFixtures::class,
Expand Down
12 changes: 3 additions & 9 deletions Tests/Repository/ContainerRepositoryFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,10 @@ private function createContainer(array $services)
$container = $this->getMockBuilder(ContainerInterface::class)->getMock();
$container
->method('has')
->willReturnCallback(static function ($id) use ($services) {
return isset($services[$id]);
});
->willReturnCallback(static fn ($id) => isset($services[$id]));
$container
->method('get')
->willReturnCallback(static function ($id) use ($services) {
return $services[$id];
});
->willReturnCallback(static fn ($id) => $services[$id]);

return $container;
}
Expand All @@ -148,9 +144,7 @@ private function createDocumentManager(array $documentRepositoryClasses)
$dm = $this->getMockBuilder(DocumentManager::class)->disableOriginalConstructor()->getMock();
$dm
->method('getClassMetadata')
->willReturnCallback(static function ($class) use ($classMetadatas) {
return $classMetadatas[$class];
});
->willReturnCallback(static fn ($class) => $classMetadatas[$class]);

$evm = $this->createMock(EventManager::class);

Expand Down