diff --git a/.gitignore b/.gitignore index 72fd675f..f05fcb90 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,7 @@ package-lock.json Tests/Application/var Tests/Application/public/build Tests/Application/.env.local -Tests/Application/.env.test.local +Tests/Application/.env.*.local Tests/reports/ # IDEs diff --git a/.php_cs.dist b/.php-cs-fixer.dist.php similarity index 61% rename from .php_cs.dist rename to .php-cs-fixer.dist.php index 2e80eed7..2fd9ff01 100644 --- a/.php_cs.dist +++ b/.php-cs-fixer.dist.php @@ -1,6 +1,6 @@ setRiskyAllowed(true) +$config = new PhpCsFixer\Config(); +$config->setRiskyAllowed(true) ->setRules([ '@Symfony' => true, '@Symfony:risky' => true, - 'ordered_imports' => true, + 'class_definition' => false, 'concat_space' => ['spacing' => 'one'], - 'array_syntax' => ['syntax' => 'short'], - 'phpdoc_align' => false, - 'class_definition' => [ - 'multiLineExtendsEachSingleLine' => true, - ], - 'linebreak_after_opening_tag' => true, '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, + 'function_declaration' => ['closure_function_spacing' => 'none'], + 'header_comment' => ['header' => $header], + 'native_function_invocation' => ['include' => ['@internal']], + 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true, 'remove_inheritdoc' => true], 'no_useless_else' => true, 'no_useless_return' => true, 'php_unit_strict' => true, + 'phpdoc_align' => ['align' => 'left'], 'phpdoc_order' => true, - 'strict_comparison' => true, - 'strict_param' => true, 'phpdoc_to_comment' => false, - 'header_comment' => ['header' => $header], + 'phpdoc_types_order' => false, 'single_line_throw' => false, + 'strict_comparison' => true, + 'strict_param' => true, ]) ->setFinder( PhpCsFixer\Finder::create() @@ -44,3 +39,5 @@ ->exclude('Tests/reports/') ->in(__DIR__) ); + +return $config; diff --git a/Content/Application/ContentDataMapper/DataMapper/ExcerptDataMapper.php b/Content/Application/ContentDataMapper/DataMapper/ExcerptDataMapper.php index 69cc790c..ea6d52eb 100644 --- a/Content/Application/ContentDataMapper/DataMapper/ExcerptDataMapper.php +++ b/Content/Application/ContentDataMapper/DataMapper/ExcerptDataMapper.php @@ -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) { @@ -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); diff --git a/Content/Application/ContentDataMapper/DataMapper/RoutableDataMapper.php b/Content/Application/ContentDataMapper/DataMapper/RoutableDataMapper.php index ac267ad1..db36c749 100644 --- a/Content/Application/ContentDataMapper/DataMapper/RoutableDataMapper.php +++ b/Content/Application/ContentDataMapper/DataMapper/RoutableDataMapper.php @@ -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) { @@ -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, @@ -183,7 +183,7 @@ public function map( if (($data[$name] ?? null) !== $route->getPath()) { $localizedObject->setTemplateData( - array_merge( + \array_merge( $localizedObject->getTemplateData(), [$name => $route->getPath()] ) diff --git a/Content/Application/ContentDataMapper/DataMapper/SeoDataMapper.php b/Content/Application/ContentDataMapper/DataMapper/SeoDataMapper.php index c2ba2181..53a2165f 100644 --- a/Content/Application/ContentDataMapper/DataMapper/SeoDataMapper.php +++ b/Content/Application/ContentDataMapper/DataMapper/SeoDataMapper.php @@ -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) { @@ -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); diff --git a/Content/Application/ContentDataMapper/DataMapper/TemplateDataMapper.php b/Content/Application/ContentDataMapper/DataMapper/TemplateDataMapper.php index 0a1a9cd8..040b3e11 100644 --- a/Content/Application/ContentDataMapper/DataMapper/TemplateDataMapper.php +++ b/Content/Application/ContentDataMapper/DataMapper/TemplateDataMapper.php @@ -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) { @@ -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); @@ -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 )); @@ -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 = []; diff --git a/Content/Application/ContentDataMapper/DataMapper/WorkflowDataMapper.php b/Content/Application/ContentDataMapper/DataMapper/WorkflowDataMapper.php index c8f9d1e9..36cffc34 100644 --- a/Content/Application/ContentDataMapper/DataMapper/WorkflowDataMapper.php +++ b/Content/Application/ContentDataMapper/DataMapper/WorkflowDataMapper.php @@ -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) { @@ -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); diff --git a/Content/Application/ContentIndexer/ContentIndexer.php b/Content/Application/ContentIndexer/ContentIndexer.php index a08a878b..e22c73cf 100644 --- a/Content/Application/ContentIndexer/ContentIndexer.php +++ b/Content/Application/ContentIndexer/ContentIndexer.php @@ -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) { @@ -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; } diff --git a/Content/Application/ContentMerger/Merger/TemplateMerger.php b/Content/Application/ContentMerger/Merger/TemplateMerger.php index 92d98242..8d4863ca 100644 --- a/Content/Application/ContentMerger/Merger/TemplateMerger.php +++ b/Content/Application/ContentMerger/Merger/TemplateMerger.php @@ -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() )); diff --git a/Content/Application/ContentMetadataInspector/ContentMetadataInspector.php b/Content/Application/ContentMetadataInspector/ContentMetadataInspector.php index 94bd0e99..e7b23ab4 100644 --- a/Content/Application/ContentMetadataInspector/ContentMetadataInspector.php +++ b/Content/Application/ContentMetadataInspector/ContentMetadataInspector.php @@ -14,6 +14,7 @@ namespace Sulu\Bundle\ContentBundle\Content\Application\ContentMetadataInspector; use Doctrine\ORM\EntityManagerInterface; +use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface; class ContentMetadataInspector implements ContentMetadataInspectorInterface { @@ -30,6 +31,7 @@ public function __construct(EntityManagerInterface $entityManager) public function getDimensionContentClass(string $contentRichEntityClass): string { $classMetadata = $this->entityManager->getClassMetadata($contentRichEntityClass); + /** @var array{targetEntity: class-string} $associationMapping */ $associationMapping = $classMetadata->getAssociationMapping('dimensionContents'); return $associationMapping['targetEntity']; @@ -38,6 +40,7 @@ public function getDimensionContentClass(string $contentRichEntityClass): string public function getDimensionContentPropertyName(string $contentRichEntityClass): string { $classMetadata = $this->entityManager->getClassMetadata($contentRichEntityClass); + /** @var array{mappedBy: string} $associationMapping */ $associationMapping = $classMetadata->getAssociationMapping('dimensionContents'); return $associationMapping['mappedBy']; diff --git a/Content/Application/ContentNormalizer/ContentNormalizer.php b/Content/Application/ContentNormalizer/ContentNormalizer.php index f7208f58..2130d194 100644 --- a/Content/Application/ContentNormalizer/ContentNormalizer.php +++ b/Content/Application/ContentNormalizer/ContentNormalizer.php @@ -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) ); @@ -62,7 +62,7 @@ public function normalize(object $object): array $normalizedData = $normalizer->enhance($object, $normalizedData); } - ksort($normalizedData); + \ksort($normalizedData); return $normalizedData; } diff --git a/Content/Application/ContentNormalizer/Normalizer/TemplateNormalizer.php b/Content/Application/ContentNormalizer/Normalizer/TemplateNormalizer.php index da15dcc8..6497099f 100644 --- a/Content/Application/ContentNormalizer/Normalizer/TemplateNormalizer.php +++ b/Content/Application/ContentNormalizer/Normalizer/TemplateNormalizer.php @@ -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']; diff --git a/Content/Application/ContentWorkflow/ContentWorkflow.php b/Content/Application/ContentWorkflow/ContentWorkflow.php index 935ed5fd..5b18ab23 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, \get_class($localizedDimensionContent))); } $workflow = $this->workflowRegistry->get( diff --git a/Content/Application/ContentWorkflow/ContentWorkflowInterface.php b/Content/Application/ContentWorkflow/ContentWorkflowInterface.php index 19d3e6c1..8f8dda97 100644 --- a/Content/Application/ContentWorkflow/ContentWorkflowInterface.php +++ b/Content/Application/ContentWorkflow/ContentWorkflowInterface.php @@ -18,9 +18,9 @@ interface ContentWorkflowInterface { - const CONTENT_RICH_ENTITY_CONTEXT_KEY = 'contentRichEntity'; - const DIMENSION_CONTENT_COLLECTION_CONTEXT_KEY = 'dimensionContentCollection'; - const DIMENSION_ATTRIBUTES_CONTEXT_KEY = 'dimensionAttributes'; + public const CONTENT_RICH_ENTITY_CONTEXT_KEY = 'contentRichEntity'; + public const DIMENSION_CONTENT_COLLECTION_CONTEXT_KEY = 'dimensionContentCollection'; + public const DIMENSION_ATTRIBUTES_CONTEXT_KEY = 'dimensionAttributes'; /** * @param mixed[] $dimensionAttributes diff --git a/Content/Application/ContentWorkflow/Subscriber/RemoveDraftTransitionSubscriber.php b/Content/Application/ContentWorkflow/Subscriber/RemoveDraftTransitionSubscriber.php index c5ed4ec1..3e0f7402 100644 --- a/Content/Application/ContentWorkflow/Subscriber/RemoveDraftTransitionSubscriber.php +++ b/Content/Application/ContentWorkflow/Subscriber/RemoveDraftTransitionSubscriber.php @@ -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, diff --git a/Content/Application/ContentWorkflow/Subscriber/UnpublishTransitionSubscriber.php b/Content/Application/ContentWorkflow/Subscriber/UnpublishTransitionSubscriber.php index 86dba6d5..30028743 100644 --- a/Content/Application/ContentWorkflow/Subscriber/UnpublishTransitionSubscriber.php +++ b/Content/Application/ContentWorkflow/Subscriber/UnpublishTransitionSubscriber.php @@ -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); diff --git a/Content/Application/DimensionContentCollectionFactory/DimensionContentCollectionFactory.php b/Content/Application/DimensionContentCollectionFactory/DimensionContentCollectionFactory.php index 7b2cb45e..d9dd7f81 100644 --- a/Content/Application/DimensionContentCollectionFactory/DimensionContentCollectionFactory.php +++ b/Content/Application/DimensionContentCollectionFactory/DimensionContentCollectionFactory.php @@ -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; diff --git a/Content/Domain/Exception/ContentNotFoundException.php b/Content/Domain/Exception/ContentNotFoundException.php index 8830e6d6..b5bba848 100644 --- a/Content/Domain/Exception/ContentNotFoundException.php +++ b/Content/Domain/Exception/ContentNotFoundException.php @@ -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) )); } } diff --git a/Content/Domain/Model/DimensionContentCollection.php b/Content/Domain/Model/DimensionContentCollection.php index 13caebb5..c38c4f8d 100644 --- a/Content/Domain/Model/DimensionContentCollection.php +++ b/Content/Domain/Model/DimensionContentCollection.php @@ -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; @@ -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) { diff --git a/Content/Domain/Model/DimensionContentInterface.php b/Content/Domain/Model/DimensionContentInterface.php index 9d0971c0..8e1eebe4 100644 --- a/Content/Domain/Model/DimensionContentInterface.php +++ b/Content/Domain/Model/DimensionContentInterface.php @@ -15,8 +15,8 @@ interface DimensionContentInterface { - const STAGE_DRAFT = 'draft'; - const STAGE_LIVE = 'live'; + public const STAGE_DRAFT = 'draft'; + public const STAGE_LIVE = 'live'; public static function getResourceKey(): string; diff --git a/Content/Domain/Model/WorkflowInterface.php b/Content/Domain/Model/WorkflowInterface.php index 6c09f0fd..4fbfb614 100644 --- a/Content/Domain/Model/WorkflowInterface.php +++ b/Content/Domain/Model/WorkflowInterface.php @@ -17,33 +17,33 @@ interface WorkflowInterface { // See https://github.com/sulu/SuluContentBundle/pull/53 for graphic about workflow - const WORKFLOW_PLACE_UNPUBLISHED = 'unpublished'; // was never published or set to review + public const WORKFLOW_PLACE_UNPUBLISHED = 'unpublished'; // was never published or set to review - const WORKFLOW_PLACE_REVIEW = 'review'; // unpublished changes are in review + public const WORKFLOW_PLACE_REVIEW = 'review'; // unpublished changes are in review - const WORKFLOW_PLACE_PUBLISHED = 'published'; // is published + public const WORKFLOW_PLACE_PUBLISHED = 'published'; // is published - const WORKFLOW_PLACE_DRAFT = 'draft'; // published but has a draft data + public const WORKFLOW_PLACE_DRAFT = 'draft'; // published but has a draft data - const WORKFLOW_PLACE_REVIEW_DRAFT = 'review_draft'; // published but has draft data in review + public const WORKFLOW_PLACE_REVIEW_DRAFT = 'review_draft'; // published but has draft data in review - const WORKFLOW_TRANSITION_REQUEST_FOR_REVIEW = 'request_for_review'; + public const WORKFLOW_TRANSITION_REQUEST_FOR_REVIEW = 'request_for_review'; - const WORKFLOW_TRANSITION_REJECT = 'reject'; + public const WORKFLOW_TRANSITION_REJECT = 'reject'; - const WORKFLOW_TRANSITION_PUBLISH = 'publish'; + public const WORKFLOW_TRANSITION_PUBLISH = 'publish'; - const WORKFLOW_TRANSITION_UNPUBLISH = 'unpublish'; + public const WORKFLOW_TRANSITION_UNPUBLISH = 'unpublish'; - const WORKFLOW_TRANSITION_CREATE_DRAFT = 'create_draft'; + public const WORKFLOW_TRANSITION_CREATE_DRAFT = 'create_draft'; - const WORKFLOW_TRANSITION_REMOVE_DRAFT = 'remove_draft'; + public const WORKFLOW_TRANSITION_REMOVE_DRAFT = 'remove_draft'; - const WORKFLOW_TRANSITION_REQUEST_FOR_REVIEW_DRAFT = 'request_for_review_draft'; + public const WORKFLOW_TRANSITION_REQUEST_FOR_REVIEW_DRAFT = 'request_for_review_draft'; - const WORKFLOW_TRANSITION_REJECT_DRAFT = 'reject_draft'; + public const WORKFLOW_TRANSITION_REJECT_DRAFT = 'reject_draft'; - const WORKFLOW_DEFAULT_NAME = 'content_workflow'; + public const WORKFLOW_DEFAULT_NAME = 'content_workflow'; public static function getWorkflowName(): string; diff --git a/Content/Infrastructure/Doctrine/DimensionContentRepository.php b/Content/Infrastructure/Doctrine/DimensionContentRepository.php index 75607054..ff658f60 100644 --- a/Content/Infrastructure/Doctrine/DimensionContentRepository.php +++ b/Content/Infrastructure/Doctrine/DimensionContentRepository.php @@ -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 ); diff --git a/Content/Infrastructure/Doctrine/MetadataLoader.php b/Content/Infrastructure/Doctrine/MetadataLoader.php index 6d460b30..641a4763 100644 --- a/Content/Infrastructure/Doctrine/MetadataLoader.php +++ b/Content/Infrastructure/Doctrine/MetadataLoader.php @@ -29,9 +29,6 @@ class MetadataLoader implements EventSubscriber { - /** - * {@inheritdoc} - */ public function getSubscribedEvents() { return [ @@ -41,6 +38,7 @@ public function getSubscribedEvents() public function loadClassMetadata(LoadClassMetadataEventArgs $event): void { + /** @var ClassMetadataInfo $metadata */ $metadata = $event->getClassMetadata(); $reflection = $metadata->getReflectionClass(); @@ -102,6 +100,8 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $event): void /** * @codeCoverageIgnore + * + * @param ClassMetadataInfo $metadata */ private function addManyToOne( LoadClassMetadataEventArgs $event, @@ -121,7 +121,7 @@ private function addManyToOne( 'targetEntity' => $class, 'joinColumns' => [ [ - 'name' => $namingStrategy->joinKeyColumnName($name), + 'name' => $namingStrategy->joinKeyColumnName($name), // @phpstan-ignore-line 'referencedColumnName' => $referencedColumnName, 'nullable' => false, 'onDelete' => 'CASCADE', @@ -131,6 +131,9 @@ private function addManyToOne( ]); } + /** + * @param ClassMetadataInfo $metadata + */ private function addManyToMany( LoadClassMetadataEventArgs $event, ClassMetadataInfo $metadata, @@ -173,6 +176,7 @@ private function addManyToMany( } /** + * @param ClassMetadataInfo $metadata * @param mixed[] $mapping */ private function addField(ClassMetadataInfo $metadata, string $name, string $type = 'string', array $mapping = []): void @@ -186,7 +190,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, @@ -194,13 +198,16 @@ private function addField(ClassMetadataInfo $metadata, string $name, string $typ ], $mapping)); } + /** + * @param ClassMetadataInfo $metadata + */ 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); } } diff --git a/Content/Infrastructure/Doctrine/TagFactory.php b/Content/Infrastructure/Doctrine/TagFactory.php index 5e34869f..fc9bf27b 100644 --- a/Content/Infrastructure/Doctrine/TagFactory.php +++ b/Content/Infrastructure/Doctrine/TagFactory.php @@ -26,10 +26,13 @@ class TagFactory implements TagFactoryInterface private $entityManager; /** - * @var EntityRepository + * @var EntityRepository */ private $tagRepository; + /** + * @param EntityRepository $tagRepository + */ public function __construct(EntityManagerInterface $entityManager, EntityRepository $tagRepository) { $this->entityManager = $entityManager; @@ -52,7 +55,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]); } @@ -67,7 +70,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; diff --git a/Content/Infrastructure/Sulu/Admin/ContentViewBuilderFactory.php b/Content/Infrastructure/Sulu/Admin/ContentViewBuilderFactory.php index 9fa5cd7c..bc7159a2 100644 --- a/Content/Infrastructure/Sulu/Admin/ContentViewBuilderFactory.php +++ b/Content/Infrastructure/Sulu/Admin/ContentViewBuilderFactory.php @@ -69,21 +69,21 @@ public function getDefaultToolbarActions( $toolbarActions = []; - if (is_subclass_of($dimensionContentClass, WorkflowInterface::class)) { + if (\is_subclass_of($dimensionContentClass, WorkflowInterface::class)) { $toolbarActions['save'] = new ToolbarAction( - 'sulu_admin.save_with_publishing', - [ - 'publish_visible_condition' => '(!_permissions || _permissions.live)', - 'save_visible_condition' => '(!_permissions || _permissions.edit)', - ] - ); + 'sulu_admin.save_with_publishing', + [ + 'publish_visible_condition' => '(!_permissions || _permissions.live)', + 'save_visible_condition' => '(!_permissions || _permissions.edit)', + ] + ); } else { $toolbarActions['save'] = new ToolbarAction( - 'sulu_admin.save' - ); + 'sulu_admin.save' + ); } - if (is_subclass_of($dimensionContentClass, TemplateInterface::class)) { + if (\is_subclass_of($dimensionContentClass, TemplateInterface::class)) { $toolbarActions['type'] = new ToolbarAction( 'sulu_admin.type', [ @@ -93,31 +93,31 @@ public function getDefaultToolbarActions( } $toolbarActions['delete'] = new ToolbarAction( - 'sulu_admin.delete', + 'sulu_admin.delete', + [ + 'visible_condition' => '(!_permissions || _permissions.delete) && url != "/"', + ] + ); + + if (\is_subclass_of($dimensionContentClass, WorkflowInterface::class)) { + $toolbarActions['edit'] = new DropdownToolbarAction( + 'sulu_admin.edit', + 'su-pen', [ - 'visible_condition' => '(!_permissions || _permissions.delete) && url != "/"', + new ToolbarAction( + 'sulu_admin.delete_draft', + [ + 'visible_condition' => '(!_permissions || _permissions.live)', + ] + ), + new ToolbarAction( + 'sulu_admin.set_unpublished', + [ + 'visible_condition' => '(!_permissions || _permissions.live)', + ] + ), ] ); - - if (is_subclass_of($dimensionContentClass, WorkflowInterface::class)) { - $toolbarActions['edit'] = new DropdownToolbarAction( - 'sulu_admin.edit', - 'su-pen', - [ - new ToolbarAction( - 'sulu_admin.delete_draft', - [ - 'visible_condition' => '(!_permissions || _permissions.live)', - ] - ), - new ToolbarAction( - 'sulu_admin.set_unpublished', - [ - 'visible_condition' => '(!_permissions || _permissions.live)', - ] - ), - ] - ); } return $toolbarActions; @@ -162,7 +162,7 @@ public function createViews( if ($this->hasPermission($securityContext, PermissionTypes::ADD)) { if ($addParentView) { - if (is_subclass_of($dimensionContentClass, TemplateInterface::class)) { + if (\is_subclass_of($dimensionContentClass, TemplateInterface::class)) { /** @var FormViewBuilderInterface|PreviewFormViewBuilderInterface $templateFormView */ $templateFormView = $this->createTemplateFormView( $addParentView, @@ -180,7 +180,7 @@ public function createViews( } if ($this->hasPermission($securityContext, PermissionTypes::EDIT)) { - if (is_subclass_of($dimensionContentClass, TemplateInterface::class)) { + if (\is_subclass_of($dimensionContentClass, TemplateInterface::class)) { $views[] = $this->createTemplateFormView( $editParentView, $previewEnabled, @@ -190,7 +190,7 @@ public function createViews( ); } - if (is_subclass_of($dimensionContentClass, SeoInterface::class)) { + if (\is_subclass_of($dimensionContentClass, SeoInterface::class)) { $views[] = $this->createSeoFormView( $editParentView, $previewEnabled, @@ -199,7 +199,7 @@ public function createViews( ); } - if (is_subclass_of($dimensionContentClass, ExcerptInterface::class)) { + if (\is_subclass_of($dimensionContentClass, ExcerptInterface::class)) { $views[] = $this->createExcerptFormView( $editParentView, $previewEnabled, @@ -226,7 +226,7 @@ private function createTemplateFormView( ->setResourceKey($resourceKey) ->setFormKey($formKey) ->setTabTitle('sulu_content.content') - ->addToolbarActions(array_values($toolbarActions)) + ->addToolbarActions(\array_values($toolbarActions)) ->setTabOrder(20) ->setParent($parentView); } @@ -245,7 +245,7 @@ private function createSeoFormView( ->setFormKey('content_seo') ->setTabTitle('sulu_content.seo') ->setTitleVisible(true) - ->addToolbarActions(array_values($toolbarActions)) + ->addToolbarActions(\array_values($toolbarActions)) ->setTabOrder(30) ->setParent($parentView); } @@ -264,7 +264,7 @@ private function createExcerptFormView( ->setFormKey('content_excerpt') ->setTabTitle('sulu_content.excerpt') ->setTitleVisible(true) - ->addToolbarActions(array_values($toolbarActions)) + ->addToolbarActions(\array_values($toolbarActions)) ->setTabOrder(40) ->setParent($parentView); } diff --git a/Content/Infrastructure/Sulu/Automation/ContentPublishTaskHandler.php b/Content/Infrastructure/Sulu/Automation/ContentPublishTaskHandler.php index c66ce0c8..e2e6bf31 100644 --- a/Content/Infrastructure/Sulu/Automation/ContentPublishTaskHandler.php +++ b/Content/Infrastructure/Sulu/Automation/ContentPublishTaskHandler.php @@ -46,9 +46,6 @@ public function __construct(ContentManagerInterface $contentManager, EntityManag $this->translator = $translator; } - /** - * {@inheritdoc} - */ public function configureOptionsResolver(OptionsResolver $optionsResolver): OptionsResolver { return $optionsResolver->setRequired(['id', 'locale']) @@ -56,25 +53,16 @@ public function configureOptionsResolver(OptionsResolver $optionsResolver): Opti ->setAllowedTypes('locale', 'string'); } - /** - * {@inheritdoc} - */ public function supports(string $entityClass): bool { - return is_subclass_of($entityClass, ContentRichEntityInterface::class); + return \is_subclass_of($entityClass, ContentRichEntityInterface::class); } - /** - * {@inheritdoc} - */ public function getConfiguration(): TaskHandlerConfiguration { return TaskHandlerConfiguration::create($this->translator->trans('sulu_content.task_handler.publish', [], 'admin')); } - /** - * {@inheritdoc} - */ public function handle($workload) { if (!\is_array($workload)) { diff --git a/Content/Infrastructure/Sulu/Automation/ContentUnpublishTaskHandler.php b/Content/Infrastructure/Sulu/Automation/ContentUnpublishTaskHandler.php index b4885f4b..39dc24b0 100644 --- a/Content/Infrastructure/Sulu/Automation/ContentUnpublishTaskHandler.php +++ b/Content/Infrastructure/Sulu/Automation/ContentUnpublishTaskHandler.php @@ -46,9 +46,6 @@ public function __construct(ContentManagerInterface $contentManager, EntityManag $this->translator = $translator; } - /** - * {@inheritdoc} - */ public function configureOptionsResolver(OptionsResolver $optionsResolver): OptionsResolver { return $optionsResolver->setRequired(['id', 'locale']) @@ -56,25 +53,16 @@ public function configureOptionsResolver(OptionsResolver $optionsResolver): Opti ->setAllowedTypes('locale', 'string'); } - /** - * {@inheritdoc} - */ public function supports(string $entityClass): bool { - return is_subclass_of($entityClass, ContentRichEntityInterface::class); + return \is_subclass_of($entityClass, ContentRichEntityInterface::class); } - /** - * {@inheritdoc} - */ public function getConfiguration(): TaskHandlerConfiguration { return TaskHandlerConfiguration::create($this->translator->trans('sulu_content.task_handler.unpublish', [], 'admin')); } - /** - * {@inheritdoc} - */ public function handle($workload) { if (!\is_array($workload)) { diff --git a/Content/Infrastructure/Sulu/Preview/ContentObjectProvider.php b/Content/Infrastructure/Sulu/Preview/ContentObjectProvider.php index fa80481c..2a04fd1b 100644 --- a/Content/Infrastructure/Sulu/Preview/ContentObjectProvider.php +++ b/Content/Infrastructure/Sulu/Preview/ContentObjectProvider.php @@ -135,7 +135,7 @@ public function setContext($object, $locale, array $context): DimensionContentIn */ public function serialize($object) { - return json_encode([ + return \json_encode([ 'id' => $object->getResource()->getId(), 'locale' => $object->getLocale(), ]) ?: '[]'; @@ -149,7 +149,7 @@ public function serialize($object) */ public function deserialize($serializedObject, $objectClass) { - $data = json_decode($serializedObject, true); + $data = \json_decode($serializedObject, true); $id = $data['id'] ?? null; $locale = $data['locale'] ?? null; diff --git a/Content/Infrastructure/Sulu/Preview/PreviewDimensionContentCollection.php b/Content/Infrastructure/Sulu/Preview/PreviewDimensionContentCollection.php index 3bd84af6..8bd06eb8 100644 --- a/Content/Infrastructure/Sulu/Preview/PreviewDimensionContentCollection.php +++ b/Content/Infrastructure/Sulu/Preview/PreviewDimensionContentCollection.php @@ -19,6 +19,7 @@ /** * @internal + * * @implements \IteratorAggregate */ class PreviewDimensionContentCollection implements \IteratorAggregate, DimensionContentCollectionInterface @@ -53,7 +54,7 @@ public function getDimensionContent(array $dimensionAttributes): ?DimensionConte public function getDimensionAttributes(): array { - return array_merge( + return \array_merge( $this->previewDimensionContent::getDefaultDimensionAttributes(), ['locale' => $this->previewLocale] ); diff --git a/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProvider.php b/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProvider.php index 416c310a..528fc48e 100644 --- a/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProvider.php +++ b/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProvider.php @@ -77,7 +77,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, \get_class($entity))); } try { @@ -110,8 +110,8 @@ public function isPublished($entityClass, $id, $locale) public function supports($entityClass) { // need to support DimensionContentInterface::class because of the ContentObjectProvider::deserialize() method - return is_a($entityClass, ContentRichEntityInterface::class, true) - || is_a($entityClass, DimensionContentInterface::class, true); + return \is_a($entityClass, ContentRichEntityInterface::class, true) + || \is_a($entityClass, DimensionContentInterface::class, true); } protected function loadEntity(string $entityClass, string $id, string $locale): ?TemplateInterface @@ -143,7 +143,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, \get_class($resolvedDimensionContent))); } return $resolvedDimensionContent; @@ -166,7 +166,7 @@ private function getCacheLifetime(StructureMetadata $metadata): ?int || !$this->cacheLifetimeResolver->supports($cacheLifetime['type'], $cacheLifetime['value']) ) { // TODO FIXME add test case for this - throw new \InvalidArgumentException(sprintf('Invalid cachelifetime in route default provider: %s', var_export($cacheLifetime, true))); // @codeCoverageIgnore + throw new \InvalidArgumentException(\sprintf('Invalid cachelifetime in route default provider: %s', \var_export($cacheLifetime, true))); // @codeCoverageIgnore } return $this->cacheLifetimeResolver->resolve($cacheLifetime['type'], $cacheLifetime['value']); diff --git a/Content/Infrastructure/Sulu/Search/ContentReindexProvider.php b/Content/Infrastructure/Sulu/Search/ContentReindexProvider.php index a3c1d185..8d08abcf 100644 --- a/Content/Infrastructure/Sulu/Search/ContentReindexProvider.php +++ b/Content/Infrastructure/Sulu/Search/ContentReindexProvider.php @@ -120,17 +120,17 @@ public function getLocalesForObject($object) $locales = $object->getDimensionContents() ->filter( - function (DimensionContentInterface $dimensionContent) use ($stage) { + function(DimensionContentInterface $dimensionContent) use ($stage) { return $stage === $dimensionContent->getStage(); } ) ->map( - function (DimensionContentInterface $dimensionContent) { + function(DimensionContentInterface $dimensionContent) { return $dimensionContent->getLocale(); } )->getValues(); - return array_values(array_filter(array_unique($locales))); + return \array_values(\array_filter(\array_unique($locales))); } /** @@ -167,7 +167,7 @@ public function translateObject($object, $locale) private function getWorkflowStage(): string { - $interfaces = class_implements($this->getDimensionContentClass()); + $interfaces = \class_implements($this->getDimensionContentClass()); if ($interfaces && \in_array(WorkflowInterface::class, $interfaces, true) && SuluKernel::CONTEXT_WEBSITE === $this->context) { diff --git a/Content/Infrastructure/Sulu/Search/ContentSearchMetadataProvider.php b/Content/Infrastructure/Sulu/Search/ContentSearchMetadataProvider.php index 36cd1ed5..94d0448f 100644 --- a/Content/Infrastructure/Sulu/Search/ContentSearchMetadataProvider.php +++ b/Content/Infrastructure/Sulu/Search/ContentSearchMetadataProvider.php @@ -33,14 +33,14 @@ class ContentSearchMetadataProvider implements ProviderInterface { - const SEARCH_FIELD_TAG = 'sulu.search.field'; - const FIELD_TEMPLATE_KEY = '_template_key'; - const EXCERPT_FIELDS = [ + public const SEARCH_FIELD_TAG = 'sulu.search.field'; + public const FIELD_TEMPLATE_KEY = '_template_key'; + public const EXCERPT_FIELDS = [ 'excerptTitle', 'excerptMore', 'excerptDescription', ]; - const SEO_FIELDS = [ + public const SEO_FIELDS = [ 'seoTitle', 'seoDescription', 'seoKeywords', @@ -91,7 +91,7 @@ public function getMetadataForObject($object): ?ClassMetadata { $dimensionContentClass = $this->getDimensionContentClass(); - if (!is_a($object, $dimensionContentClass, true) + if (!\is_a($object, $dimensionContentClass, true) || !$object instanceof DimensionContentInterface || !$object instanceof TemplateInterface) { return null; @@ -119,7 +119,7 @@ public function getAllMetadata(): array /** @var class-string $dimensionContentClass */ $dimensionContentClass = $this->getDimensionContentClass(); - if (!is_a($dimensionContentClass, TemplateInterface::class, true)) { + if (!\is_a($dimensionContentClass, TemplateInterface::class, true)) { // TODO FIXME add test case for this return []; // @codeCoverageIgnore } @@ -137,7 +137,7 @@ public function getMetadataForDocument(Document $document): ?ClassMetadata /** @var class-string $dimensionContentClass */ $dimensionContentClass = $this->getDimensionContentClass(); - if (!is_a($dimensionContentClass, TemplateInterface::class, true)) { + if (!\is_a($dimensionContentClass, TemplateInterface::class, true)) { // TODO FIXME add test case for this return null; // @codeCoverageIgnore } @@ -173,11 +173,11 @@ private function getMetadata(string $className, StructureMetadata $structureMeta /** @var class-string $dimensionContentClass */ $dimensionContentClass = $this->getDimensionContentClass(); - if (!is_a($dimensionContentClass, DimensionContentInterface::class, true)) { + if (!\is_a($dimensionContentClass, DimensionContentInterface::class, true)) { // TODO FIXME add test case for this // @codeCoverageIgnoreStart throw new \RuntimeException( - sprintf('$dimensionContentClass needs to be of type "%s"', DimensionContentInterface::class) + \sprintf('$dimensionContentClass needs to be of type "%s"', DimensionContentInterface::class) ); // @codeCoverageIgnoreEnd } @@ -196,7 +196,7 @@ private function getMetadata(string $className, StructureMetadata $structureMeta ] ); - if (is_a($className, ExcerptInterface::class, true)) { + if (\is_a($className, ExcerptInterface::class, true)) { foreach (self::EXCERPT_FIELDS as $property) { $indexMeta->addFieldMapping( $property, @@ -210,7 +210,7 @@ private function getMetadata(string $className, StructureMetadata $structureMeta } } - if (is_a($className, SeoInterface::class, true)) { + if (\is_a($className, SeoInterface::class, true)) { foreach (self::SEO_FIELDS as $property) { $indexMeta->addFieldMapping( $property, @@ -282,7 +282,7 @@ private function createIndexNameField(string $indexName): Expression private function getContentField(PropertyMetadata $property): Expression { return $this->searchMetadataFactory->createMetadataExpression( - sprintf( + \sprintf( 'object.getTemplateData()["%s"]', $property->getName() ) @@ -341,15 +341,15 @@ private function mapProperty(PropertyMetadata $property, IndexMetadata $metadata // @codeCoverageIgnoreStart $metadata->setImageUrlField($this->getContentField($property)); break; - // @codeCoverageIgnoreEnd + // @codeCoverageIgnoreEnd default: // TODO FIXME add test case for this // @codeCoverageIgnoreStart throw new \InvalidArgumentException( - sprintf( + \sprintf( 'Unknown search field role "%s", role must be one of "%s"', $tagAttributes['role'], - implode(', ', ['title', 'description', 'image']) + \implode(', ', ['title', 'description', 'image']) ) ); // @codeCoverageIgnoreEnd diff --git a/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProvider.php b/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProvider.php index a21ccdda..39e243a6 100644 --- a/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProvider.php +++ b/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProvider.php @@ -32,9 +32,9 @@ class ContentSitemapProvider implements SitemapProviderInterface { - const ROUTE_ALIAS = 'route'; - const CONTENT_RICH_ENTITY_ALIAS = ContentWorkflowInterface::CONTENT_RICH_ENTITY_CONTEXT_KEY; - const LOCALIZED_DIMENSION_CONTENT_ALIAS = 'localizedDimensionContent'; + public const ROUTE_ALIAS = 'route'; + public const CONTENT_RICH_ENTITY_ALIAS = ContentWorkflowInterface::CONTENT_RICH_ENTITY_CONTEXT_KEY; + public const LOCALIZED_DIMENSION_CONTENT_ALIAS = 'localizedDimensionContent'; /** * @var EntityManagerInterface @@ -97,7 +97,7 @@ public function build($page, $scheme, $host): array ); /** @var PortalInformation|null $portalInformation */ - $portalInformation = array_shift($portalInformations); + $portalInformation = \array_shift($portalInformations); if (!$portalInformation) { // TODO FIXME add testcase for this @@ -119,7 +119,7 @@ public function build($page, $scheme, $host): array $mainRoute = $entityRoutes[$defaultLocale]; unset($entityRoutes[$defaultLocale]); } else { - $mainRoute = array_shift($entityRoutes); + $mainRoute = \array_shift($entityRoutes); } $sitemapUrl = $this->generateSitemapUrl( @@ -158,8 +158,8 @@ public function getMaxPage($scheme, $host): int ->getQuery() ->getSingleScalarResult(); - return (int) ceil($amount / self::PAGE_SIZE); - } catch (NoResultException | NonUniqueResultException $e) { // @codeCoverageIgnore + return (int) \ceil($amount / self::PAGE_SIZE); + } catch (NoResultException|NonUniqueResultException $e) { // @codeCoverageIgnore // TODO FIXME add testcase for this return 0; // @codeCoverageIgnore } diff --git a/Content/Infrastructure/Sulu/SmartContent/Provider/ContentDataProvider.php b/Content/Infrastructure/Sulu/SmartContent/Provider/ContentDataProvider.php index 79326a8b..d4f8cc10 100644 --- a/Content/Infrastructure/Sulu/SmartContent/Provider/ContentDataProvider.php +++ b/Content/Infrastructure/Sulu/SmartContent/Provider/ContentDataProvider.php @@ -77,8 +77,8 @@ protected function configure(BuilderInterface $builder): void */ protected function decorateDataItems(array $data): array { - return array_map( - function (DimensionContentInterface $dimensionContent) { + return \array_map( + function(DimensionContentInterface $dimensionContent) { $normalizedContentData = $this->normalizeContent($dimensionContent); return $this->createDataItem($dimensionContent, $normalizedContentData); @@ -97,8 +97,8 @@ function (DimensionContentInterface $dimensionContent) { */ protected function decorateResourceItems(array $data, $locale): array { - return array_map( - function (DimensionContentInterface $dimensionContent) { + return \array_map( + function(DimensionContentInterface $dimensionContent) { $normalizedContentData = $this->normalizeContent($dimensionContent); $id = $this->getIdForItem($dimensionContent); diff --git a/Content/Infrastructure/Sulu/SmartContent/Repository/ContentDataProviderRepository.php b/Content/Infrastructure/Sulu/SmartContent/Repository/ContentDataProviderRepository.php index 0158c70f..b24bc8be 100644 --- a/Content/Infrastructure/Sulu/SmartContent/Repository/ContentDataProviderRepository.php +++ b/Content/Infrastructure/Sulu/SmartContent/Repository/ContentDataProviderRepository.php @@ -23,9 +23,9 @@ class ContentDataProviderRepository implements DataProviderRepositoryInterface { - const CONTENT_RICH_ENTITY_ALIAS = 'entity'; - const LOCALIZED_DIMENSION_CONTENT_ALIAS = 'localizedContent'; - const UNLOCALIZED_DIMENSION_CONTENT_ALIAS = 'unlocalizedContent'; + public const CONTENT_RICH_ENTITY_ALIAS = 'entity'; + public const LOCALIZED_DIMENSION_CONTENT_ALIAS = 'localizedContent'; + public const UNLOCALIZED_DIMENSION_CONTENT_ALIAS = 'unlocalizedContent'; /** * @var ContentManagerInterface @@ -48,7 +48,7 @@ class ContentDataProviderRepository implements DataProviderRepositoryInterface protected $contentRichEntityClass; /** - * @var ClassMetadata + * @var ClassMetadata */ protected $contentRichEntityClassMetadata; @@ -67,7 +67,9 @@ public function __construct( $this->showDrafts = $showDrafts; $this->contentRichEntityClass = $contentRichEntityClass; - $this->contentRichEntityClassMetadata = $this->entityManager->getClassMetadata($this->contentRichEntityClass); + /** @var ClassMetadata $contentRichEntityClassMetadata */ + $contentRichEntityClassMetadata = $this->entityManager->getClassMetadata($this->contentRichEntityClass); + $this->contentRichEntityClassMetadata = $contentRichEntityClassMetadata; } /** @@ -92,9 +94,9 @@ public function findByFilters($filters, $page, $pageSize, $limit, $locale, $opti $showUnpublished = $this->showDrafts; - return array_filter( - array_map( - function (ContentRichEntityInterface $contentRichEntity) use ($locale, $showUnpublished) { + return \array_filter( + \array_map( + function(ContentRichEntityInterface $contentRichEntity) use ($locale, $showUnpublished) { $stage = $showUnpublished ? DimensionContentInterface::STAGE_DRAFT : DimensionContentInterface::STAGE_LIVE; @@ -139,7 +141,7 @@ protected function findEntityIdsByFilters( if (!empty($categories = $filters['categories'] ?? [])) { $categoryOperator = (string) ($filters['categoryOperator'] ?? 'OR'); - $parameters = array_merge( + $parameters = \array_merge( $parameters, $this->addCategoryFilter($queryBuilder, $categories, $categoryOperator, 'adminCategories') ); @@ -148,7 +150,7 @@ protected function findEntityIdsByFilters( if (!empty($websiteCategories = $filters['websiteCategories'] ?? [])) { $websiteCategoryOperator = (string) ($filters['websiteCategoriesOperator'] ?? 'OR'); - $parameters = array_merge( + $parameters = \array_merge( $parameters, $this->addCategoryFilter($queryBuilder, $websiteCategories, $websiteCategoryOperator, 'websiteCategories') ); @@ -157,7 +159,7 @@ protected function findEntityIdsByFilters( if (!empty($tags = $filters['tags'] ?? [])) { $tagOperator = (string) ($filters['tagOperator'] ?? 'OR'); - $parameters = array_merge( + $parameters = \array_merge( $parameters, $this->addTagFilter($queryBuilder, $tags, $tagOperator, 'adminTags') ); @@ -166,14 +168,14 @@ protected function findEntityIdsByFilters( if (!empty($websiteTags = $filters['websiteTags'] ?? [])) { $websiteTagOperator = (string) ($filters['websiteTagsOperator'] ?? 'OR'); - $parameters = array_merge( + $parameters = \array_merge( $parameters, $this->addTagFilter($queryBuilder, $websiteTags, $websiteTagOperator, 'websiteTags') ); } if (!empty($types = $filters['types'] ?? [])) { - $parameters = array_merge( + $parameters = \array_merge( $parameters, $this->addTypeFilter($queryBuilder, $types, 'adminTypes') ); @@ -182,7 +184,7 @@ protected function findEntityIdsByFilters( if ($targetGroupId = $filters['targetGroupId'] ?? null) { // TODO FIXME add testcase for this // @codeCoverageIgnoreStart - $parameters = array_merge( + $parameters = \array_merge( $parameters, $this->addTargetGroupFilter($queryBuilder, $targetGroupId, 'targetGroupId') ); @@ -194,7 +196,7 @@ protected function findEntityIdsByFilters( // @codeCoverageIgnoreStart $includeSubFolders = (bool) ($filters['includeSubFolders'] ?? false); - $parameters = array_merge( + $parameters = \array_merge( $parameters, $this->addDatasourceFilter($queryBuilder, (string) $dataSource, $includeSubFolders, 'datasource') ); @@ -204,7 +206,7 @@ protected function findEntityIdsByFilters( if ($sortColumn = $filters['sortBy'] ?? null) { $sortMethod = (string) ($filters['sortMethod'] ?? 'asc'); - $parameters = array_merge( + $parameters = \array_merge( $parameters, $this->setSortBy($queryBuilder, (string) $sortColumn, $sortMethod) ); @@ -233,8 +235,8 @@ protected function findEntityIdsByFilters( $queryBuilder->setMaxResults($limit); } - return array_unique( - array_column($queryBuilder->getQuery()->getScalarResult(), 'id') + return \array_unique( + \array_column($queryBuilder->getQuery()->getScalarResult(), 'id') ); } @@ -278,7 +280,7 @@ protected function addCategoryFilter(QueryBuilder $queryBuilder, array $categori $queryBuilder, $this->getCategoryRelationFieldName($queryBuilder), $categories, - mb_strtolower($categoryOperator), + \mb_strtolower($categoryOperator), $alias ); } @@ -296,7 +298,7 @@ protected function addTagFilter(QueryBuilder $queryBuilder, array $tags, string $queryBuilder, $this->getTagRelationFieldName($queryBuilder), $tags, - mb_strtolower($tagOperator), + \mb_strtolower($tagOperator), $alias ); } @@ -310,7 +312,7 @@ protected function addTagFilter(QueryBuilder $queryBuilder, array $tags, string */ protected function addTypeFilter(QueryBuilder $queryBuilder, array $types, string $alias): array { - $queryBuilder->andWhere(static::LOCALIZED_DIMENSION_CONTENT_ALIAS . ".templateKey IN ('" . implode("','", $types) . "')"); + $queryBuilder->andWhere(static::LOCALIZED_DIMENSION_CONTENT_ALIAS . ".templateKey IN ('" . \implode("','", $types) . "')"); return []; } @@ -363,9 +365,9 @@ protected function setSortBy( $alias = self::LOCALIZED_DIMENSION_CONTENT_ALIAS; - if (false !== mb_strpos($sortColumn, '.')) { + if (false !== \mb_strpos($sortColumn, '.')) { // TODO FIXME add testcase for this - list($alias, $sortColumn) = explode('.', $sortColumn, 2); // @codeCoverageIgnore + list($alias, $sortColumn) = \explode('.', $sortColumn, 2); // @codeCoverageIgnore } if (!\in_array($alias, $queryBuilder->getAllAliases(), true)) { @@ -489,11 +491,11 @@ protected function findEntitiesByIds(array $ids): array ->setParameter('ids', $ids) ->getResult(); - $idPositions = array_flip($ids); + $idPositions = \array_flip($ids); - usort( + \usort( $entities, - function (ContentRichEntityInterface $a, ContentRichEntityInterface $b) use ($idPositions, $entityIdentifierFieldName) { + function(ContentRichEntityInterface $a, ContentRichEntityInterface $b) use ($idPositions, $entityIdentifierFieldName) { $aId = $this->contentRichEntityClassMetadata->getIdentifierValues($a)[$entityIdentifierFieldName]; $bId = $this->contentRichEntityClassMetadata->getIdentifierValues($b)[$entityIdentifierFieldName]; diff --git a/Content/Infrastructure/Sulu/Structure/ContentDocument.php b/Content/Infrastructure/Sulu/Structure/ContentDocument.php index 39ba4713..d5fa0954 100644 --- a/Content/Infrastructure/Sulu/Structure/ContentDocument.php +++ b/Content/Infrastructure/Sulu/Structure/ContentDocument.php @@ -145,7 +145,7 @@ public function getStructure() protected function createReadOnlyException(string $method): \BadMethodCallException { return new \BadMethodCallException( - sprintf( + \sprintf( 'Compatibility layer ContentDocument instances are readonly. Tried to call "%s"', $method ) diff --git a/Content/Infrastructure/Sulu/Structure/ContentStructureBridge.php b/Content/Infrastructure/Sulu/Structure/ContentStructureBridge.php index 050f4454..4470f124 100644 --- a/Content/Infrastructure/Sulu/Structure/ContentStructureBridge.php +++ b/Content/Infrastructure/Sulu/Structure/ContentStructureBridge.php @@ -260,7 +260,7 @@ public function getPropertyValue($name) */ public function getPropertyNames() { - return array_keys($this->structure->getChildren()); + return \array_keys($this->structure->getChildren()); } public function setType($type): void @@ -429,7 +429,7 @@ public function __get($name) protected function createReadOnlyException(string $method): \BadMethodCallException { return new \BadMethodCallException( - sprintf( + \sprintf( 'Compatibility layer StructureBridge instances are readonly. Tried to call "%s"', $method ) diff --git a/Content/Infrastructure/Sulu/Structure/StructureMetadataNotFoundException.php b/Content/Infrastructure/Sulu/Structure/StructureMetadataNotFoundException.php index 4a7210c6..816aabde 100644 --- a/Content/Infrastructure/Sulu/Structure/StructureMetadataNotFoundException.php +++ b/Content/Infrastructure/Sulu/Structure/StructureMetadataNotFoundException.php @@ -17,7 +17,7 @@ class StructureMetadataNotFoundException extends \Exception { public function __construct(string $templateType, ?string $templateKey) { - parent::__construct(sprintf( + parent::__construct(\sprintf( 'No structure metadata found for template type "%s" and template key "%s"', $templateType, $templateKey diff --git a/Content/Infrastructure/Sulu/Teaser/ContentTeaserProvider.php b/Content/Infrastructure/Sulu/Teaser/ContentTeaserProvider.php index 547105fd..f6f1afd4 100644 --- a/Content/Infrastructure/Sulu/Teaser/ContentTeaserProvider.php +++ b/Content/Infrastructure/Sulu/Teaser/ContentTeaserProvider.php @@ -28,7 +28,7 @@ abstract class ContentTeaserProvider implements TeaserProviderInterface { - const CONTENT_RICH_ENTITY_ALIAS = ContentWorkflowInterface::CONTENT_RICH_ENTITY_CONTEXT_KEY; + public const CONTENT_RICH_ENTITY_ALIAS = ContentWorkflowInterface::CONTENT_RICH_ENTITY_CONTEXT_KEY; /** * @var ContentManagerInterface @@ -94,10 +94,10 @@ public function find(array $ids, $locale): array $contentRichEntities = $this->findEntitiesByIds($ids); - return array_values( - array_filter( - array_map( - function (ContentRichEntityInterface $contentRichEntity) use ($locale): ?Teaser { + return \array_values( + \array_filter( + \array_map( + function(ContentRichEntityInterface $contentRichEntity) use ($locale): ?Teaser { $resolvedDimensionContent = $this->resolveContent($contentRichEntity, $locale); if (!$resolvedDimensionContent) { @@ -287,11 +287,11 @@ protected function findEntitiesByIds(array $ids): array ->setParameter('ids', $ids) ->getResult(); - $idPositions = array_flip($ids); + $idPositions = \array_flip($ids); - usort( + \usort( $entities, - function (ContentRichEntityInterface $a, ContentRichEntityInterface $b) use ($idPositions, $classMetadata, $entityIdField) { + function(ContentRichEntityInterface $a, ContentRichEntityInterface $b) use ($idPositions, $classMetadata, $entityIdField) { $aId = $classMetadata->getIdentifierValues($a)[$entityIdField]; $bId = $classMetadata->getIdentifierValues($b)[$entityIdField]; diff --git a/DependencyInjection/SuluContentExtension.php b/DependencyInjection/SuluContentExtension.php index cb453174..7c1d1589 100644 --- a/DependencyInjection/SuluContentExtension.php +++ b/DependencyInjection/SuluContentExtension.php @@ -51,7 +51,7 @@ public function load(array $configs, ContainerBuilder $container): void $loader->load('normalizer.xml'); $loader->load('services.xml'); - if ($container->hasParameter('kernel.bundles')) { + if ($container->hasParameter('kernel.bundles')) { // @phpstan-ignore-line // TODO FIXME add test here // @codeCoverageIgnoreStart /** @var string[] $bundles */ diff --git a/Tests/Application/ExampleTestBundle/Admin/ExampleAdmin.php b/Tests/Application/ExampleTestBundle/Admin/ExampleAdmin.php index f2c337ad..89303e1c 100644 --- a/Tests/Application/ExampleTestBundle/Admin/ExampleAdmin.php +++ b/Tests/Application/ExampleTestBundle/Admin/ExampleAdmin.php @@ -27,13 +27,13 @@ class ExampleAdmin extends Admin { - const SECURITY_CONTEXT = 'sulu.example.examples'; + public const SECURITY_CONTEXT = 'sulu.example.examples'; - const LIST_VIEW = 'example_test.example.list'; + public const LIST_VIEW = 'example_test.example.list'; - const ADD_TABS_VIEW = 'example_test.example.add_tabs'; + public const ADD_TABS_VIEW = 'example_test.example.add_tabs'; - const EDIT_TABS_VIEW = 'example_test.example.edit_tabs'; + public const EDIT_TABS_VIEW = 'example_test.example.edit_tabs'; /** * @var ViewBuilderFactoryInterface diff --git a/Tests/Application/ExampleTestBundle/Controller/ExampleController.php b/Tests/Application/ExampleTestBundle/Controller/ExampleController.php index 67ac6cdf..06b8c65d 100644 --- a/Tests/Application/ExampleTestBundle/Controller/ExampleController.php +++ b/Tests/Application/ExampleTestBundle/Controller/ExampleController.php @@ -154,7 +154,7 @@ public function postAction(Request $request): Response $this->entityManager->flush(); // Index live dimension content - $this->contentIndexer->index($example, array_merge($dimensionAttributes, [ + $this->contentIndexer->index($example, \array_merge($dimensionAttributes, [ 'stage' => DimensionContentInterface::STAGE_LIVE, ])); } @@ -193,7 +193,7 @@ public function postTriggerAction(string $id, Request $request): Response $this->entityManager->flush(); // Deindex live dimension content - $this->contentIndexer->deindex(Example::RESOURCE_KEY, $id, array_merge( + $this->contentIndexer->deindex(Example::RESOURCE_KEY, $id, \array_merge( $dimensionAttributes, ['stage' => DimensionContentInterface::STAGE_LIVE] )); @@ -254,7 +254,7 @@ public function putAction(Request $request, int $id): Response $this->entityManager->flush(); // Index live dimension content - $this->contentIndexer->index($example, array_merge($dimensionAttributes, [ + $this->contentIndexer->index($example, \array_merge($dimensionAttributes, [ 'stage' => DimensionContentInterface::STAGE_LIVE, ])); } diff --git a/Tests/Application/ExampleTestBundle/Entity/Example.php b/Tests/Application/ExampleTestBundle/Entity/Example.php index 33c0a035..e2d6df30 100644 --- a/Tests/Application/ExampleTestBundle/Entity/Example.php +++ b/Tests/Application/ExampleTestBundle/Entity/Example.php @@ -21,8 +21,8 @@ class Example implements ContentRichEntityInterface { use ContentRichEntityTrait; - const RESOURCE_KEY = 'examples'; - const TEMPLATE_TYPE = 'example'; + public const RESOURCE_KEY = 'examples'; + public const TEMPLATE_TYPE = 'example'; /** * @var mixed diff --git a/Tests/Application/ExampleTestBundle/Teaser/ExampleTeaserProvider.php b/Tests/Application/ExampleTestBundle/Teaser/ExampleTeaserProvider.php index a8b4d727..a18739ec 100644 --- a/Tests/Application/ExampleTestBundle/Teaser/ExampleTeaserProvider.php +++ b/Tests/Application/ExampleTestBundle/Teaser/ExampleTeaserProvider.php @@ -56,7 +56,7 @@ public function getConfiguration(): TeaserConfiguration protected function getDescription(DimensionContentInterface $dimensionContent, array $data): ?string { - $article = strip_tags($data['article'] ?? ''); + $article = \strip_tags($data['article'] ?? ''); return $article ?: parent::getDescription($dimensionContent, $data); } diff --git a/Tests/Application/bin/console.php b/Tests/Application/bin/console.php index 4c10d9bb..7c276a99 100755 --- a/Tests/Application/bin/console.php +++ b/Tests/Application/bin/console.php @@ -16,31 +16,31 @@ use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Debug\Debug; -if (false === in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) { +if (false === \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) { echo 'Warning: The console should be invoked via the CLI version of PHP, not the ' . \PHP_SAPI . ' SAPI' . \PHP_EOL; } require __DIR__ . '/../../../vendor/autoload.php'; -if (!class_exists(Application::class)) { +if (!\class_exists(Application::class)) { throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.'); } $input = new ArgvInput(); if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) { - putenv('APP_ENV=' . $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); + \putenv('APP_ENV=' . $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); } if ($input->hasParameterOption('--no-debug', true)) { - putenv('APP_DEBUG=' . $_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); + \putenv('APP_DEBUG=' . $_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); } -require dirname(__DIR__) . '/config/bootstrap.php'; +require \dirname(__DIR__) . '/config/bootstrap.php'; if ($_SERVER['APP_DEBUG']) { - umask(0000); + \umask(0000); - if (class_exists(Debug::class)) { + if (\class_exists(Debug::class)) { Debug::enable(); } } diff --git a/Tests/Application/config/bootstrap.php b/Tests/Application/config/bootstrap.php index 29f7707a..7314acf9 100644 --- a/Tests/Application/config/bootstrap.php +++ b/Tests/Application/config/bootstrap.php @@ -15,7 +15,7 @@ $file = __DIR__ . '/../../../vendor/autoload.php'; -if (!file_exists($file)) { +if (!\file_exists($file)) { throw new RuntimeException('Install dependencies to run test suite.'); } @@ -23,17 +23,17 @@ // Load cached env vars if the .env.local.php file exists // Run "composer dump-env prod" to create it (requires symfony/flex >=1.2) -if (is_array($env = @include dirname(__DIR__) . '/.env.local.php')) { +if (\is_array($env = @include \dirname(__DIR__) . '/.env.local.php')) { $_SERVER += $env; $_ENV += $env; -} elseif (!class_exists(Dotenv::class)) { +} elseif (!\class_exists(Dotenv::class)) { throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); } else { - $path = dirname(__DIR__) . '/.env'; + $path = \dirname(__DIR__) . '/.env'; $dotenv = new Dotenv(); $dotenv->loadEnv($path); } $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; $_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; -$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], \FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; +$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || \filter_var($_SERVER['APP_DEBUG'], \FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; diff --git a/Tests/Application/public/index.php b/Tests/Application/public/index.php index ae38b280..c8b377b7 100644 --- a/Tests/Application/public/index.php +++ b/Tests/Application/public/index.php @@ -13,23 +13,23 @@ use Sulu\Bundle\ContentBundle\Tests\Application\Kernel; use Sulu\Component\HttpKernel\SuluKernel; -use Symfony\Component\Debug\Debug; +use Symfony\Component\ErrorHandler\Debug; use Symfony\Component\HttpFoundation\Request; // Webserver should run under dev for development $_SERVER['APP_ENV'] = 'dev'; $_ENV['APP_ENV'] = 'dev'; -require dirname(__DIR__) . '/config/bootstrap.php'; +require \dirname(__DIR__) . '/config/bootstrap.php'; if ($_SERVER['APP_DEBUG']) { - umask(0000); + \umask(0000); Debug::enable(); } $suluContext = SuluKernel::CONTEXT_WEBSITE; -if (preg_match('/^\/admin(\/|$)/', $_SERVER['REQUEST_URI'])) { +if (\preg_match('/^\/admin(\/|$)/', $_SERVER['REQUEST_URI'])) { $suluContext = SuluKernel::CONTEXT_ADMIN; } diff --git a/Tests/Functional/Content/Infrastructure/Doctrine/CategoryFactoryTest.php b/Tests/Functional/Content/Infrastructure/Doctrine/CategoryFactoryTest.php index 05db026e..c5fca215 100644 --- a/Tests/Functional/Content/Infrastructure/Doctrine/CategoryFactoryTest.php +++ b/Tests/Functional/Content/Infrastructure/Doctrine/CategoryFactoryTest.php @@ -41,8 +41,8 @@ public function testCreate(array $categoryIds): void $this->assertSame( $categoryIds, - array_map( - function (CategoryInterface $category) { + \array_map( + function(CategoryInterface $category) { return $category->getId(); }, $categoryFactory->create($categoryIds) diff --git a/Tests/Functional/Content/Infrastructure/Doctrine/DimensionContentRepositoryTest.php b/Tests/Functional/Content/Infrastructure/Doctrine/DimensionContentRepositoryTest.php index b45d2703..bce579c4 100644 --- a/Tests/Functional/Content/Infrastructure/Doctrine/DimensionContentRepositoryTest.php +++ b/Tests/Functional/Content/Infrastructure/Doctrine/DimensionContentRepositoryTest.php @@ -53,9 +53,9 @@ public function testLoadExistAll(): void $this->assertSame([ $dimensionContent1->getId(), $dimensionContent2->getId(), - ], array_map(function (ExampleDimensionContent $dimensionContent) { + ], \array_map(function(ExampleDimensionContent $dimensionContent) { return $dimensionContent->getId(); - }, iterator_to_array($dimensionContentCollection))); + }, \iterator_to_array($dimensionContentCollection))); } public function testLoadOneNotExist(): void @@ -76,9 +76,9 @@ public function testLoadOneNotExist(): void $this->assertSame([ $dimensionContent1->getId(), - ], array_map(function (ExampleDimensionContent $dimensionContent) { + ], \array_map(function(ExampleDimensionContent $dimensionContent) { return $dimensionContent->getId(); - }, iterator_to_array($dimensionContentCollection))); + }, \iterator_to_array($dimensionContentCollection))); } public function testLoadExistOrderedDifferent(): void @@ -102,9 +102,9 @@ public function testLoadExistOrderedDifferent(): void $this->assertSame([ $dimensionContent1->getId(), $dimensionContent2->getId(), // Dimension 2 should be the last one in this case - ], array_map(function (ExampleDimensionContent $dimensionContent) { + ], \array_map(function(ExampleDimensionContent $dimensionContent) { return $dimensionContent->getId(); - }, iterator_to_array($dimensionContentCollection))); + }, \iterator_to_array($dimensionContentCollection))); } private function createContentRichEntity(): Example diff --git a/Tests/Functional/Content/Infrastructure/Doctrine/TagFactoryTest.php b/Tests/Functional/Content/Infrastructure/Doctrine/TagFactoryTest.php index e3764601..0dace135 100644 --- a/Tests/Functional/Content/Infrastructure/Doctrine/TagFactoryTest.php +++ b/Tests/Functional/Content/Infrastructure/Doctrine/TagFactoryTest.php @@ -48,8 +48,8 @@ public function testCreate(array $tagNames, array $existTags): void $this->assertSame( $tagNames, - array_map( - function (TagInterface $tag) { + \array_map( + function(TagInterface $tag) { return $tag->getName(); }, $tags diff --git a/Tests/Functional/Content/Infrastructure/Sulu/Search/ContentSearchMetadataProviderTest.php b/Tests/Functional/Content/Infrastructure/Sulu/Search/ContentSearchMetadataProviderTest.php index 8267e297..e9404fb3 100644 --- a/Tests/Functional/Content/Infrastructure/Sulu/Search/ContentSearchMetadataProviderTest.php +++ b/Tests/Functional/Content/Infrastructure/Sulu/Search/ContentSearchMetadataProviderTest.php @@ -119,7 +119,7 @@ public function testGetMetadataForDocument(): void $metadata = $this->searchMetadataProvider->getMetadataForObject($dimensionContent); $this->assertNotNull($metadata); $allIndexMetadata = $metadata->getIndexMetadatas(); - $indexMetadata = $allIndexMetadata[array_key_first($allIndexMetadata)]; + $indexMetadata = $allIndexMetadata[\array_key_first($allIndexMetadata)]; $document = $this->objectToDocumentConverter->objectToDocument($indexMetadata, $dimensionContent); $documentMetadata = $this->searchMetadataProvider->getMetadataForDocument($document); diff --git a/Tests/Functional/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProviderTest.php b/Tests/Functional/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProviderTest.php index c5dc9dd5..417c13ff 100644 --- a/Tests/Functional/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProviderTest.php +++ b/Tests/Functional/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProviderTest.php @@ -26,8 +26,8 @@ class ContentSitemapProviderTest extends SuluTestCase use AssertSnapshotTrait; use CreateExampleTrait; - const SCHEME = 'https'; - const HOST = 'localhost'; + public const SCHEME = 'https'; + public const HOST = 'localhost'; /** * @var ContentSitemapProvider @@ -164,20 +164,20 @@ public function testGetAlias(): void */ private function mapSitemapEntries(array $sitemapEntries): array { - usort( + \usort( $sitemapEntries, - function (SitemapUrl $a, SitemapUrl $b) { - return strcmp($a->getLoc(), $b->getLoc()); + function(SitemapUrl $a, SitemapUrl $b) { + return \strcmp($a->getLoc(), $b->getLoc()); } ); - return array_map( - function (SitemapUrl $sitemapUrl) { + return \array_map( + function(SitemapUrl $sitemapUrl) { return [ 'locale' => $sitemapUrl->getLocale(), 'defaultLocale' => $sitemapUrl->getDefaultLocale(), 'loc' => $sitemapUrl->getLoc(), - 'alternateLinks' => array_map(function (SitemapAlternateLink $alternateLink) { + 'alternateLinks' => \array_map(function(SitemapAlternateLink $alternateLink) { return [ 'locale' => $alternateLink->getLocale(), 'href' => $alternateLink->getHref(), diff --git a/Tests/Functional/Content/Infrastructure/Sulu/SmartContent/ContentDataProviderTest.php b/Tests/Functional/Content/Infrastructure/Sulu/SmartContent/ContentDataProviderTest.php index 99110361..70baf04f 100644 --- a/Tests/Functional/Content/Infrastructure/Sulu/SmartContent/ContentDataProviderTest.php +++ b/Tests/Functional/Content/Infrastructure/Sulu/SmartContent/ContentDataProviderTest.php @@ -611,7 +611,7 @@ public function filters(): array */ private function mapDataProviderResult(DataProviderResult $dataProviderResult): array { - return array_map(function (ArrayAccessItem $item) { + return \array_map(function(ArrayAccessItem $item) { return [ 'id' => $item->getId(), 'excerptCategories' => $item['excerptCategories'], diff --git a/Tests/Functional/Content/Infrastructure/Sulu/Teaser/ContentTeaserProviderTest.php b/Tests/Functional/Content/Infrastructure/Sulu/Teaser/ContentTeaserProviderTest.php index 4e1ccc00..cd068be1 100644 --- a/Tests/Functional/Content/Infrastructure/Sulu/Teaser/ContentTeaserProviderTest.php +++ b/Tests/Functional/Content/Infrastructure/Sulu/Teaser/ContentTeaserProviderTest.php @@ -173,7 +173,7 @@ public function testFindENNoRoute(): void */ private function mapTeasers(array $teasers): array { - return array_map(function (Teaser $teaser) { + return \array_map(function(Teaser $teaser) { return [ 'id' => $teaser->getId(), 'type' => $teaser->getType(), diff --git a/Tests/Functional/Integration/ExampleControllerTest.php b/Tests/Functional/Integration/ExampleControllerTest.php index 9f997dc0..48f83201 100644 --- a/Tests/Functional/Integration/ExampleControllerTest.php +++ b/Tests/Functional/Integration/ExampleControllerTest.php @@ -44,7 +44,7 @@ public function testPostPublish(): int self::purgeDatabase(); self::initPhpcr(); - $this->client->request('POST', '/admin/api/examples?locale=en&action=publish', [], [], [], json_encode([ + $this->client->request('POST', '/admin/api/examples?locale=en&action=publish', [], [], [], \json_encode([ 'template' => 'example-2', 'title' => 'Test Example', 'url' => '/my-example', @@ -67,7 +67,7 @@ public function testPostPublish(): int ]) ?: null); $response = $this->client->getResponse(); - $content = json_decode((string) $response->getContent(), true); + $content = \json_decode((string) $response->getContent(), true); $id = $content['id'] ?? null; $this->assertResponseSnapshot('example_post_publish.json', $response, 201); @@ -111,7 +111,7 @@ public function testPost(): int { self::purgeDatabase(); - $this->client->request('POST', '/admin/api/examples?locale=en', [], [], [], json_encode([ + $this->client->request('POST', '/admin/api/examples?locale=en', [], [], [], \json_encode([ 'template' => 'example-2', 'title' => 'Test Example', 'url' => '/my-example', @@ -136,7 +136,7 @@ public function testPost(): int $this->assertResponseSnapshot('example_post.json', $response, 201); - $id = json_decode((string) $response->getContent(), true)['id'] ?? null; + $id = \json_decode((string) $response->getContent(), true)['id'] ?? null; return $id; } @@ -165,7 +165,7 @@ public function testGet(int $id): void */ public function testPut(int $id): void { - $this->client->request('PUT', '/admin/api/examples/' . $id . '?locale=en', [], [], [], json_encode([ + $this->client->request('PUT', '/admin/api/examples/' . $id . '?locale=en', [], [], [], \json_encode([ 'template' => 'default', 'title' => 'Test Example 2', 'url' => '/my-example-2', diff --git a/Tests/Traits/AssertSnapshotTrait.php b/Tests/Traits/AssertSnapshotTrait.php index f56824ff..2755d265 100644 --- a/Tests/Traits/AssertSnapshotTrait.php +++ b/Tests/Traits/AssertSnapshotTrait.php @@ -45,7 +45,7 @@ protected function assertArraySnapshot( array $array, string $message = '' ): void { - $arrayContent = json_encode($array); + $arrayContent = \json_encode($array); $this->assertIsString($arrayContent); $this->assertSnapshot($snapshotPatternFilename, $arrayContent, $message); @@ -57,10 +57,10 @@ protected function assertSnapshot( string $message = '' ): void { $snapshotFolder = $this->getCalledClassFolder() . \DIRECTORY_SEPARATOR . $this->getSnapshotFolder(); - $snapshotPattern = file_get_contents($snapshotFolder . \DIRECTORY_SEPARATOR . $snapshotPatternFilename); + $snapshotPattern = \file_get_contents($snapshotFolder . \DIRECTORY_SEPARATOR . $snapshotPatternFilename); $this->assertIsString($snapshotPattern); - $this->assertMatchesPattern(trim($snapshotPattern), trim($content), $message); + $this->assertMatchesPattern(\trim($snapshotPattern), \trim($content), $message); } private function getCalledClassFolder(): string diff --git a/Tests/Traits/CreateExampleTrait.php b/Tests/Traits/CreateExampleTrait.php index ada1eb38..759d1152 100644 --- a/Tests/Traits/CreateExampleTrait.php +++ b/Tests/Traits/CreateExampleTrait.php @@ -54,7 +54,7 @@ protected static function createExample(array $dataSet = [], array $options = [] $slugger = new AsciiSlugger(); - $fillWithdefaultData = function (array $data) use ($slugger): array { + $fillWithdefaultData = function(array $data) use ($slugger): array { // the example default template has the following required fields $data['title'] = $data['title'] ?? 'Test Example'; $data['url'] = $data['url'] ?? '/' . $slugger->slug($data['title'])->toString(); @@ -133,7 +133,7 @@ protected static function createExample(array $dataSet = [], array $options = [] ['stage' => DimensionContentInterface::STAGE_LIVE, 'locale' => $locale], ExampleDimensionContent::class ); - $liveData['published'] = date('Y-m-d H:i:s'); + $liveData['published'] = \date('Y-m-d H:i:s'); $contentDataMapper->map($fillWithdefaultData($liveData), $liveDimensionContentCollection); if ($options['create_route'] ?? false) { diff --git a/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/RoutableDataMapperTest.php b/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/RoutableDataMapperTest.php index 254137e1..dfb4eabd 100644 --- a/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/RoutableDataMapperTest.php +++ b/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/RoutableDataMapperTest.php @@ -419,7 +419,7 @@ public function testMapNoRoutePropertyDataAndNoOldRoute(): void $factory->getStructureMetadata('mock-template-type', 'default')->willReturn($metadata->reveal())->shouldBeCalled(); $routeGenerator->generate( - array_merge($data, [ + \array_merge($data, [ '_unlocalizedObject' => $unlocalizedDimensionContent->reveal(), '_localizedObject' => $localizedDimensionContentMock, ]), @@ -487,7 +487,7 @@ public function testMapNoRoutePropertyDataAndNoOldRouteIgnoreSlash(): void $factory->getStructureMetadata('mock-template-type', 'default')->willReturn($metadata->reveal())->shouldBeCalled(); $routeGenerator->generate( - array_merge($data, [ + \array_merge($data, [ '_unlocalizedObject' => $unlocalizedDimensionContent->reveal(), '_localizedObject' => $localizedDimensionContentMock, ]), @@ -642,7 +642,7 @@ public function testMapNoRoutePath(): void $localizedDimensionContent->getLocale()->willReturn('en'); $routeGenerator->generate( - array_merge($data, [ + \array_merge($data, [ '_unlocalizedObject' => $unlocalizedDimensionContent->reveal(), '_localizedObject' => $localizedDimensionContentMock, ]), @@ -894,7 +894,7 @@ public function testMapCustomRoute(): void $localizedDimensionContent->getLocale()->willReturn('en'); $routeGenerator->generate( - array_merge($data, [ + \array_merge($data, [ '_unlocalizedObject' => $unlocalizedDimensionContent->reveal(), '_localizedObject' => $localizedDimensionContentMock, ]), diff --git a/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/TemplateDataMapperTest.php b/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/TemplateDataMapperTest.php index 885b0e63..45b441ce 100644 --- a/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/TemplateDataMapperTest.php +++ b/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/TemplateDataMapperTest.php @@ -107,7 +107,7 @@ public function testMapLocalizedNoTemplateInstance(): void $localizedDimensionContent = $this->prophesize(DimensionContentInterface::class); $this->expectException(\RuntimeException::class); - $this->expectExceptionMessage(sprintf( + $this->expectExceptionMessage(\sprintf( 'Expected "$localizedObject" from type "%s" but "%s" given.', TemplateInterface::class, \get_class($localizedDimensionContent->reveal()) diff --git a/Tests/Unit/Content/Application/ContentMerger/Merger/ExcerptMergerTest.php b/Tests/Unit/Content/Application/ContentMerger/Merger/ExcerptMergerTest.php index 0121d9e4..b25f8e34 100644 --- a/Tests/Unit/Content/Application/ContentMerger/Merger/ExcerptMergerTest.php +++ b/Tests/Unit/Content/Application/ContentMerger/Merger/ExcerptMergerTest.php @@ -84,13 +84,13 @@ public function testMergeSet(): void $target->setExcerptTitle('Excerpt Title')->shouldBeCalled(); $target->setExcerptDescription('Excerpt Description')->shouldBeCalled(); $target->setExcerptMore('Excerpt More')->shouldBeCalled(); - $target->setExcerptTags(Argument::that(function ($tags) { - return array_map(function (TagInterface $tag) { + $target->setExcerptTags(Argument::that(function($tags) { + return \array_map(function(TagInterface $tag) { return $tag->getId(); }, $tags) === [1, 2]; }))->shouldBeCalled(); - $target->setExcerptCategories(Argument::that(function ($categories) { - return array_map(function (CategoryInterface $category) { + $target->setExcerptCategories(Argument::that(function($categories) { + return \array_map(function(CategoryInterface $category) { return $category->getId(); }, $categories) === [3, 4]; }))->shouldBeCalled(); diff --git a/Tests/Unit/Content/Application/ContentWorkflow/ContentWorkflowTest.php b/Tests/Unit/Content/Application/ContentWorkflow/ContentWorkflowTest.php index 3ef17fac..1b39aacd 100644 --- a/Tests/Unit/Content/Application/ContentWorkflow/ContentWorkflowTest.php +++ b/Tests/Unit/Content/Application/ContentWorkflow/ContentWorkflowTest.php @@ -87,7 +87,7 @@ public function testTransitionNoWorkflowInterface(): void $dimensionContent1->getStage()->willReturn('draft'); $dimensionContent1->getLocale()->willReturn('de'); - $this->expectExceptionMessage(sprintf( + $this->expectExceptionMessage(\sprintf( 'Expected "%s" but "%s" given.', WorkflowInterface::class, \get_class($dimensionContent2->reveal())) diff --git a/Tests/Unit/Content/Application/ContentWorkflow/Subscriber/UnpublishTransitionSubscriberTest.php b/Tests/Unit/Content/Application/ContentWorkflow/Subscriber/UnpublishTransitionSubscriberTest.php index 32193650..0fcdc3f8 100644 --- a/Tests/Unit/Content/Application/ContentWorkflow/Subscriber/UnpublishTransitionSubscriberTest.php +++ b/Tests/Unit/Content/Application/ContentWorkflow/Subscriber/UnpublishTransitionSubscriberTest.php @@ -160,7 +160,7 @@ public function testOnUnpublishNoLocalizedDimensionContent(): void ->willReturn(null) ->shouldBeCalled(); - $liveDimensionAttributes = array_merge($dimensionAttributes, ['stage' => DimensionContentInterface::STAGE_LIVE]); + $liveDimensionAttributes = \array_merge($dimensionAttributes, ['stage' => DimensionContentInterface::STAGE_LIVE]); $dimensionContentRepository->load($contentRichEntity->reveal(), $liveDimensionAttributes) ->willReturn($dimensionContentCollection) @@ -203,7 +203,7 @@ public function testOnUnpublish(): void ->willReturn($localizedLiveDimensionContent) ->shouldBeCalled(); - $liveDimensionAttributes = array_merge($dimensionAttributes, ['stage' => DimensionContentInterface::STAGE_LIVE]); + $liveDimensionAttributes = \array_merge($dimensionAttributes, ['stage' => DimensionContentInterface::STAGE_LIVE]); $dimensionContentRepository->load($contentRichEntity->reveal(), $liveDimensionAttributes) ->willReturn($dimensionContentCollection) diff --git a/Tests/Unit/Content/Application/DimensionContentCollectionFactory/DimensionContentCollectionFactoryTest.php b/Tests/Unit/Content/Application/DimensionContentCollectionFactory/DimensionContentCollectionFactoryTest.php index e46f624c..4217c637 100644 --- a/Tests/Unit/Content/Application/DimensionContentCollectionFactory/DimensionContentCollectionFactoryTest.php +++ b/Tests/Unit/Content/Application/DimensionContentCollectionFactory/DimensionContentCollectionFactoryTest.php @@ -76,8 +76,8 @@ public function testCreateWithExistingDimensionContent(): void $contentDataMapper->map( $data, Argument::that( - function (DimensionContentCollectionInterface $collection) use ($dimensionContent1, $dimensionContent2) { - return [$dimensionContent1->reveal(), $dimensionContent2->reveal()] === iterator_to_array($collection); + function(DimensionContentCollectionInterface $collection) use ($dimensionContent1, $dimensionContent2) { + return [$dimensionContent1->reveal(), $dimensionContent2->reveal()] === \iterator_to_array($collection); } ) )->shouldBeCalled(); @@ -102,7 +102,7 @@ function (DimensionContentCollectionInterface $collection) use ($dimensionConten $this->assertSame($attributes, $dimensionContentCollection->getDimensionAttributes()); $this->assertSame( [$dimensionContent1->reveal(), $dimensionContent2->reveal()], - iterator_to_array($dimensionContentCollection) + \iterator_to_array($dimensionContentCollection) ); } @@ -142,8 +142,8 @@ public function testCreateWithoutExistingDimensionContent(): void $contentDataMapper->map( $data, Argument::that( - function (DimensionContentCollectionInterface $collection) use ($dimensionContent1, $dimensionContent2) { - return [$dimensionContent1->reveal(), $dimensionContent2->reveal()] === iterator_to_array($collection); + function(DimensionContentCollectionInterface $collection) use ($dimensionContent1, $dimensionContent2) { + return [$dimensionContent1->reveal(), $dimensionContent2->reveal()] === \iterator_to_array($collection); } ) )->shouldBeCalled(); @@ -166,7 +166,7 @@ function (DimensionContentCollectionInterface $collection) use ($dimensionConten $this->assertSame($attributes, $dimensionContentCollection->getDimensionAttributes()); $this->assertSame( [$dimensionContent1->reveal(), $dimensionContent2->reveal()], - iterator_to_array($dimensionContentCollection) + \iterator_to_array($dimensionContentCollection) ); } @@ -200,8 +200,8 @@ public function testCreateWithoutExistingLocalizedDimensionContent(): void $contentDataMapper->map( $data, Argument::that( - function (DimensionContentCollectionInterface $collection) use ($dimensionContent1, $dimensionContent2) { - return [$dimensionContent1->reveal(), $dimensionContent2->reveal()] === iterator_to_array($collection); + function(DimensionContentCollectionInterface $collection) use ($dimensionContent1, $dimensionContent2) { + return [$dimensionContent1->reveal(), $dimensionContent2->reveal()] === \iterator_to_array($collection); } ) )->shouldBeCalled(); @@ -224,7 +224,7 @@ function (DimensionContentCollectionInterface $collection) use ($dimensionConten $this->assertSame($attributes, $dimensionContentCollection->getDimensionAttributes()); $this->assertSame( [$dimensionContent1->reveal(), $dimensionContent2->reveal()], - iterator_to_array($dimensionContentCollection) + \iterator_to_array($dimensionContentCollection) ); } } diff --git a/Tests/Unit/Content/Domain/Model/ContentRichEntityTraitTest.php b/Tests/Unit/Content/Domain/Model/ContentRichEntityTraitTest.php index 10b65ad7..1820200d 100644 --- a/Tests/Unit/Content/Domain/Model/ContentRichEntityTraitTest.php +++ b/Tests/Unit/Content/Domain/Model/ContentRichEntityTraitTest.php @@ -52,12 +52,12 @@ public function testGetAddRemoveDimension(): void $this->assertSame([ $modelDimension1->reveal(), $modelDimension2->reveal(), - ], iterator_to_array($model->getDimensionContents())); + ], \iterator_to_array($model->getDimensionContents())); $model->removeDimensionContent($modelDimension2->reveal()); $this->assertSame([ $modelDimension1->reveal(), - ], iterator_to_array($model->getDimensionContents())); + ], \iterator_to_array($model->getDimensionContents())); } } diff --git a/Tests/Unit/Content/Domain/Model/DimensionContentCollectionTest.php b/Tests/Unit/Content/Domain/Model/DimensionContentCollectionTest.php index a2f5a453..83c637cf 100644 --- a/Tests/Unit/Content/Domain/Model/DimensionContentCollectionTest.php +++ b/Tests/Unit/Content/Domain/Model/DimensionContentCollectionTest.php @@ -72,7 +72,7 @@ public function testIterator(): void $this->assertSame([ $dimensionContent1->reveal(), $dimensionContent2->reveal(), - ], iterator_to_array($dimensionContentCollection)); + ], \iterator_to_array($dimensionContentCollection)); } public function testGetDimensionContentClass(): void diff --git a/Tests/Unit/Content/Domain/Model/ExcerptTraitTest.php b/Tests/Unit/Content/Domain/Model/ExcerptTraitTest.php index 48de47d7..e8d5c378 100644 --- a/Tests/Unit/Content/Domain/Model/ExcerptTraitTest.php +++ b/Tests/Unit/Content/Domain/Model/ExcerptTraitTest.php @@ -80,7 +80,7 @@ public function testGetSetExcerptTags(): void $model = $this->getExcerptInstance(); $this->assertEmpty($model->getExcerptTags()); $model->setExcerptTags([$tag1, $tag2]); - $this->assertSame([1, 2], array_map(function (TagInterface $tag) { + $this->assertSame([1, 2], \array_map(function(TagInterface $tag) { return $tag->getId(); }, $model->getExcerptTags())); } @@ -93,7 +93,7 @@ public function testGetSetExcerptCategories(): void $model = $this->getExcerptInstance(); $this->assertEmpty($model->getExcerptCategories()); $model->setExcerptCategories([$category1, $category2]); - $this->assertSame([1, 2], array_map(function (CategoryInterface $category) { + $this->assertSame([1, 2], \array_map(function(CategoryInterface $category) { return $category->getId(); }, $model->getExcerptCategories())); } diff --git a/Tests/Unit/Content/Infrastructure/Doctrine/MetadataLoaderTest.php b/Tests/Unit/Content/Infrastructure/Doctrine/MetadataLoaderTest.php index c4c6f476..88e56054 100644 --- a/Tests/Unit/Content/Infrastructure/Doctrine/MetadataLoaderTest.php +++ b/Tests/Unit/Content/Infrastructure/Doctrine/MetadataLoaderTest.php @@ -78,21 +78,21 @@ public function testInvalidMetadata(array $interfaces, array $fields, array $man foreach ($fields as $field => $exist) { $classMetadata->hasField($field)->willReturn($exist); - $classMetadata->mapField(Argument::that(function (array $mapping) use ($field) { + $classMetadata->mapField(Argument::that(function(array $mapping) use ($field) { return $mapping['fieldName'] === $field; }))->shouldBeCalledTimes($exist ? 0 : 1); } foreach ($manyToManyAssociations as $association => $exist) { $classMetadata->hasAssociation($association)->willReturn($exist); - $classMetadata->mapManyToMany(Argument::that(function (array $mapping) use ($association) { + $classMetadata->mapManyToMany(Argument::that(function(array $mapping) use ($association) { return $mapping['fieldName'] === $association; }))->shouldBeCalledTimes($exist ? 0 : 1); } foreach ($manyToOneAssociations as $association => $exist) { $classMetadata->hasAssociation($association)->willReturn($exist); - $classMetadata->mapManyToOne(Argument::that(function (array $mapping) use ($association) { + $classMetadata->mapManyToOne(Argument::that(function(array $mapping) use ($association) { return $mapping['fieldName'] === $association; }))->shouldBeCalledTimes($exist ? 0 : 1); } diff --git a/Tests/Unit/Content/Infrastructure/Sulu/Admin/ContentViewBuilderFactoryTest.php b/Tests/Unit/Content/Infrastructure/Sulu/Admin/ContentViewBuilderFactoryTest.php index 60ae106a..13f966a5 100644 --- a/Tests/Unit/Content/Infrastructure/Sulu/Admin/ContentViewBuilderFactoryTest.php +++ b/Tests/Unit/Content/Infrastructure/Sulu/Admin/ContentViewBuilderFactoryTest.php @@ -289,7 +289,7 @@ public function testCreateViewsWithSecurityContext(array $permissions, array $ex foreach ($views as $index => $viewBuilder) { $toolbarActions = $viewBuilder->getView()->getOption('toolbarActions'); - $toolbarActionTypes = array_map(function ($toolbarAction) { + $toolbarActionTypes = \array_map(function($toolbarAction) { return $toolbarAction->getType(); }, $toolbarActions); @@ -411,7 +411,7 @@ public function testCreateViewsWithContentRichEntityClass(DimensionContentInterf foreach ($views as $index => $viewBuilder) { $toolbarActions = $viewBuilder->getView()->getOption('toolbarActions'); - $toolbarActionTypes = array_map(function ($toolbarAction) { + $toolbarActionTypes = \array_map(function($toolbarAction) { return $toolbarAction->getType(); }, $toolbarActions); diff --git a/Tests/Unit/Content/Infrastructure/Sulu/Preview/ContentObjectProviderTest.php b/Tests/Unit/Content/Infrastructure/Sulu/Preview/ContentObjectProviderTest.php index 119b5fce..f338522d 100644 --- a/Tests/Unit/Content/Infrastructure/Sulu/Preview/ContentObjectProviderTest.php +++ b/Tests/Unit/Content/Infrastructure/Sulu/Preview/ContentObjectProviderTest.php @@ -74,20 +74,20 @@ public function testGetObject(int $id = 1, string $locale = 'de'): void $this->entityManager->createQueryBuilder()->willReturn($queryBuilder->reveal())->shouldBeCalledTimes(1); - $queryBuilder->select(Argument::type('string'))->will(function () { - return func_get_arg(\func_num_args() - 2); + $queryBuilder->select(Argument::type('string'))->will(function() { + return \func_get_arg(\func_num_args() - 2); })->shouldBeCalledTimes(1); - $queryBuilder->from(Argument::type('string'), Argument::type('string'))->will(function () { - return func_get_arg(\func_num_args() - 2); + $queryBuilder->from(Argument::type('string'), Argument::type('string'))->will(function() { + return \func_get_arg(\func_num_args() - 2); })->shouldBeCalledTimes(1); - $queryBuilder->where(Argument::type('string'))->will(function () { - return func_get_arg(\func_num_args() - 2); + $queryBuilder->where(Argument::type('string'))->will(function() { + return \func_get_arg(\func_num_args() - 2); })->shouldBeCalledTimes(1); - $queryBuilder->setParameter(Argument::type('string'), Argument::any())->will(function () { - return func_get_arg(\func_num_args() - 2); + $queryBuilder->setParameter(Argument::type('string'), Argument::any())->will(function() { + return \func_get_arg(\func_num_args() - 2); })->shouldBeCalledTimes(1); $query = $this->prophesize(AbstractQuery::class); @@ -125,20 +125,20 @@ public function testGetObjectContentNotFound(int $id = 1, string $locale = 'de') $this->entityManager->createQueryBuilder()->willReturn($queryBuilder->reveal())->shouldBeCalledTimes(1); - $queryBuilder->select(Argument::type('string'))->will(function () { - return func_get_arg(\func_num_args() - 2); + $queryBuilder->select(Argument::type('string'))->will(function() { + return \func_get_arg(\func_num_args() - 2); })->shouldBeCalledTimes(1); - $queryBuilder->from(Argument::type('string'), Argument::type('string'))->will(function () { - return func_get_arg(\func_num_args() - 2); + $queryBuilder->from(Argument::type('string'), Argument::type('string'))->will(function() { + return \func_get_arg(\func_num_args() - 2); })->shouldBeCalledTimes(1); - $queryBuilder->where(Argument::type('string'))->will(function () { - return func_get_arg(\func_num_args() - 2); + $queryBuilder->where(Argument::type('string'))->will(function() { + return \func_get_arg(\func_num_args() - 2); })->shouldBeCalledTimes(1); - $queryBuilder->setParameter(Argument::type('string'), Argument::any())->will(function () { - return func_get_arg(\func_num_args() - 2); + $queryBuilder->setParameter(Argument::type('string'), Argument::any())->will(function() { + return \func_get_arg(\func_num_args() - 2); })->shouldBeCalledTimes(1); $query = $this->prophesize(AbstractQuery::class); @@ -202,7 +202,7 @@ public function testSetValues( $this->contentDataMapper->map( $data, Argument::that( - function (PreviewDimensionContentCollection $dimensionContentCollection) use ($dimensionContent) { + function(PreviewDimensionContentCollection $dimensionContentCollection) use ($dimensionContent) { return $dimensionContent->reveal() === $dimensionContentCollection->getDimensionContent([]); } ) @@ -232,7 +232,7 @@ public function testSerialize(): void $dimensionContent->getLocale()->willReturn('en'); $dimensionContent->getStage()->willReturn('draft'); - $serializedObject = json_encode([ + $serializedObject = \json_encode([ 'id' => '123-456', 'locale' => 'en', ]); @@ -248,20 +248,20 @@ public function testDeserialize(): void $this->entityManager->createQueryBuilder()->willReturn($queryBuilder->reveal())->shouldBeCalledTimes(1); - $queryBuilder->select(Argument::type('string'))->will(function () { - return func_get_arg(\func_num_args() - 2); + $queryBuilder->select(Argument::type('string'))->will(function() { + return \func_get_arg(\func_num_args() - 2); })->shouldBeCalledTimes(1); - $queryBuilder->from(Argument::type('string'), Argument::type('string'))->will(function () { - return func_get_arg(\func_num_args() - 2); + $queryBuilder->from(Argument::type('string'), Argument::type('string'))->will(function() { + return \func_get_arg(\func_num_args() - 2); })->shouldBeCalledTimes(1); - $queryBuilder->where(Argument::type('string'))->will(function () { - return func_get_arg(\func_num_args() - 2); + $queryBuilder->where(Argument::type('string'))->will(function() { + return \func_get_arg(\func_num_args() - 2); })->shouldBeCalledTimes(1); - $queryBuilder->setParameter(Argument::type('string'), Argument::any())->will(function () { - return func_get_arg(\func_num_args() - 2); + $queryBuilder->setParameter(Argument::type('string'), Argument::any())->will(function() { + return \func_get_arg(\func_num_args() - 2); })->shouldBeCalledTimes(1); $query = $this->prophesize(AbstractQuery::class); @@ -279,7 +279,7 @@ public function testDeserialize(): void Argument::type('array') )->willReturn($dimensionContent->reveal())->shouldBeCalledTimes(1); - $serializedObject = json_encode([ + $serializedObject = \json_encode([ 'id' => '123-456', 'locale' => 'en', ]) ?: ''; @@ -291,7 +291,7 @@ public function testDeserialize(): void public function testDeserializeIdNull(): void { - $serializedObject = json_encode([ + $serializedObject = \json_encode([ 'id' => null, 'locale' => 'en', ]) ?: ''; @@ -303,7 +303,7 @@ public function testDeserializeIdNull(): void public function testDeserializeLocaleNull(): void { - $serializedObject = json_encode([ + $serializedObject = \json_encode([ 'id' => '123-456', 'locale' => null, ]) ?: ''; diff --git a/Tests/Unit/Content/Infrastructure/Sulu/Preview/PreviewDimensionContentCollectionTest.php b/Tests/Unit/Content/Infrastructure/Sulu/Preview/PreviewDimensionContentCollectionTest.php index 37117919..d9c4d5be 100644 --- a/Tests/Unit/Content/Infrastructure/Sulu/Preview/PreviewDimensionContentCollectionTest.php +++ b/Tests/Unit/Content/Infrastructure/Sulu/Preview/PreviewDimensionContentCollectionTest.php @@ -88,7 +88,7 @@ public function testGetIterator(): void $this->assertSame( [$dimensionContent->reveal()], - iterator_to_array($previewDimensionContentCollection) + \iterator_to_array($previewDimensionContentCollection) ); } diff --git a/Tests/Unit/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProviderTest.php b/Tests/Unit/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProviderTest.php index dfb5ea53..aa80d635 100644 --- a/Tests/Unit/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProviderTest.php +++ b/Tests/Unit/Content/Infrastructure/Sulu/Route/ContentRouteDefaultsProviderTest.php @@ -251,7 +251,7 @@ public function testGetByEntityReturnNoneTemplate(): void $resolvedDimensionContent = $this->prophesize(DimensionContentInterface::class); $this->expectException(\RuntimeException::class); - $this->expectExceptionMessage(sprintf( + $this->expectExceptionMessage(\sprintf( 'Expected to get "%s" from ContentResolver but "%s" given.', TemplateInterface::class, \get_class($resolvedDimensionContent->reveal()) @@ -295,7 +295,7 @@ public function testGetByEntityReturnNoneTemplateFromPreview(): void $contentRichEntity = $this->prophesize(ContentRichEntityInterface::class); $this->expectException(\RuntimeException::class); - $this->expectExceptionMessage(sprintf( + $this->expectExceptionMessage(\sprintf( 'Expected to get "%s" from ContentResolver but "%s" given.', TemplateInterface::class, \get_class($contentRichEntity->reveal()) @@ -400,7 +400,7 @@ public function testGetByEntityNotPublished(): void $query->getSingleResult()->willReturn($contentRichEntity->reveal()); $contentResolver->resolve($contentRichEntity->reveal(), ['locale' => 'en', 'stage' => 'live']) - ->will(function ($arguments) { + ->will(function($arguments) { throw new ContentNotFoundException($arguments[0], $arguments[1]); }); diff --git a/Tests/Unit/Content/Infrastructure/Sulu/Structure/ContentStructureBridgeFactoryTest.php b/Tests/Unit/Content/Infrastructure/Sulu/Structure/ContentStructureBridgeFactoryTest.php index 163a83ec..2821ef37 100644 --- a/Tests/Unit/Content/Infrastructure/Sulu/Structure/ContentStructureBridgeFactoryTest.php +++ b/Tests/Unit/Content/Infrastructure/Sulu/Structure/ContentStructureBridgeFactoryTest.php @@ -75,7 +75,7 @@ public function testGetBridge(): void public function testGetBridgeNoStructureMetadata(): void { $this->expectException(StructureMetadataNotFoundException::class); - $this->expectExceptionMessage(sprintf( + $this->expectExceptionMessage(\sprintf( 'No structure metadata found for template type "%s" and template key "%s"', 'mock-template-type', 'default' diff --git a/Tests/Unit/Content/Infrastructure/Sulu/Structure/ContentStructureBridgeTest.php b/Tests/Unit/Content/Infrastructure/Sulu/Structure/ContentStructureBridgeTest.php index 2495d142..e257b1ed 100644 --- a/Tests/Unit/Content/Infrastructure/Sulu/Structure/ContentStructureBridgeTest.php +++ b/Tests/Unit/Content/Infrastructure/Sulu/Structure/ContentStructureBridgeTest.php @@ -272,7 +272,7 @@ public function testGetProperty(): void $legacyProperty->setPropertyValue( Argument::that( - function (PropertyValue $propertyValue) { + function(PropertyValue $propertyValue) { return 'title' === $propertyValue->getName() && 'Test' === $propertyValue->getValue(); } ) @@ -303,7 +303,7 @@ public function testGetPropertyChild(): void $legacyProperty->setPropertyValue( Argument::that( - function (PropertyValue $propertyValue) { + function(PropertyValue $propertyValue) { return 'title' === $propertyValue->getName() && 'Test' === $propertyValue->getValue(); } ) @@ -334,7 +334,7 @@ public function testGetPropertyByTagName(): void $legacyProperty->setPropertyValue( Argument::that( - function (PropertyValue $propertyValue) { + function(PropertyValue $propertyValue) { return 'title' === $propertyValue->getName() && 'Test' === $propertyValue->getValue(); } ) @@ -365,7 +365,7 @@ public function testGetPropertiesByTagName(): void $legacyProperty->setPropertyValue( Argument::that( - function (PropertyValue $propertyValue) { + function(PropertyValue $propertyValue) { return 'title' === $propertyValue->getName() && 'Test' === $propertyValue->getValue(); } ) @@ -397,7 +397,7 @@ public function testGetPropertyValue(): void $legacyProperty->setPropertyValue( Argument::that( - function (PropertyValue $propertyValue) { + function(PropertyValue $propertyValue) { return 'title' === $propertyValue->getName() && 'Test' === $propertyValue->getValue(); } ) @@ -429,7 +429,7 @@ public function testGetPropertyValueByTagName(): void $legacyProperty->setPropertyValue( Argument::that( - function (PropertyValue $propertyValue) { + function(PropertyValue $propertyValue) { return 'title' === $propertyValue->getName() && 'Test' === $propertyValue->getValue(); } ) @@ -459,7 +459,7 @@ public function testGetProperties(): void $legacyProperty->setPropertyValue( Argument::that( - function (PropertyValue $propertyValue) { + function(PropertyValue $propertyValue) { return 'title' === $propertyValue->getName() && 'Test' === $propertyValue->getValue(); } ) @@ -509,7 +509,7 @@ public function testGetPropertiesFlated(): void $legacyProperty->setPropertyValue( Argument::that( - function (PropertyValue $propertyValue) { + function(PropertyValue $propertyValue) { return 'title' === $propertyValue->getName() && 'Test' === $propertyValue->getValue(); } ) diff --git a/Tests/phpstan/console-application.php b/Tests/phpstan/console-application.php index 12362ca7..3a50b659 100644 --- a/Tests/phpstan/console-application.php +++ b/Tests/phpstan/console-application.php @@ -14,7 +14,7 @@ use Sulu\Bundle\ContentBundle\Tests\Application\Kernel; use Symfony\Bundle\FrameworkBundle\Console\Application; -require dirname(__DIR__) . '/Application/config/bootstrap.php'; +require \dirname(__DIR__) . '/Application/config/bootstrap.php'; $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG'], Kernel::CONTEXT_ADMIN); $kernel->boot(); diff --git a/Tests/phpstan/object-manager.php b/Tests/phpstan/object-manager.php index b9476b65..708b71d3 100644 --- a/Tests/phpstan/object-manager.php +++ b/Tests/phpstan/object-manager.php @@ -14,7 +14,7 @@ use Sulu\Bundle\ContentBundle\Tests\Application\Kernel; use Symfony\Component\DependencyInjection\ContainerInterface; -require dirname(__DIR__) . '/Application/config/bootstrap.php'; +require \dirname(__DIR__) . '/Application/config/bootstrap.php'; $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG'], Kernel::CONTEXT_ADMIN); $kernel->boot(); diff --git a/composer.json b/composer.json index 5c3d5ec0..5a0f85e7 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "coduo/php-matcher": "^3.2 || ^4.0 || ^5.0 || ^6.0", "doctrine/data-fixtures": "^1.3.3", "doctrine/doctrine-fixtures-bundle": "^2.0 || ^3.0", - "friendsofphp/php-cs-fixer": "^2.17 || ^3.0", + "friendsofphp/php-cs-fixer": "^3.4", "handcraftedinthealps/code-coverage-checker": "^0.2.1", "handcraftedinthealps/zendsearch": "^2.0", "jackalope/jackalope-doctrine-dbal": "^1.3.4", diff --git a/depfile.yaml b/depfile.yaml deleted file mode 100644 index cb33e7c6..00000000 --- a/depfile.yaml +++ /dev/null @@ -1,31 +0,0 @@ -paths: - - ./Content - -layers: - - name: UserInterface - collectors: - - type: directory - regex: UserInterface/.* - - name: Infrastructure - collectors: - - type: directory - regex: Infrastructure/.* - - name: Application - collectors: - - type: directory - regex: Application/.* - - name: Domain - collectors: - - type: directory - regex: Domain/.* - -ruleset: - UserInterface: - - Application - - Domain - Infrastructure: - - Application - - Domain - Application: - - Domain - Domain: ~ diff --git a/deptrac.yaml b/deptrac.yaml new file mode 100644 index 00000000..07321b41 --- /dev/null +++ b/deptrac.yaml @@ -0,0 +1,32 @@ +parameters: + paths: + - ./Content + + layers: + - name: UserInterface + collectors: + - type: directory + regex: UserInterface/.* + - name: Infrastructure + collectors: + - type: directory + regex: Infrastructure/.* + - name: Application + collectors: + - type: directory + regex: Application/.* + - name: Domain + collectors: + - type: directory + regex: Domain/.* + + ruleset: + UserInterface: + - Application + - Domain + Infrastructure: + - Application + - Domain + Application: + - Domain + Domain: ~