diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 76416958..cfbfcb60 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -11,30 +11,41 @@ $config = new PhpCsFixer\Config(); $config->setRiskyAllowed(true) + ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) ->setRules([ '@Symfony' => true, '@Symfony:risky' => true, + 'array_syntax' => ['syntax' => 'short'], 'class_definition' => false, 'concat_space' => ['spacing' => 'one'], 'declare_strict_types' => true, 'function_declaration' => ['closure_function_spacing' => 'none'], 'header_comment' => ['header' => $header], + 'native_constant_invocation' => true, + 'native_function_casing' => true, 'native_function_invocation' => ['include' => ['@internal']], + 'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false], 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true, 'remove_inheritdoc' => true], + 'ordered_imports' => true, 'no_useless_else' => true, 'no_useless_return' => true, 'php_unit_strict' => true, 'phpdoc_align' => ['align' => 'left'], 'phpdoc_order' => true, - 'phpdoc_to_comment' => false, 'phpdoc_types_order' => false, 'single_line_throw' => false, + 'single_line_comment_spacing' => false, 'strict_comparison' => true, 'strict_param' => true, - 'get_class_to_class_keyword' => false, // should be enabled as soon as support for php < 8 is dropped + 'phpdoc_to_comment' => [ + 'ignored_tags' => ['todo', 'var'], + ], + 'get_class_to_class_keyword' => true, 'nullable_type_declaration_for_default_null_value' => true, 'no_null_property_initialization' => false, + 'fully_qualified_strict_types' => false, 'new_with_parentheses' => true, + 'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['array_destructuring', 'arrays', 'match']], ]) ->setFinder( PhpCsFixer\Finder::create() diff --git a/Content/Application/ContentWorkflow/ContentWorkflow.php b/Content/Application/ContentWorkflow/ContentWorkflow.php index 5b18ab23..53c196b3 100644 --- a/Content/Application/ContentWorkflow/ContentWorkflow.php +++ b/Content/Application/ContentWorkflow/ContentWorkflow.php @@ -94,7 +94,7 @@ public function apply( } if (!$localizedDimensionContent instanceof WorkflowInterface) { - throw new \RuntimeException(\sprintf('Expected "%s" but "%s" given.', WorkflowInterface::class, \get_class($localizedDimensionContent))); + throw new \RuntimeException(\sprintf('Expected "%s" but "%s" given.', WorkflowInterface::class, $localizedDimensionContent::class)); } $workflow = $this->workflowRegistry->get( diff --git a/Content/Infrastructure/Doctrine/DimensionContentRepository.php b/Content/Infrastructure/Doctrine/DimensionContentRepository.php index 3222199e..6ce8216f 100644 --- a/Content/Infrastructure/Doctrine/DimensionContentRepository.php +++ b/Content/Infrastructure/Doctrine/DimensionContentRepository.php @@ -60,8 +60,8 @@ public function load( ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes ): DimensionContentCollectionInterface { - $dimensionContentClass = $this->contentMetadataInspector->getDimensionContentClass(\get_class($contentRichEntity)); - $mappingProperty = $this->contentMetadataInspector->getDimensionContentPropertyName(\get_class($contentRichEntity)); + $dimensionContentClass = $this->contentMetadataInspector->getDimensionContentClass($contentRichEntity::class); + $mappingProperty = $this->contentMetadataInspector->getDimensionContentPropertyName($contentRichEntity::class); $queryBuilder = $this->entityManager->createQueryBuilder() ->from($dimensionContentClass, 'dimensionContent') diff --git a/Content/Infrastructure/Doctrine/RouteRemover.php b/Content/Infrastructure/Doctrine/RouteRemover.php index e1d07528..c5a28cdf 100644 --- a/Content/Infrastructure/Doctrine/RouteRemover.php +++ b/Content/Infrastructure/Doctrine/RouteRemover.php @@ -67,7 +67,7 @@ public function preRemove(LifecycleEventArgs $event): void return; // @codeCoverageIgnore } - $dimensionContentClass = $this->contentMetadataInspector->getDimensionContentClass(\get_class($object)); + $dimensionContentClass = $this->contentMetadataInspector->getDimensionContentClass($object::class); $resourceKey = $dimensionContentClass::getResourceKey(); $entityClass = null; diff --git a/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProvider.php b/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProvider.php index 72ce500f..bbce98e5 100644 --- a/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProvider.php +++ b/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProvider.php @@ -80,7 +80,7 @@ public function getByEntity($entityClass, $id, $locale, $object = null) } if (!$entity instanceof TemplateInterface) { - throw new \RuntimeException(\sprintf('Expected to get "%s" from ContentResolver but "%s" given.', TemplateInterface::class, \get_class($entity))); + throw new \RuntimeException(\sprintf('Expected to get "%s" from ContentResolver but "%s" given.', TemplateInterface::class, $entity::class)); } try { @@ -156,7 +156,7 @@ protected function loadEntity(string $entityClass, string $id, string $locale): ); if (!$resolvedDimensionContent instanceof TemplateInterface) { - throw new \RuntimeException(\sprintf('Expected to get "%s" from ContentResolver but "%s" given.', TemplateInterface::class, \get_class($resolvedDimensionContent))); + throw new \RuntimeException(\sprintf('Expected to get "%s" from ContentResolver but "%s" given.', TemplateInterface::class, $resolvedDimensionContent::class)); } return $resolvedDimensionContent; diff --git a/Tests/Functional/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProviderTest.php b/Tests/Functional/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProviderTest.php index 5b1a72a0..dbe76e9f 100644 --- a/Tests/Functional/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProviderTest.php +++ b/Tests/Functional/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProviderTest.php @@ -146,7 +146,7 @@ public function testCreateSitemap(): void $sitemap = $this->contentSitemapProvider->createSitemap(static::SCHEME, static::HOST); $this->assertNotNull($sitemap); - $this->assertSame(Sitemap::class, \get_class($sitemap)); + $this->assertSame(Sitemap::class, $sitemap::class); $this->assertSame($this->contentSitemapProvider->getAlias(), $sitemap->getAlias()); $this->assertSame($this->contentSitemapProvider->getMaxPage(static::SCHEME, static::HOST), $sitemap->getMaxPage()); } diff --git a/Tests/Traits/CreateExampleTrait.php b/Tests/Traits/CreateExampleTrait.php index 29ac19c7..8b9ba0a7 100644 --- a/Tests/Traits/CreateExampleTrait.php +++ b/Tests/Traits/CreateExampleTrait.php @@ -152,7 +152,7 @@ protected static function createExample(array $dataSet = [], array $options = [] $draftTemplateData = $draftLocalizedDimension->getTemplateData(); $route->setPath($draftTemplateData['url']); $route->setEntityId($example->getId()); // @phpstan-ignore-line - $route->setEntityClass(\get_class($example)); + $route->setEntityClass($example::class); $entityManager->persist($route); } diff --git a/Tests/Unit/Content/Application/ContentMerger/ContentMergerTest.php b/Tests/Unit/Content/Application/ContentMerger/ContentMergerTest.php index fe155296..2860f0a3 100644 --- a/Tests/Unit/Content/Application/ContentMerger/ContentMergerTest.php +++ b/Tests/Unit/Content/Application/ContentMerger/ContentMergerTest.php @@ -79,7 +79,7 @@ public function testMerge(): void ], [ 'locale' => 'en', 'stage' => 'draft', - ], \get_class($dimensionContent1)); + ], $dimensionContent1::class); $this->assertSame( $mergedDimensionContent->reveal(), diff --git a/Tests/Unit/Content/Infrastructure/Sulu/Admin/ContentViewBuilderFactoryTest.php b/Tests/Unit/Content/Infrastructure/Sulu/Admin/ContentViewBuilderFactoryTest.php index 6dac5be1..ee2307d5 100644 --- a/Tests/Unit/Content/Infrastructure/Sulu/Admin/ContentViewBuilderFactoryTest.php +++ b/Tests/Unit/Content/Infrastructure/Sulu/Admin/ContentViewBuilderFactoryTest.php @@ -446,7 +446,7 @@ public function testCreateViewsWithContentRichEntityClass(DimensionContentInterf $contentMetadataInspector = $this->prophesize(ContentMetadataInspectorInterface::class); $contentMetadataInspector->getDimensionContentClass(Example::class) - ->willReturn(\get_class($dimensionContentObject)); + ->willReturn($dimensionContentObject::class); $contentViewBuilder = $this->createContentViewBuilder($contentMetadataInspector->reveal(), $securityChecker->reveal()); diff --git a/Tests/Unit/Content/Infrastructure/Sulu/Automation/ContentPublishTaskHandlerTest.php b/Tests/Unit/Content/Infrastructure/Sulu/Automation/ContentPublishTaskHandlerTest.php index d29d1984..65e68126 100644 --- a/Tests/Unit/Content/Infrastructure/Sulu/Automation/ContentPublishTaskHandlerTest.php +++ b/Tests/Unit/Content/Infrastructure/Sulu/Automation/ContentPublishTaskHandlerTest.php @@ -112,7 +112,7 @@ public function testSupports(): void { $entity = new Example(); - $this->assertTrue($this->handler->supports(\get_class($entity))); + $this->assertTrue($this->handler->supports($entity::class)); $this->assertFalse($this->handler->supports(PageDocument::class)); } diff --git a/Tests/Unit/Content/Infrastructure/Sulu/Automation/ContentUnpublishTaskHandlerTest.php b/Tests/Unit/Content/Infrastructure/Sulu/Automation/ContentUnpublishTaskHandlerTest.php index dc0c08ad..66a8c87c 100644 --- a/Tests/Unit/Content/Infrastructure/Sulu/Automation/ContentUnpublishTaskHandlerTest.php +++ b/Tests/Unit/Content/Infrastructure/Sulu/Automation/ContentUnpublishTaskHandlerTest.php @@ -112,7 +112,7 @@ public function testSupports(): void { $entity = new Example(); - $this->assertTrue($this->handler->supports(\get_class($entity))); + $this->assertTrue($this->handler->supports($entity::class)); $this->assertFalse($this->handler->supports(PageDocument::class)); } diff --git a/Tests/Unit/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProviderTest.php b/Tests/Unit/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProviderTest.php index 1197cc4c..93833b14 100644 --- a/Tests/Unit/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProviderTest.php +++ b/Tests/Unit/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProviderTest.php @@ -67,7 +67,7 @@ public function testSupports(): void $contentRichEntity = new Example(); - $this->assertTrue($contentRouteDefaultsProvider->supports(\get_class($contentRichEntity))); + $this->assertTrue($contentRouteDefaultsProvider->supports($contentRichEntity::class)); $this->assertFalse($contentRouteDefaultsProvider->supports(\stdClass::class)); }