Skip to content

Commit

Permalink
Fix php-cs-fix config (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
Prokyonn authored Sep 25, 2024
1 parent bf5cfd7 commit 63c1e51
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 15 deletions.
15 changes: 13 additions & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Content/Application/ContentWorkflow/ContentWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion Content/Infrastructure/Doctrine/RouteRemover.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Traits/CreateExampleTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function testMerge(): void
], [
'locale' => 'en',
'stage' => 'draft',
], \get_class($dimensionContent1));
], $dimensionContent1::class);

$this->assertSame(
$mergedDimensionContent->reveal(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit 63c1e51

Please sign in to comment.