Skip to content

Commit

Permalink
Upgrade php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Sep 14, 2021
1 parent d6b82d2 commit f080779
Show file tree
Hide file tree
Showing 72 changed files with 258 additions and 284 deletions.
31 changes: 16 additions & 15 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$header = <<<'EOF'
$header = <<<EOF
This file is part of Sulu.
(c) Sulu GmbH
Expand All @@ -9,31 +9,30 @@
with this source code in the file LICENSE.
EOF;

return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
$finder = PhpCsFixer\Finder::create()
->exclude(['var/cache', 'tests/Resources/cache', 'node_modules'])
->in(__DIR__);

$config = new PhpCsFixer\Config();
$config->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'ordered_imports' => true,
'concat_space' => ['spacing' => 'one'],
'array_syntax' => ['syntax' => 'short'],
'phpdoc_align' => false,
'class_definition' => [
'multiLineExtendsEachSingleLine' => true,
],
'linebreak_after_opening_tag' => true,
'class_definition' => false,
'declare_strict_types' => true,
'mb_str_functions' => true,
'no_php4_constructor' => true,
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true, 'remove_inheritdoc' => true],
'no_useless_return' => true,
'no_useless_else' => true,
'php_unit_strict' => true,
'phpdoc_order' => true,
'strict_comparison' => true,
'strict_param' => true,
'phpdoc_to_comment' => false,
'function_declaration' => ['closure_function_spacing' => 'none'],
'native_function_invocation' => ['include' => ['@internal']],
'phpdoc_align' => ['align' => 'left'],
'phpdoc_types_order' => false,
'header_comment' => ['header' => $header],
'single_line_throw' => false,
])
Expand All @@ -44,3 +43,5 @@
->exclude('Tests/reports/')
->in(__DIR__)
);

return $config;
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function map(
DimensionContentCollectionInterface $dimensionContentCollection
): void {
$dimensionAttributes = $dimensionContentCollection->getDimensionAttributes();
$unlocalizedDimensionAttributes = array_merge($dimensionAttributes, ['locale' => null]);
$unlocalizedDimensionAttributes = \array_merge($dimensionAttributes, ['locale' => null]);
$unlocalizedObject = $dimensionContentCollection->getDimensionContent($unlocalizedDimensionAttributes);

if (!$unlocalizedObject instanceof AuthorInterface) {
Expand All @@ -45,7 +45,7 @@ public function map(

if ($localizedObject) {
if (!$localizedObject instanceof AuthorInterface) {
throw new \RuntimeException(sprintf('Expected "$localizedObject" from type "%s" but "%s" given.', AuthorInterface::class, \get_class($localizedObject)));
throw new \RuntimeException(\sprintf('Expected "$localizedObject" from type "%s" but "%s" given.', AuthorInterface::class, \get_class($localizedObject)));
}

$this->setAuthorData($localizedObject, $data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function map(
DimensionContentCollectionInterface $dimensionContentCollection
): void {
$dimensionAttributes = $dimensionContentCollection->getDimensionAttributes();
$unlocalizedDimensionAttributes = array_merge($dimensionAttributes, ['locale' => null]);
$unlocalizedDimensionAttributes = \array_merge($dimensionAttributes, ['locale' => null]);
$unlocalizedObject = $dimensionContentCollection->getDimensionContent($unlocalizedDimensionAttributes);

if (!$unlocalizedObject instanceof ExcerptInterface) {
Expand All @@ -52,7 +52,7 @@ public function map(

if ($localizedObject) {
if (!$localizedObject instanceof ExcerptInterface) {
throw new \RuntimeException(sprintf('Expected "$localizedObject" from type "%s" but "%s" given.', ExcerptInterface::class, \get_class($localizedObject)));
throw new \RuntimeException(\sprintf('Expected "$localizedObject" from type "%s" but "%s" given.', ExcerptInterface::class, \get_class($localizedObject)));
}

$this->setExcerptData($localizedObject, $data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function map(
$dimensionAttributes = $dimensionContentCollection->getDimensionAttributes();
$localizedObject = $dimensionContentCollection->getDimensionContent($dimensionAttributes);

$unlocalizedDimensionAttributes = array_merge($dimensionAttributes, ['locale' => null]);
$unlocalizedDimensionAttributes = \array_merge($dimensionAttributes, ['locale' => null]);
$unlocalizedObject = $dimensionContentCollection->getDimensionContent($unlocalizedDimensionAttributes);

if (!$localizedObject || !$localizedObject instanceof RoutableInterface) {
Expand Down Expand Up @@ -154,7 +154,7 @@ public function map(
$routePath = $data[$name] ?? null;
if (!$routePath) {
/** @var mixed $routeGenerationData */
$routeGenerationData = array_merge(
$routeGenerationData = \array_merge(
$data,
[
'_unlocalizedObject' => $unlocalizedObject,
Expand Down Expand Up @@ -183,7 +183,7 @@ public function map(

if (($data[$name] ?? null) !== $route->getPath()) {
$localizedObject->setTemplateData(
array_merge(
\array_merge(
$localizedObject->getTemplateData(),
[$name => $route->getPath()]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function map(
DimensionContentCollectionInterface $dimensionContentCollection
): void {
$dimensionAttributes = $dimensionContentCollection->getDimensionAttributes();
$unlocalizedDimensionAttributes = array_merge($dimensionAttributes, ['locale' => null]);
$unlocalizedDimensionAttributes = \array_merge($dimensionAttributes, ['locale' => null]);
$unlocalizedObject = $dimensionContentCollection->getDimensionContent($unlocalizedDimensionAttributes);

if (!$unlocalizedObject instanceof SeoInterface) {
Expand All @@ -34,7 +34,7 @@ public function map(

if ($localizedObject) {
if (!$localizedObject instanceof SeoInterface) {
throw new \RuntimeException(sprintf('Expected "$localizedObject" from type "%s" but "%s" given.', SeoInterface::class, \get_class($localizedObject)));
throw new \RuntimeException(\sprintf('Expected "$localizedObject" from type "%s" but "%s" given.', SeoInterface::class, \get_class($localizedObject)));
}

$this->setSeoData($localizedObject, $data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function map(
DimensionContentCollectionInterface $dimensionContentCollection
): void {
$dimensionAttributes = $dimensionContentCollection->getDimensionAttributes();
$unlocalizedDimensionAttributes = array_merge($dimensionAttributes, ['locale' => null]);
$unlocalizedDimensionAttributes = \array_merge($dimensionAttributes, ['locale' => null]);
$unlocalizedObject = $dimensionContentCollection->getDimensionContent($unlocalizedDimensionAttributes);

if (!$unlocalizedObject instanceof TemplateInterface) {
Expand Down Expand Up @@ -73,7 +73,7 @@ public function map(

if ($localizedObject) {
if (!$localizedObject instanceof TemplateInterface) {
throw new \RuntimeException(sprintf('Expected "$localizedObject" from type "%s" but "%s" given.', TemplateInterface::class, \get_class($localizedObject)));
throw new \RuntimeException(\sprintf('Expected "$localizedObject" from type "%s" but "%s" given.', TemplateInterface::class, \get_class($localizedObject)));
}

$localizedObject->setTemplateKey($template);
Expand All @@ -86,7 +86,7 @@ public function map(
}

// Unlocalized dimensions can contain data of different templates so we need to merge them together
$unlocalizedObject->setTemplateData(array_merge(
$unlocalizedObject->setTemplateData(\array_merge(
$unlocalizedObject->getTemplateData(),
$unlocalizedData
));
Expand All @@ -102,7 +102,7 @@ private function getTemplateData(array $data, string $type, string $template): a
$metadata = $this->factory->getStructureMetadata($type, $template);

if (!$metadata) {
throw new \RuntimeException(sprintf('Could not find structure "%s" of type "%s".', $template, $type));
throw new \RuntimeException(\sprintf('Could not find structure "%s" of type "%s".', $template, $type));
}

$unlocalizedData = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function map(
DimensionContentCollectionInterface $dimensionContentCollection
): void {
$dimensionAttributes = $dimensionContentCollection->getDimensionAttributes();
$unlocalizedDimensionAttributes = array_merge($dimensionAttributes, ['locale' => null]);
$unlocalizedDimensionAttributes = \array_merge($dimensionAttributes, ['locale' => null]);
$unlocalizedObject = $dimensionContentCollection->getDimensionContent($unlocalizedDimensionAttributes);

if (!$unlocalizedObject instanceof WorkflowInterface) {
Expand All @@ -35,7 +35,7 @@ public function map(

if ($localizedObject) {
if (!$localizedObject instanceof WorkflowInterface) {
throw new \RuntimeException(sprintf('Expected "$localizedObject" from type "%s" but "%s" given.', WorkflowInterface::class, \get_class($localizedObject)));
throw new \RuntimeException(\sprintf('Expected "$localizedObject" from type "%s" but "%s" given.', WorkflowInterface::class, \get_class($localizedObject)));
}

$this->setWorkflowData($localizedObject, $data);
Expand Down
6 changes: 3 additions & 3 deletions Content/Application/ContentIndexer/ContentIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function deindex(string $resourceKey, $id, array $dimensionAttributes = [
$locale = $dimensionAttributes['locale'] ?? null;
$stage = $dimensionAttributes['stage'] ?? null;

$search = $this->searchManager->createSearch(sprintf('__id:"%s"', $id))
$search = $this->searchManager->createSearch(\sprintf('__id:"%s"', $id))
->indexes($this->getIndexes($resourceKey, $stage));

if ($locale) {
Expand Down Expand Up @@ -119,9 +119,9 @@ private function loadDimensionContent(
*/
private function getIndexes(string $resourceKey, ?string $stage): array
{
return array_filter(
return \array_filter(
$this->searchManager->getIndexNames(),
function ($indexName) use ($resourceKey, $stage) {
function($indexName) use ($resourceKey, $stage) {
if (null === $stage) {
return $resourceKey === $indexName || $resourceKey . '_published' === $indexName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function merge(object $targetObject, object $sourceObject): void
$targetObject->setTemplateKey($templateKey);
}

$targetObject->setTemplateData(array_merge(
$targetObject->setTemplateData(\array_merge(
$targetObject->getTemplateData(),
$sourceObject->getTemplateData()
));
Expand Down
4 changes: 2 additions & 2 deletions Content/Application/ContentNormalizer/ContentNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function normalize(object $object): array
$ignoredAttributes = [];

foreach ($this->normalizers as $normalizer) {
$ignoredAttributes = array_merge(
$ignoredAttributes = \array_merge(
$ignoredAttributes,
$normalizer->getIgnoredAttributes($object)
);
Expand All @@ -62,7 +62,7 @@ public function normalize(object $object): array
$normalizedData = $normalizer->enhance($object, $normalizedData);
}

ksort($normalizedData);
\ksort($normalizedData);

return $normalizedData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function enhance(object $object, array $normalizedData): array
return $normalizedData;
}

$normalizedData = array_merge($normalizedData['templateData'], $normalizedData);
$normalizedData = \array_merge($normalizedData['templateData'], $normalizedData);
unset($normalizedData['templateData']);

$normalizedData['template'] = $normalizedData['templateKey'];
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, \get_class($localizedDimensionContent)));
}

$workflow = $this->workflowRegistry->get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function onRemoveDraft(TransitionEvent $transitionEvent): void
throw new \RuntimeException('Transition context must contain "contentRichEntity".');
}

$draftDimensionAttributes = array_merge($dimensionAttributes, ['stage' => DimensionContentInterface::STAGE_DRAFT]);
$liveDimensionAttributes = array_merge($dimensionAttributes, ['stage' => DimensionContentInterface::STAGE_LIVE]);
$draftDimensionAttributes = \array_merge($dimensionAttributes, ['stage' => DimensionContentInterface::STAGE_DRAFT]);
$liveDimensionAttributes = \array_merge($dimensionAttributes, ['stage' => DimensionContentInterface::STAGE_LIVE]);

$this->contentCopier->copy(
$contentRichEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function onUnpublish(TransitionEvent $transitionEvent): void
throw new \RuntimeException('Transition context must contain "contentRichEntity".');
}

$liveDimensionAttributes = array_merge($dimensionAttributes, ['stage' => DimensionContentInterface::STAGE_LIVE]);
$liveDimensionAttributes = \array_merge($dimensionAttributes, ['stage' => DimensionContentInterface::STAGE_LIVE]);

$dimensionContentCollection = $this->dimensionContentRepository->load($contentRichEntity, $liveDimensionAttributes);
$localizedLiveDimensionContent = $dimensionContentCollection->getDimensionContent($liveDimensionAttributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function create(
$dimensionContentCollection = $this->dimensionContentRepository->load($contentRichEntity, $dimensionAttributes);
$dimensionAttributes = $dimensionContentCollection->getDimensionAttributes();

$orderedContentDimensions = iterator_to_array($dimensionContentCollection);
$orderedContentDimensions = \iterator_to_array($dimensionContentCollection);
$dimensionContents = new ArrayCollection($orderedContentDimensions);

$unlocalizedAttributes = $dimensionAttributes;
Expand Down
4 changes: 2 additions & 2 deletions Content/Domain/Exception/ContentNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class ContentNotFoundException extends \Exception
*/
public function __construct(ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes)
{
parent::__construct(sprintf(
parent::__construct(\sprintf(
'Could not load content with id "%s" and attributes: %s',
$contentRichEntity->getId(),
json_encode($dimensionAttributes)
\json_encode($dimensionAttributes)
));
}
}
6 changes: 3 additions & 3 deletions Content/Domain/Model/DimensionContentCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ public function __construct(
$this->defaultDimensionAttributes = $dimensionContentClass::getDefaultDimensionAttributes();

$this->unlocalizedDimensionContent = $this->dimensionContents->filter(
function (DimensionContentInterface $dimensionContent) {
function(DimensionContentInterface $dimensionContent) {
return null === $dimensionContent->getLocale();
}
)->first() ?: null;

$this->localizedDimensionContent = $this->dimensionContents->filter(
function (DimensionContentInterface $dimensionContent) {
function(DimensionContentInterface $dimensionContent) {
return null !== $dimensionContent->getLocale();
}
)->first() ?: null;
Expand All @@ -89,7 +89,7 @@ public function getDimensionContentClass(): string

public function getDimensionContent(array $dimensionAttributes): ?DimensionContentInterface
{
$dimensionAttributes = array_merge($this->defaultDimensionAttributes, $dimensionAttributes);
$dimensionAttributes = \array_merge($this->defaultDimensionAttributes, $dimensionAttributes);

$criteria = Criteria::create();
foreach ($dimensionAttributes as $key => $value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ private function getEffectiveAttributes(string $className, array $attributes): a
$defaultValues = $className::getDefaultDimensionAttributes();

// Ignore keys that are not part of the default attributes
$attributes = array_intersect_key($attributes, $defaultValues);
$attributes = \array_intersect_key($attributes, $defaultValues);

$attributes = array_merge(
$attributes = \array_merge(
$defaultValues,
$attributes
);
Expand Down
9 changes: 3 additions & 6 deletions Content/Infrastructure/Doctrine/MetadataLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@

class MetadataLoader implements EventSubscriber
{
/**
* {@inheritdoc}
*/
public function getSubscribedEvents()
{
return [
Expand Down Expand Up @@ -201,7 +198,7 @@ private function addField(ClassMetadataInfo $metadata, string $name, string $typ
$nullable = false;
}

$metadata->mapField(array_merge([
$metadata->mapField(\array_merge([
'fieldName' => $name,
'columnName' => $name,
'type' => $type,
Expand All @@ -215,10 +212,10 @@ private function addField(ClassMetadataInfo $metadata, string $name, string $typ
private function getRelationTableName(ClassMetadataInfo $metadata, string $relationName): string
{
$inflector = InflectorFactory::create()->build();
$tableNameParts = explode('_', $metadata->getTableName());
$tableNameParts = \explode('_', $metadata->getTableName());
$singularName = $inflector->singularize($tableNameParts[\count($tableNameParts) - 1]) . '_';
$tableNameParts[\count($tableNameParts) - 1] = $singularName;

return implode('_', $tableNameParts) . $inflector->tableize($relationName);
return \implode('_', $tableNameParts) . $inflector->tableize($relationName);
}
}
4 changes: 2 additions & 2 deletions Content/Infrastructure/Doctrine/TagFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function create(array $tagNames): array
// sort tags by the given names order
$excerptTags = [];
foreach ($tags as $tag) {
$index = array_search($tag->getName(), $tagNames, true);
$index = \array_search($tag->getName(), $tagNames, true);
$excerptTags[$index] = $tag;
unset($tagNames[$index]);
}
Expand All @@ -67,7 +67,7 @@ public function create(array $tagNames): array
continue;
}

$index = array_search($object->getName(), $tagNames, true);
$index = \array_search($object->getName(), $tagNames, true);

if (false === $index) {
continue;
Expand Down
Loading

0 comments on commit f080779

Please sign in to comment.