From 2bd26900e3c2e395d59925bb186e804cc264d67d Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Mon, 4 Sep 2023 14:49:37 -0300 Subject: [PATCH] Fix PHPStan findings about iterable parameters --- phpstan-baseline.neon | 10 ++--- phpstan.neon.dist | 2 - .../Repository/LogEntryRepository.php | 3 +- src/Loggable/Mapping/Driver/Annotation.php | 4 ++ src/Loggable/Mapping/Driver/Xml.php | 2 + src/Loggable/Mapping/Driver/Yaml.php | 4 ++ src/Mapping/Annotation/Blameable.php | 1 + src/Mapping/Annotation/IpTraceable.php | 1 + src/Mapping/Annotation/Loggable.php | 2 + src/Mapping/Annotation/Reference.php | 2 + src/Mapping/Annotation/ReferenceIntegrity.php | 2 +- src/Mapping/Annotation/Slug.php | 5 ++- src/Mapping/Annotation/SlugHandler.php | 7 +++- src/Mapping/Annotation/SlugHandlerOption.php | 3 +- src/Mapping/Annotation/SoftDeleteable.php | 3 ++ src/Mapping/Annotation/Timestampable.php | 5 ++- src/Mapping/Annotation/Translatable.php | 3 ++ src/Mapping/Annotation/TranslationEntity.php | 3 ++ src/Mapping/Annotation/Tree.php | 2 + src/Mapping/Annotation/TreeClosure.php | 2 + src/Mapping/Annotation/TreeLevel.php | 3 ++ src/Mapping/Annotation/TreePath.php | 3 ++ src/Mapping/Annotation/TreeRoot.php | 3 ++ src/Mapping/Annotation/Uploadable.php | 3 ++ src/Mapping/Driver.php | 4 +- src/Mapping/Event/AdapterInterface.php | 4 +- src/Mapping/ExtensionMetadataFactory.php | 3 ++ .../Mapping/Event/ReferencesAdapter.php | 6 +-- .../Handler/SlugHandlerInterface.php | 19 +++++---- ...SlugHandlerWithUniqueCallbackInterface.php | 5 ++- src/Sluggable/Mapping/Driver/Annotation.php | 2 + src/Sluggable/Mapping/Driver/Xml.php | 3 ++ src/Sluggable/Mapping/Driver/Yaml.php | 4 ++ src/Sluggable/SluggableListener.php | 2 + .../Exec/MultiTableDeleteExecutor.php | 3 ++ .../Query/TreeWalker/SoftDeleteableWalker.php | 2 + .../Entity/Repository/SortableRepository.php | 6 +++ src/Sortable/Mapping/Driver/Xml.php | 3 ++ src/Sortable/Mapping/Driver/Yaml.php | 1 + src/Sortable/Mapping/Event/Adapter/ODM.php | 11 +++--- src/Sortable/Mapping/Event/Adapter/ORM.php | 11 +++--- src/Sortable/SortableListener.php | 39 +++++++++++-------- src/Tool/WrapperInterface.php | 2 + src/Translatable/Mapping/Driver/Xml.php | 6 +++ src/Translatable/Mapping/Driver/Yaml.php | 4 ++ .../Query/TreeWalker/TranslationWalker.php | 6 +++ src/Translator/TranslationProxy.php | 12 +++--- .../Repository/AbstractTreeRepository.php | 16 ++++---- .../Repository/AbstractTreeRepository.php | 16 ++++---- .../Repository/ClosureTreeRepository.php | 2 +- .../Repository/NestedTreeRepository.php | 2 +- src/Tree/Hydrator/ORM/TreeObjectHydrator.php | 6 ++- src/Tree/Mapping/Validator.php | 9 +++-- src/Tree/RepositoryInterface.php | 8 ++-- src/Tree/RepositoryUtilsInterface.php | 24 ++++++------ src/Tree/Strategy/ORM/Closure.php | 2 +- src/Uploadable/UploadableListener.php | 9 +++-- .../Extension/Encoder/EncoderListener.php | 3 ++ tests/Gedmo/Tool/BaseTestCaseOM.php | 14 ++++++- .../Translatable/Fixture/Issue75/Article.php | 3 ++ .../Translatable/Fixture/Type/Custom.php | 2 + ...terializedPathODMMongoDBRepositoryTest.php | 2 +- .../Tree/MaterializedPathODMMongoDBTest.php | 7 +++- .../Tree/MaterializedPathORMFeaturesTest.php | 26 ++++++++----- .../MaterializedPathORMRepositoryTest.php | 18 ++++----- ...MaterializedPathORMRootAssociationTest.php | 21 +++++----- tests/Gedmo/Tree/MaterializedPathORMTest.php | 21 +++++----- .../Gedmo/Uploadable/UploadableEntityTest.php | 2 + 68 files changed, 301 insertions(+), 148 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 5a52a3f189..ec85088095 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -255,11 +255,6 @@ parameters: count: 3 path: src/Sluggable/Handler/TreeSlugHandler.php - - - message: "#^Part \\$option \\(array\\{string, mixed\\}\\) of encapsed string cannot be cast to string\\.$#" - count: 1 - path: src/Sluggable/Mapping/Driver/Annotation.php - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$isMappedSuperclass\\.$#" count: 1 @@ -505,6 +500,11 @@ parameters: count: 1 path: src/Tree/TreeListener.php + - + message: "#^Method Gedmo\\\\Uploadable\\\\Event\\\\UploadableBaseEventArgs\\:\\:__construct\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#" + count: 2 + path: src/Uploadable/Event/UploadableBaseEventArgs.php + - message: "#^Method Gedmo\\\\Uploadable\\\\Event\\\\UploadableBaseEventArgs\\:\\:getExtensionConfiguration\\(\\) return type has no value type specified in iterable type array\\.$#" count: 2 diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 553d280e86..34297d0f2b 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -19,8 +19,6 @@ parameters: - '#^Property Gedmo\\Tests\\.+\\Fixture\\[^:]+::\$\w+ is never written, only read\.$#' - '#^Property Gedmo\\Tests\\.+\\Fixture\\[^:]+::\$\w+ is never read, only written\.$#' - '#^Property Gedmo\\Tests\\.+\\Fixture\\[^:]+::\$\w+ is unused\.$#' - # @todo: Remove the following ignored error when the parameters are correctly declared. - - '#^Method Gedmo\\[^:]+::[^\(]+\(\) has parameter \$\w+ with no value type specified in iterable type array\.$#' rules: - PHPStan\Rules\Constants\MissingClassConstantTypehintRule diff --git a/src/Loggable/Document/Repository/LogEntryRepository.php b/src/Loggable/Document/Repository/LogEntryRepository.php index bcdeb84394..b2b8bfe13e 100644 --- a/src/Loggable/Document/Repository/LogEntryRepository.php +++ b/src/Loggable/Document/Repository/LogEntryRepository.php @@ -106,7 +106,8 @@ public function revert($document, $version = 1) /** * Fills a documents versioned fields with data * - * @param object $document + * @param object $document + * @param array $data * * @return void * diff --git a/src/Loggable/Mapping/Driver/Annotation.php b/src/Loggable/Mapping/Driver/Annotation.php index 6fd718fa03..db225fb5c4 100644 --- a/src/Loggable/Mapping/Driver/Annotation.php +++ b/src/Loggable/Mapping/Driver/Annotation.php @@ -108,6 +108,8 @@ protected function isMappingValid(ClassMetadata $meta, $field) } /** + * @param array $config + * * @return bool */ protected function isClassAnnotationInValid(ClassMetadata $meta, array &$config) @@ -117,6 +119,8 @@ protected function isClassAnnotationInValid(ClassMetadata $meta, array &$config) /** * Searches properties of embedded object for versioned fields + * + * @param array $config */ private function inspectEmbeddedForVersioned(string $field, array &$config, \Doctrine\ORM\Mapping\ClassMetadata $meta): void { diff --git a/src/Loggable/Mapping/Driver/Xml.php b/src/Loggable/Mapping/Driver/Xml.php index 82a33dcdb0..92940c142e 100644 --- a/src/Loggable/Mapping/Driver/Xml.php +++ b/src/Loggable/Mapping/Driver/Xml.php @@ -86,6 +86,8 @@ public function readExtendedMetadata($meta, array &$config) /** * Searches mappings on element for versioned fields + * + * @param array $config */ private function inspectElementForVersioned(\SimpleXMLElement $element, array &$config, ClassMetadata $meta): void { diff --git a/src/Loggable/Mapping/Driver/Yaml.php b/src/Loggable/Mapping/Driver/Yaml.php index 5481473d51..c18d836e5c 100644 --- a/src/Loggable/Mapping/Driver/Yaml.php +++ b/src/Loggable/Mapping/Driver/Yaml.php @@ -139,6 +139,10 @@ protected function _loadMappingFile($file) return \Symfony\Component\Yaml\Yaml::parse(file_get_contents($file)); } + /** + * @param array>> $mapping + * @param array $config + */ private function inspectEmbeddedForVersioned(string $field, array $mapping, array &$config): void { if (isset($mapping['fields'])) { diff --git a/src/Mapping/Annotation/Blameable.php b/src/Mapping/Annotation/Blameable.php index 5d83839cc0..790ebbcac3 100644 --- a/src/Mapping/Annotation/Blameable.php +++ b/src/Mapping/Annotation/Blameable.php @@ -34,6 +34,7 @@ final class Blameable implements GedmoAnnotation public $value; /** + * @param array $data * @param string|string[]|null $field * @param mixed $value */ diff --git a/src/Mapping/Annotation/IpTraceable.php b/src/Mapping/Annotation/IpTraceable.php index f2be37b647..c9ee21c430 100644 --- a/src/Mapping/Annotation/IpTraceable.php +++ b/src/Mapping/Annotation/IpTraceable.php @@ -34,6 +34,7 @@ final class IpTraceable implements GedmoAnnotation public $value; /** + * @param array $data * @param string|string[]|null $field * @param mixed $value */ diff --git a/src/Mapping/Annotation/Loggable.php b/src/Mapping/Annotation/Loggable.php index 6773232173..ce29fba47c 100644 --- a/src/Mapping/Annotation/Loggable.php +++ b/src/Mapping/Annotation/Loggable.php @@ -37,6 +37,8 @@ final class Loggable implements GedmoAnnotation public $logEntryClass; /** + * @param array $data + * * @phpstan-param class-string|null $logEntryClass */ public function __construct(array $data = [], ?string $logEntryClass = null) diff --git a/src/Mapping/Annotation/Reference.php b/src/Mapping/Annotation/Reference.php index bcc8e62f31..01d56f8c33 100644 --- a/src/Mapping/Annotation/Reference.php +++ b/src/Mapping/Annotation/Reference.php @@ -51,6 +51,8 @@ abstract class Reference implements GedmoAnnotation public $inversedBy; /** + * @param array $data + * * @phpstan-param class-string|null $class */ public function __construct( diff --git a/src/Mapping/Annotation/ReferenceIntegrity.php b/src/Mapping/Annotation/ReferenceIntegrity.php index 9a1bbb9353..c19e6b9df8 100644 --- a/src/Mapping/Annotation/ReferenceIntegrity.php +++ b/src/Mapping/Annotation/ReferenceIntegrity.php @@ -30,7 +30,7 @@ final class ReferenceIntegrity implements GedmoAnnotation public $value; /** - * @param string|array|null $data + * @param string|array|null $data */ public function __construct($data = [], ?string $value = null) { diff --git a/src/Mapping/Annotation/Slug.php b/src/Mapping/Annotation/Slug.php index 8aee50d3fd..570cf05ac9 100644 --- a/src/Mapping/Annotation/Slug.php +++ b/src/Mapping/Annotation/Slug.php @@ -52,8 +52,9 @@ final class Slug implements GedmoAnnotation public $dateFormat = 'Y-m-d-H:i'; /** - * @param string[] $fields - * @param SlugHandler[] $handlers + * @param array $data + * @param string[] $fields + * @param SlugHandler[] $handlers */ public function __construct( array $data = [], diff --git a/src/Mapping/Annotation/SlugHandler.php b/src/Mapping/Annotation/SlugHandler.php index 14e073f272..732a289f39 100644 --- a/src/Mapping/Annotation/SlugHandler.php +++ b/src/Mapping/Annotation/SlugHandler.php @@ -33,12 +33,15 @@ final class SlugHandler implements GedmoAnnotation public $class = ''; /** - * @var array|array + * @var array|array */ public $options = []; /** - * @phpstan-param string|class-string $class + * @param array $data + * + * @phpstan-param string|class-string $class + * @phpstan-param array|array $options */ public function __construct( array $data = [], diff --git a/src/Mapping/Annotation/SlugHandlerOption.php b/src/Mapping/Annotation/SlugHandlerOption.php index 5dd5afcdf0..fb83e6b780 100644 --- a/src/Mapping/Annotation/SlugHandlerOption.php +++ b/src/Mapping/Annotation/SlugHandlerOption.php @@ -35,7 +35,8 @@ final class SlugHandlerOption implements GedmoAnnotation public $value; /** - * @param mixed $value + * @param array $data + * @param mixed $value */ public function __construct( array $data = [], diff --git a/src/Mapping/Annotation/SoftDeleteable.php b/src/Mapping/Annotation/SoftDeleteable.php index fe0215ebec..7d95c51ade 100644 --- a/src/Mapping/Annotation/SoftDeleteable.php +++ b/src/Mapping/Annotation/SoftDeleteable.php @@ -35,6 +35,9 @@ final class SoftDeleteable implements GedmoAnnotation /** @var bool */ public $hardDelete = true; + /** + * @param array $data + */ public function __construct(array $data = [], string $fieldName = 'deletedAt', bool $timeAware = false, bool $hardDelete = true) { if ([] !== $data) { diff --git a/src/Mapping/Annotation/Timestampable.php b/src/Mapping/Annotation/Timestampable.php index 20392db51d..44807bffc1 100644 --- a/src/Mapping/Annotation/Timestampable.php +++ b/src/Mapping/Annotation/Timestampable.php @@ -34,8 +34,9 @@ final class Timestampable implements GedmoAnnotation public $value; /** - * @param string|string[] $field - * @param mixed $value + * @param array $data + * @param string|string[] $field + * @param mixed $value */ public function __construct(array $data = [], string $on = 'update', $field = null, $value = null) { diff --git a/src/Mapping/Annotation/Translatable.php b/src/Mapping/Annotation/Translatable.php index 6f265af2c6..2379b40340 100644 --- a/src/Mapping/Annotation/Translatable.php +++ b/src/Mapping/Annotation/Translatable.php @@ -29,6 +29,9 @@ final class Translatable implements GedmoAnnotation /** @var bool|null */ public $fallback; + /** + * @param array $data + */ public function __construct(array $data = [], ?bool $fallback = null) { if ([] !== $data) { diff --git a/src/Mapping/Annotation/TranslationEntity.php b/src/Mapping/Annotation/TranslationEntity.php index 5c6ab7df35..f5c92df36f 100644 --- a/src/Mapping/Annotation/TranslationEntity.php +++ b/src/Mapping/Annotation/TranslationEntity.php @@ -33,6 +33,9 @@ final class TranslationEntity implements GedmoAnnotation */ public $class; + /** + * @param array $data + */ public function __construct(array $data = [], string $class = '') { if ([] !== $data) { diff --git a/src/Mapping/Annotation/Tree.php b/src/Mapping/Annotation/Tree.php index e5dccde329..9caca34c0e 100644 --- a/src/Mapping/Annotation/Tree.php +++ b/src/Mapping/Annotation/Tree.php @@ -49,6 +49,8 @@ final class Tree implements GedmoAnnotation public $identifierMethod; /** + * @param array $data + * * @phpstan-param 'closure'|'materializedPath'|'nested'|null $type */ public function __construct( diff --git a/src/Mapping/Annotation/TreeClosure.php b/src/Mapping/Annotation/TreeClosure.php index 589526f8ef..939d7646e5 100644 --- a/src/Mapping/Annotation/TreeClosure.php +++ b/src/Mapping/Annotation/TreeClosure.php @@ -34,6 +34,8 @@ final class TreeClosure implements GedmoAnnotation public $class; /** + * @param array $data + * * @phpstan-param string|class-string $class */ public function __construct(array $data = [], string $class = '') diff --git a/src/Mapping/Annotation/TreeLevel.php b/src/Mapping/Annotation/TreeLevel.php index 19ce938ac6..0fb16476c5 100644 --- a/src/Mapping/Annotation/TreeLevel.php +++ b/src/Mapping/Annotation/TreeLevel.php @@ -33,6 +33,9 @@ final class TreeLevel implements GedmoAnnotation */ public $base = 0; + /** + * @param array $data + */ public function __construct( array $data = [], int $base = 0 diff --git a/src/Mapping/Annotation/TreePath.php b/src/Mapping/Annotation/TreePath.php index b95c95cef6..133c3fdde3 100644 --- a/src/Mapping/Annotation/TreePath.php +++ b/src/Mapping/Annotation/TreePath.php @@ -40,6 +40,9 @@ final class TreePath implements GedmoAnnotation /** @var bool */ public $endsWithSeparator = true; + /** + * @param array $data + */ public function __construct( array $data = [], string $separator = ',', diff --git a/src/Mapping/Annotation/TreeRoot.php b/src/Mapping/Annotation/TreeRoot.php index cd89cbd701..0065995fdc 100644 --- a/src/Mapping/Annotation/TreeRoot.php +++ b/src/Mapping/Annotation/TreeRoot.php @@ -29,6 +29,9 @@ final class TreeRoot implements GedmoAnnotation /** @var string|null */ public $identifierMethod; + /** + * @param array $data + */ public function __construct(array $data = [], ?string $identifierMethod = null) { if ([] !== $data) { diff --git a/src/Mapping/Annotation/Uploadable.php b/src/Mapping/Annotation/Uploadable.php index 637691dbcb..e75c118c20 100644 --- a/src/Mapping/Annotation/Uploadable.php +++ b/src/Mapping/Annotation/Uploadable.php @@ -76,6 +76,9 @@ final class Uploadable implements GedmoAnnotation */ public $disallowedTypes = ''; + /** + * @param array $data + */ public function __construct( array $data = [], bool $allowOverwrite = false, diff --git a/src/Mapping/Driver.php b/src/Mapping/Driver.php index f0d42ef518..660a11aa3d 100644 --- a/src/Mapping/Driver.php +++ b/src/Mapping/Driver.php @@ -26,12 +26,14 @@ interface Driver /** * Read the extended metadata configuration for a single mapped class. * - * @param ClassMetadata&(OdmClassMetadata|OrmClassMetadata) $meta + * @param ClassMetadata $meta * @param array $config * * @return void * * @throws InvalidMappingException if the mapping configuration is invalid + * + * @phpstan-param ClassMetadata&(OdmClassMetadata|OrmClassMetadata) $meta */ public function readExtendedMetadata($meta, array &$config); diff --git a/src/Mapping/Event/AdapterInterface.php b/src/Mapping/Event/AdapterInterface.php index dcae65ab3e..683634c174 100644 --- a/src/Mapping/Event/AdapterInterface.php +++ b/src/Mapping/Event/AdapterInterface.php @@ -31,8 +31,8 @@ interface AdapterInterface * * Calls a method on the event args object. * - * @param string $method - * @param array $args + * @param string $method + * @param array $args * * @return mixed */ diff --git a/src/Mapping/ExtensionMetadataFactory.php b/src/Mapping/ExtensionMetadataFactory.php index 2e239803f3..43f0b50415 100644 --- a/src/Mapping/ExtensionMetadataFactory.php +++ b/src/Mapping/ExtensionMetadataFactory.php @@ -225,6 +225,9 @@ protected function getDriver($omDriver) return $driver; } + /** + * @param array $config + */ private function storeConfiguration(string $className, array $config): void { if (null === $this->cacheItemPool) { diff --git a/src/References/Mapping/Event/ReferencesAdapter.php b/src/References/Mapping/Event/ReferencesAdapter.php index 9e46fad47d..df5fdbaad2 100644 --- a/src/References/Mapping/Event/ReferencesAdapter.php +++ b/src/References/Mapping/Event/ReferencesAdapter.php @@ -35,9 +35,9 @@ public function getIdentifier($om, $object, $single = true); /** * Gets a single reference from the provided object manager for a class and identifier. * - * @param ObjectManager $om - * @param string $class - * @param array|string|int $identifier + * @param ObjectManager $om + * @param string $class + * @param array|string|int $identifier * * @phpstan-param class-string $class * diff --git a/src/Sluggable/Handler/SlugHandlerInterface.php b/src/Sluggable/Handler/SlugHandlerInterface.php index 706ec827ed..70d2a4c541 100644 --- a/src/Sluggable/Handler/SlugHandlerInterface.php +++ b/src/Sluggable/Handler/SlugHandlerInterface.php @@ -32,9 +32,10 @@ public function __construct(SluggableListener $sluggable); * Hook on slug handlers before the decision is made whether * the slug needs to be recalculated. * - * @param object $object - * @param string $slug - * @param bool $needToChangeSlug + * @param array $config + * @param object $object + * @param string $slug + * @param bool $needToChangeSlug * * @return void */ @@ -43,8 +44,9 @@ public function onChangeDecision(SluggableAdapter $ea, array &$config, $object, /** * Hook on slug handlers called after the slug is built. * - * @param object $object - * @param string $slug + * @param array $config + * @param object $object + * @param string $slug * * @return void */ @@ -53,8 +55,9 @@ public function postSlugBuild(SluggableAdapter $ea, array &$config, $object, &$s /** * Hook for slug handlers called after the slug is completed. * - * @param object $object - * @param string $slug + * @param array $config + * @param object $object + * @param string $slug * * @return void */ @@ -68,6 +71,8 @@ public function handlesUrlization(); /** * Validates the options for the handler. * + * @param array $options + * * @throws InvalidMappingException if the configuration is invalid * * @return void diff --git a/src/Sluggable/Handler/SlugHandlerWithUniqueCallbackInterface.php b/src/Sluggable/Handler/SlugHandlerWithUniqueCallbackInterface.php index 4c9c996244..bd6fe968b7 100644 --- a/src/Sluggable/Handler/SlugHandlerWithUniqueCallbackInterface.php +++ b/src/Sluggable/Handler/SlugHandlerWithUniqueCallbackInterface.php @@ -23,8 +23,9 @@ interface SlugHandlerWithUniqueCallbackInterface extends SlugHandlerInterface /** * Hook for slug handlers called before it is made unique. * - * @param object $object - * @param string $slug + * @param array $config + * @param object $object + * @param string $slug * * @return void */ diff --git a/src/Sluggable/Mapping/Driver/Annotation.php b/src/Sluggable/Mapping/Driver/Annotation.php index c67fad983d..4c95deba06 100644 --- a/src/Sluggable/Mapping/Driver/Annotation.php +++ b/src/Sluggable/Mapping/Driver/Annotation.php @@ -126,6 +126,8 @@ protected function getSlugHandlers(\ReflectionProperty $property, Slug $slug, Cl } /** + * @param array $config + * * @return array> */ private function retrieveSlug(ClassMetadata $meta, array &$config, \ReflectionProperty $property, ?string $fieldNamePrefix = null): array diff --git a/src/Sluggable/Mapping/Driver/Xml.php b/src/Sluggable/Mapping/Driver/Xml.php index 34f410f140..b7706e1594 100644 --- a/src/Sluggable/Mapping/Driver/Xml.php +++ b/src/Sluggable/Mapping/Driver/Xml.php @@ -77,6 +77,9 @@ protected function isValidField($meta, $field) return $mapping && in_array($mapping['type'], self::VALID_TYPES, true); } + /** + * @param array $config + */ private function buildFieldConfiguration(ClassMetadata $meta, string $field, \SimpleXMLElement $mapping, array &$config): void { /** diff --git a/src/Sluggable/Mapping/Driver/Yaml.php b/src/Sluggable/Mapping/Driver/Yaml.php index 8c6996747b..14791fdf86 100644 --- a/src/Sluggable/Mapping/Driver/Yaml.php +++ b/src/Sluggable/Mapping/Driver/Yaml.php @@ -86,6 +86,10 @@ protected function isValidField($meta, $field) return $mapping && in_array($mapping['type'], self::VALID_TYPES, true); } + /** + * @param array $fieldMapping + * @param array $config + */ private function buildFieldConfiguration(string $field, array $fieldMapping, ClassMetadata $meta, array &$config): void { if (isset($fieldMapping['gedmo'])) { diff --git a/src/Sluggable/SluggableListener.php b/src/Sluggable/SluggableListener.php index 75a95334f7..54434965a3 100644 --- a/src/Sluggable/SluggableListener.php +++ b/src/Sluggable/SluggableListener.php @@ -472,6 +472,8 @@ private function generateSlug(SluggableAdapter $ea, object $object): void /** * Generates the unique slug + * + * @param array $config */ private function makeUniqueSlug(SluggableAdapter $ea, object $object, string $preferredSlug, bool $recursing = false, array $config = []): string { diff --git a/src/SoftDeleteable/Query/TreeWalker/Exec/MultiTableDeleteExecutor.php b/src/SoftDeleteable/Query/TreeWalker/Exec/MultiTableDeleteExecutor.php index bc5cfc5d2c..df8fe7654b 100644 --- a/src/SoftDeleteable/Query/TreeWalker/Exec/MultiTableDeleteExecutor.php +++ b/src/SoftDeleteable/Query/TreeWalker/Exec/MultiTableDeleteExecutor.php @@ -25,6 +25,9 @@ */ class MultiTableDeleteExecutor extends BaseMultiTableDeleteExecutor { + /** + * @param array $config + */ public function __construct(Node $AST, $sqlWalker, ClassMetadata $meta, AbstractPlatform $platform, array $config) { parent::__construct($AST, $sqlWalker); diff --git a/src/SoftDeleteable/Query/TreeWalker/SoftDeleteableWalker.php b/src/SoftDeleteable/Query/TreeWalker/SoftDeleteableWalker.php index bcf7a32327..9e9d779f06 100644 --- a/src/SoftDeleteable/Query/TreeWalker/SoftDeleteableWalker.php +++ b/src/SoftDeleteable/Query/TreeWalker/SoftDeleteableWalker.php @@ -165,6 +165,8 @@ private function getSoftDeleteableListener(): SoftDeleteableListener /** * Search for components in the delete clause + * + * @param array> $queryComponents */ private function extractComponents(array $queryComponents): void { diff --git a/src/Sortable/Entity/Repository/SortableRepository.php b/src/Sortable/Entity/Repository/SortableRepository.php index 75e2367157..50d1dbbebd 100644 --- a/src/Sortable/Entity/Repository/SortableRepository.php +++ b/src/Sortable/Entity/Repository/SortableRepository.php @@ -65,6 +65,8 @@ public function __construct(EntityManagerInterface $em, ClassMetadata $class) } /** + * @param array $groupValues + * * @return Query */ public function getBySortableGroupsQuery(array $groupValues = []) @@ -73,6 +75,8 @@ public function getBySortableGroupsQuery(array $groupValues = []) } /** + * @param array $groupValues + * * @return QueryBuilder */ public function getBySortableGroupsQueryBuilder(array $groupValues = []) @@ -101,6 +105,8 @@ public function getBySortableGroupsQueryBuilder(array $groupValues = []) } /** + * @param array $groupValues + * * @return array */ public function getBySortableGroups(array $groupValues = []) diff --git a/src/Sortable/Mapping/Driver/Xml.php b/src/Sortable/Mapping/Driver/Xml.php index 3eca056616..d549f3282d 100644 --- a/src/Sortable/Mapping/Driver/Xml.php +++ b/src/Sortable/Mapping/Driver/Xml.php @@ -91,6 +91,9 @@ protected function isValidField($meta, $field) return $mapping && in_array($mapping['type'], self::VALID_TYPES, true); } + /** + * @param array $config + */ private function readSortableGroups(\SimpleXMLElement $mapping, array &$config, string $fieldAttr = 'field'): void { foreach ($mapping as $mappingDoctrine) { diff --git a/src/Sortable/Mapping/Driver/Yaml.php b/src/Sortable/Mapping/Driver/Yaml.php index ba8a1cbb4e..67ada70593 100644 --- a/src/Sortable/Mapping/Driver/Yaml.php +++ b/src/Sortable/Mapping/Driver/Yaml.php @@ -100,6 +100,7 @@ protected function isValidField($meta, $field) /** * @param iterable> $mapping + * @param array $config */ private function readSortableGroups(iterable $mapping, array &$config): void { diff --git a/src/Sortable/Mapping/Event/Adapter/ODM.php b/src/Sortable/Mapping/Event/Adapter/ODM.php index 5ca517c004..d293dfc148 100644 --- a/src/Sortable/Mapping/Event/Adapter/ODM.php +++ b/src/Sortable/Mapping/Event/Adapter/ODM.php @@ -23,8 +23,9 @@ final class ODM extends BaseAdapterODM implements SortableAdapter { /** - * @param ClassMetadata $meta - * @param array $groups + * @param array $config + * @param ClassMetadata $meta + * @param iterable $groups * * @return int */ @@ -51,9 +52,9 @@ public function getMaxPosition(array $config, $meta, $groups) } /** - * @param array $relocation - * @param array $delta - * @param array $config + * @param array $relocation + * @param array $delta + * @param array $config * * @return void */ diff --git a/src/Sortable/Mapping/Event/Adapter/ORM.php b/src/Sortable/Mapping/Event/Adapter/ORM.php index 1c6f292a18..166796bceb 100644 --- a/src/Sortable/Mapping/Event/Adapter/ORM.php +++ b/src/Sortable/Mapping/Event/Adapter/ORM.php @@ -26,8 +26,9 @@ final class ORM extends BaseAdapterORM implements SortableAdapter { /** - * @param ClassMetadata $meta - * @param array $groups + * @param array $config + * @param ClassMetadata $meta + * @param iterable $groups * * @return int|null */ @@ -48,9 +49,9 @@ public function getMaxPosition(array $config, $meta, $groups) } /** - * @param array $relocation - * @param array $delta - * @param array $config + * @param array $relocation + * @param array $delta + * @param array $config * @phpstan-param SortableRelocation $relocation * * @return void diff --git a/src/Sortable/SortableListener.php b/src/Sortable/SortableListener.php index fcaa737ddc..2707071e6f 100644 --- a/src/Sortable/SortableListener.php +++ b/src/Sortable/SortableListener.php @@ -317,8 +317,9 @@ public function postFlush(EventArgs $args) /** * Computes node positions and updates the sort field in memory and in the db * - * @param ClassMetadata $meta - * @param object $object + * @param array $config + * @param ClassMetadata $meta + * @param object $object * * @return void */ @@ -384,8 +385,9 @@ protected function processInsert(SortableAdapter $ea, array $config, $meta, $obj /** * Computes node positions and updates the sort field in memory and in the db * - * @param ClassMetadata $meta - * @param object $object + * @param array $config + * @param ClassMetadata $meta + * @param object $object * * @return void */ @@ -515,8 +517,9 @@ protected function processUpdate(SortableAdapter $ea, array $config, $meta, $obj /** * Computes node positions and updates the sort field in memory and in the db * - * @param ClassMetadata $meta - * @param object $object + * @param array $config + * @param ClassMetadata $meta + * @param object $object * * @return void */ @@ -566,6 +569,7 @@ protected function persistRelocations(SortableAdapter $ea) /** * @param array $groups + * @param array $config * * @return string */ @@ -585,9 +589,10 @@ protected function getHash($groups, array $config) } /** - * @param ClassMetadata $meta - * @param array $config - * @param object $object + * @param ClassMetadata $meta + * @param array $config + * @param object $object + * @param array $groups * * @return int */ @@ -630,13 +635,15 @@ protected function getMaxPosition(SortableAdapter $ea, $meta, $config, $object, /** * Add a relocation rule * - * @param string $hash The hash of the sorting group - * @param string $class The object class - * @param array $groups The sorting groups - * @param int $start Inclusive index to start relocation from - * @param int $stop Exclusive index to stop relocation at - * @param int $delta The delta to add to relocated nodes - * @param array $exclude Objects to be excluded from relocation + * @param string $hash The hash of the sorting group + * @param string $class The object class + * @param array $groups The sorting groups + * @param int $start Inclusive index to start relocation from + * @param int $stop Exclusive index to stop relocation at + * @param int $delta The delta to add to relocated nodes + * @param array $exclude Objects to be excluded from relocation + * + * @phpstan-param class-string $class * * @return void */ diff --git a/src/Tool/WrapperInterface.php b/src/Tool/WrapperInterface.php index 0ee0939e55..763aa454e7 100644 --- a/src/Tool/WrapperInterface.php +++ b/src/Tool/WrapperInterface.php @@ -51,6 +51,8 @@ public function setPropertyValue($property, $value); * * Populates the wrapped object with the given property values. * + * @param array $data + * * @return $this */ public function populate(array $data); diff --git a/src/Translatable/Mapping/Driver/Xml.php b/src/Translatable/Mapping/Driver/Xml.php index 41d2ef1fff..f9ef52085a 100644 --- a/src/Translatable/Mapping/Driver/Xml.php +++ b/src/Translatable/Mapping/Driver/Xml.php @@ -81,6 +81,9 @@ public function readExtendedMetadata($meta, array &$config) } } + /** + * @param array $config + */ private function inspectElementsForTranslatableFields(\SimpleXMLElement $xml, array &$config, ?string $prefix = null): void { if (!isset($xml->field)) { @@ -98,6 +101,9 @@ private function inspectElementsForTranslatableFields(\SimpleXMLElement $xml, ar } } + /** + * @param array $config + */ private function buildFieldConfiguration(string $fieldName, \SimpleXMLElement $mapping, array &$config): void { $mapping = $mapping->children(self::GEDMO_NAMESPACE_URI); diff --git a/src/Translatable/Mapping/Driver/Yaml.php b/src/Translatable/Mapping/Driver/Yaml.php index 1d9f1a18e8..c86a4ba39a 100644 --- a/src/Translatable/Mapping/Driver/Yaml.php +++ b/src/Translatable/Mapping/Driver/Yaml.php @@ -78,6 +78,10 @@ protected function _loadMappingFile($file) return \Symfony\Component\Yaml\Yaml::parse(file_get_contents($file)); } + /** + * @param array $fieldMapping + * @param array $config + */ private function buildFieldConfiguration(string $field, array $fieldMapping, array &$config): void { if (isset($fieldMapping['gedmo'])) { diff --git a/src/Translatable/Query/TreeWalker/TranslationWalker.php b/src/Translatable/Query/TreeWalker/TranslationWalker.php index 9d7030340f..f48895d0bb 100644 --- a/src/Translatable/Query/TreeWalker/TranslationWalker.php +++ b/src/Translatable/Query/TreeWalker/TranslationWalker.php @@ -392,6 +392,10 @@ private function needsFallback(): bool /** * Search for translated components in the select clause + * + * @param array> $queryComponents + * + * @phpstan-param array $queryComponents */ private function extractTranslatedComponents(array $queryComponents): void { @@ -430,6 +434,8 @@ private function getTranslatableListener(): TranslatableListener /** * Replaces given sql $str with required * results + * + * @param array $repl */ private function replace(array $repl, string $str): string { diff --git a/src/Translator/TranslationProxy.php b/src/Translator/TranslationProxy.php index a864411279..6f570db192 100644 --- a/src/Translator/TranslationProxy.php +++ b/src/Translator/TranslationProxy.php @@ -44,10 +44,10 @@ class TranslationProxy /** * Initializes translations collection * - * @param object $translatable object to translate - * @param string $locale translation name - * @param array $properties object properties to translate - * @param string $class translation entity|document class + * @param object $translatable object to translate + * @param string $locale translation name + * @param string[] $properties object properties to translate + * @param string $class translation entity|document class * * @throws \InvalidArgumentException Translation class doesn't implement TranslationInterface * @@ -68,8 +68,8 @@ public function __construct($translatable, $locale, array $properties, $class, C } /** - * @param string $method - * @param array $arguments + * @param string $method + * @param mixed[] $arguments * * @return mixed */ diff --git a/src/Tree/Document/MongoDB/Repository/AbstractTreeRepository.php b/src/Tree/Document/MongoDB/Repository/AbstractTreeRepository.php index 2e998fd00f..05484befed 100644 --- a/src/Tree/Document/MongoDB/Repository/AbstractTreeRepository.php +++ b/src/Tree/Document/MongoDB/Repository/AbstractTreeRepository.php @@ -139,10 +139,10 @@ abstract public function getRootNodesQuery($sortByField = null, $direction = 'as /** * Returns a QueryBuilder configured to return an array of nodes suitable for buildTree method * - * @param object $node Root node - * @param bool $direct Obtain direct children? - * @param array $options Options - * @param bool $includeNode Include node in results? + * @param object $node Root node + * @param bool $direct Obtain direct children? + * @param array $options Options + * @param bool $includeNode Include node in results? * * @return Builder */ @@ -151,10 +151,10 @@ abstract public function getNodesHierarchyQueryBuilder($node = null, $direct = f /** * Returns a Query configured to return an array of nodes suitable for buildTree method * - * @param object $node Root node - * @param bool $direct Obtain direct children? - * @param array $options Options - * @param bool $includeNode Include node in results? + * @param object $node Root node + * @param bool $direct Obtain direct children? + * @param array $options Options + * @param bool $includeNode Include node in results? * * @return Query */ diff --git a/src/Tree/Entity/Repository/AbstractTreeRepository.php b/src/Tree/Entity/Repository/AbstractTreeRepository.php index 4772424e21..1cebf62dda 100644 --- a/src/Tree/Entity/Repository/AbstractTreeRepository.php +++ b/src/Tree/Entity/Repository/AbstractTreeRepository.php @@ -185,10 +185,10 @@ abstract public function getRootNodesQuery($sortByField = null, $direction = 'as /** * Returns a QueryBuilder configured to return an array of nodes suitable for buildTree method * - * @param object $node Root node - * @param bool $direct Obtain direct children? - * @param array $options Options - * @param bool $includeNode Include node in results? + * @param object $node Root node + * @param bool $direct Obtain direct children? + * @param array $options Options + * @param bool $includeNode Include node in results? * * @return QueryBuilder QueryBuilder object */ @@ -197,10 +197,10 @@ abstract public function getNodesHierarchyQueryBuilder($node = null, $direct = f /** * Returns a Query configured to return an array of nodes suitable for buildTree method * - * @param object $node Root node - * @param bool $direct Obtain direct children? - * @param array $options Options - * @param bool $includeNode Include node in results? + * @param object $node Root node + * @param bool $direct Obtain direct children? + * @param array $options Options + * @param bool $includeNode Include node in results? * * @return Query Query object */ diff --git a/src/Tree/Entity/Repository/ClosureTreeRepository.php b/src/Tree/Entity/Repository/ClosureTreeRepository.php index 4cf4f568f4..b31490d3fa 100644 --- a/src/Tree/Entity/Repository/ClosureTreeRepository.php +++ b/src/Tree/Entity/Repository/ClosureTreeRepository.php @@ -632,7 +632,7 @@ protected function validate() } /** - * @param array $association + * @param array $association * * @return string|null */ diff --git a/src/Tree/Entity/Repository/NestedTreeRepository.php b/src/Tree/Entity/Repository/NestedTreeRepository.php index cd82be56e3..3038e13edf 100644 --- a/src/Tree/Entity/Repository/NestedTreeRepository.php +++ b/src/Tree/Entity/Repository/NestedTreeRepository.php @@ -1173,7 +1173,7 @@ protected function validate() * Collect errors on given tree if * where are any * - * @param $errors array + * @param array $errors */ private function verifyTree(array &$errors, ?object $root = null): void { diff --git a/src/Tree/Hydrator/ORM/TreeObjectHydrator.php b/src/Tree/Hydrator/ORM/TreeObjectHydrator.php index a9c4d0861a..20e39b5f90 100644 --- a/src/Tree/Hydrator/ORM/TreeObjectHydrator.php +++ b/src/Tree/Hydrator/ORM/TreeObjectHydrator.php @@ -150,7 +150,7 @@ protected function populateChildrenArray($nodes, $childrenHashmap) } /** - * @param array $nodes + * @param array $nodes * * @return array */ @@ -182,6 +182,8 @@ protected function getRootNodes($nodes) * [node1.id => true, node2.id => true, ...] * ``` * + * @param array $nodes + * * @return array */ protected function buildIdHashmap(array $nodes) @@ -267,7 +269,7 @@ protected function getTreeListener(EntityManagerInterface $em) } /** - * @param array $data + * @param array $data * * @return string */ diff --git a/src/Tree/Mapping/Validator.php b/src/Tree/Mapping/Validator.php index 2967a78101..323d00fa55 100644 --- a/src/Tree/Mapping/Validator.php +++ b/src/Tree/Mapping/Validator.php @@ -178,7 +178,8 @@ public function isValidFieldForRoot($meta, $field) /** * Validates metadata for nested type tree * - * @param ClassMetadata $meta + * @param ClassMetadata $meta + * @param array $config * * @throws InvalidMappingException * @@ -204,7 +205,8 @@ public function validateNestedTreeMetadata($meta, array $config) /** * Validates metadata for closure type tree * - * @param ClassMetadata $meta + * @param ClassMetadata $meta + * @param array $config * * @throws InvalidMappingException * @@ -227,7 +229,8 @@ public function validateClosureTreeMetadata($meta, array $config) /** * Validates metadata for materialized path type tree * - * @param ClassMetadata $meta + * @param ClassMetadata $meta + * @param array $config * * @throws InvalidMappingException * diff --git a/src/Tree/RepositoryInterface.php b/src/Tree/RepositoryInterface.php index c8376063a7..24eb6513d5 100644 --- a/src/Tree/RepositoryInterface.php +++ b/src/Tree/RepositoryInterface.php @@ -32,10 +32,10 @@ public function getRootNodes($sortByField = null, $direction = 'asc'); /** * Returns an array of nodes optimized for building a tree. * - * @param object $node Root node - * @param bool $direct Flag indicating whether only direct children should be retrieved - * @param array $options Options, see {@see RepositoryUtilsInterface::buildTree()} for supported keys - * @param bool $includeNode Flag indicating whether the given node should be included in the results + * @param object $node Root node + * @param bool $direct Flag indicating whether only direct children should be retrieved + * @param array $options Options, see {@see RepositoryUtilsInterface::buildTree()} for supported keys + * @param bool $includeNode Flag indicating whether the given node should be included in the results * * @return array */ diff --git a/src/Tree/RepositoryUtilsInterface.php b/src/Tree/RepositoryUtilsInterface.php index db5756fbb5..0dca508d19 100644 --- a/src/Tree/RepositoryUtilsInterface.php +++ b/src/Tree/RepositoryUtilsInterface.php @@ -18,17 +18,17 @@ interface RepositoryUtilsInterface * * Uses options to handle decorations * - * @param object|null $node The object to fetch children for; if null, all nodes will be retrieved - * @param bool $direct Flag indicating whether only direct children should be retrieved - * @param array $options Options configuring the output, supported keys include: - * - decorate: boolean (false) - retrieves the tree as an HTML `
    ` element - * - nodeDecorator: Closure (null) - uses $node as argument and returns the decorated item as a string - * - rootOpen: string || Closure ('
      ') - branch start, Closure will be given $children as a parameter - * - rootClose: string ('
    ') - branch close - * - childOpen: string || Closure ('
  • ') - start of node, Closure will be given $node as a parameter - * - childClose: string ('
  • ') - close of node - * - childSort: array || keys allowed: field: field to sort on, dir: direction. 'asc' or 'desc' - * @param bool $includeNode Flag indicating whether the given node should be included in the results + * @param object|null $node The object to fetch children for; if null, all nodes will be retrieved + * @param bool $direct Flag indicating whether only direct children should be retrieved + * @param array $options Options configuring the output, supported keys include: + * - decorate: boolean (false) - retrieves the tree as an HTML `
      ` element + * - nodeDecorator: Closure (null) - uses $node as argument and returns the decorated item as a string + * - rootOpen: string || Closure ('
        ') - branch start, Closure will be given $children as a parameter + * - rootClose: string ('
      ') - branch close + * - childOpen: string || Closure ('
    • ') - start of node, Closure will be given $node as a parameter + * - childClose: string ('
    • ') - close of node + * - childSort: array || keys allowed: field: field to sort on, dir: direction. 'asc' or 'desc' + * @param bool $includeNode Flag indicating whether the given node should be included in the results * * @return array>|string * @@ -44,7 +44,7 @@ public function childrenHierarchy($node = null, $direct = false, array $options * NOTE: nodes should be fetched and hydrated as array * * @param array $nodes The nodes to build the tree from - * @param array $options Options configuring the output, supported keys include: + * @param array $options Options configuring the output, supported keys include: * - decorate: boolean (false) - retrieves the tree as an HTML `
        ` element * - nodeDecorator: Closure (null) - uses $node as argument and returns the decorated item as a string * - rootOpen: string || Closure ('
          ') - branch start, Closure will be given $children as a parameter diff --git a/src/Tree/Strategy/ORM/Closure.php b/src/Tree/Strategy/ORM/Closure.php index 2774518983..45357810b3 100644 --- a/src/Tree/Strategy/ORM/Closure.php +++ b/src/Tree/Strategy/ORM/Closure.php @@ -447,7 +447,7 @@ public function updateNode(EntityManagerInterface $em, $node, $oldParent) } /** - * @param array $association + * @param array $association * * @return string|null */ diff --git a/src/Uploadable/UploadableListener.php b/src/Uploadable/UploadableListener.php index 40e7d74402..093f83518b 100644 --- a/src/Uploadable/UploadableListener.php +++ b/src/Uploadable/UploadableListener.php @@ -642,7 +642,8 @@ public function getMimeTypeGuesser() } /** - * @param object $object Entity + * @param array $config + * @param object $object Entity * * @return string * @@ -726,7 +727,8 @@ protected function getPropertyValueFromObject(ClassMetadata $meta, $propertyName /** * Returns the path of the entity's file * - * @param object $object + * @param array $config + * @param object $object * * @return string */ @@ -738,7 +740,8 @@ protected function getFilePathFieldValue(ClassMetadata $meta, array $config, $ob /** * Returns the name of the entity's file * - * @param object $object + * @param array $config + * @param object $object * * @return string */ diff --git a/tests/Gedmo/Mapping/Mock/Extension/Encoder/EncoderListener.php b/tests/Gedmo/Mapping/Mock/Extension/Encoder/EncoderListener.php index fad232e12f..ee333c4965 100644 --- a/tests/Gedmo/Mapping/Mock/Extension/Encoder/EncoderListener.php +++ b/tests/Gedmo/Mapping/Mock/Extension/Encoder/EncoderListener.php @@ -66,6 +66,9 @@ protected function getNamespace(): string return __NAMESPACE__; } + /** + * @param array $config + */ private function encode(EventAdapterInterface $ea, object $object, array $config): void { $om = $ea->getObjectManager(); diff --git a/tests/Gedmo/Tool/BaseTestCaseOM.php b/tests/Gedmo/Tool/BaseTestCaseOM.php index c702b8816c..ed99401378 100644 --- a/tests/Gedmo/Tool/BaseTestCaseOM.php +++ b/tests/Gedmo/Tool/BaseTestCaseOM.php @@ -71,7 +71,10 @@ protected function tearDown(): void } } - public function getMongoDBDriver(array $paths = []): MappingDriver + /** + * @param string[] $paths + */ + protected function getMongoDBDriver(array $paths = []): MappingDriver { if (PHP_VERSION_ID >= 80000 && class_exists(AttributeDriver::class)) { return new AttributeDriver($paths); @@ -80,7 +83,10 @@ public function getMongoDBDriver(array $paths = []): MappingDriver return new AnnotationDriverODM($_ENV['annotation_reader'], $paths); } - public function getORMDriver(array $paths = []): MappingDriver + /** + * @param string[] $paths + */ + protected function getORMDriver(array $paths = []): MappingDriver { if (PHP_VERSION_ID >= 80000) { return new AttributeDriverORM($paths); @@ -109,6 +115,10 @@ protected function getMockDocumentManager(string $dbName, ?MappingDriver $mappin * EntityManager mock object together with * annotation mapping driver and pdo_sqlite * database in memory + * + * @param string[] $fixtures + * + * @phpstan-assert class-string[] $fixtures */ protected function getDefaultMockSqliteEntityManager(array $fixtures, ?MappingDriver $mappingDriver = null): EntityManager { diff --git a/tests/Gedmo/Translatable/Fixture/Issue75/Article.php b/tests/Gedmo/Translatable/Fixture/Issue75/Article.php index af79dada39..a305e69031 100644 --- a/tests/Gedmo/Translatable/Fixture/Issue75/Article.php +++ b/tests/Gedmo/Translatable/Fixture/Issue75/Article.php @@ -86,6 +86,9 @@ public function addImage(Image $image): void $this->images[] = $image; } + /** + * @param array $images + */ public function setImages(array $images): void { foreach ($images as $img) { diff --git a/tests/Gedmo/Translatable/Fixture/Type/Custom.php b/tests/Gedmo/Translatable/Fixture/Type/Custom.php index c883ce9911..e390c44cde 100644 --- a/tests/Gedmo/Translatable/Fixture/Type/Custom.php +++ b/tests/Gedmo/Translatable/Fixture/Type/Custom.php @@ -19,6 +19,8 @@ class Custom extends Type private const NAME = 'custom'; /** + * @param mixed[] $fieldDeclaration + * * @return string */ public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) diff --git a/tests/Gedmo/Tree/MaterializedPathODMMongoDBRepositoryTest.php b/tests/Gedmo/Tree/MaterializedPathODMMongoDBRepositoryTest.php index 5ca4b1201f..74a637a19a 100644 --- a/tests/Gedmo/Tree/MaterializedPathODMMongoDBRepositoryTest.php +++ b/tests/Gedmo/Tree/MaterializedPathODMMongoDBRepositoryTest.php @@ -312,7 +312,7 @@ public function testChangeChildrenIndex(): void static::assertIsArray($tree[0][$childrenIndex]); } - public function createCategory(): Category + private function createCategory(): Category { $class = self::CATEGORY; diff --git a/tests/Gedmo/Tree/MaterializedPathODMMongoDBTest.php b/tests/Gedmo/Tree/MaterializedPathODMMongoDBTest.php index 88de3c794c..2ab145ae85 100644 --- a/tests/Gedmo/Tree/MaterializedPathODMMongoDBTest.php +++ b/tests/Gedmo/Tree/MaterializedPathODMMongoDBTest.php @@ -134,14 +134,17 @@ public function testUseOfSeparatorInPathSourceShouldThrowAnException(): void $this->dm->flush(); } - public function createCategory(): Category + private function createCategory(): Category { $class = self::CATEGORY; return new $class(); } - public function generatePath(array $sources): string + /** + * @param array $sources + */ + private function generatePath(array $sources): string { $path = ''; diff --git a/tests/Gedmo/Tree/MaterializedPathORMFeaturesTest.php b/tests/Gedmo/Tree/MaterializedPathORMFeaturesTest.php index 18fa5f6007..a85dbcc0d0 100644 --- a/tests/Gedmo/Tree/MaterializedPathORMFeaturesTest.php +++ b/tests/Gedmo/Tree/MaterializedPathORMFeaturesTest.php @@ -92,14 +92,24 @@ public function testCheckPathsAndHash(): void static::assertSame($category4->getTitle(), $category4->getTreeRootValue()); } - public function createCategory(): MPFeaturesCategory + protected function getUsedEntityFixtures(): array + { + return [ + self::CATEGORY, + ]; + } + + private function createCategory(): MPFeaturesCategory { $class = self::CATEGORY; return new $class(); } - public function generatePath(array $sources): string + /** + * @param array $sources + */ + private function generatePath(array $sources): string { $path = ''; foreach ($sources as $p => $id) { @@ -109,15 +119,11 @@ public function generatePath(array $sources): string return $path; } - public function generatePathHash(array $sources): string + /** + * @param array $sources + */ + private function generatePathHash(array $sources): string { return md5($this->generatePath($sources)); } - - protected function getUsedEntityFixtures(): array - { - return [ - self::CATEGORY, - ]; - } } diff --git a/tests/Gedmo/Tree/MaterializedPathORMRepositoryTest.php b/tests/Gedmo/Tree/MaterializedPathORMRepositoryTest.php index 33465aaaa2..9a95918498 100644 --- a/tests/Gedmo/Tree/MaterializedPathORMRepositoryTest.php +++ b/tests/Gedmo/Tree/MaterializedPathORMRepositoryTest.php @@ -365,10 +365,18 @@ public function testChangeChildrenIndex(): void static::assertIsArray($tree[0][$childrenIndex]); } + protected function getUsedEntityFixtures(): array + { + return [ + self::CATEGORY, + self::CATEGORY_WITH_TRIMMED_SEPARATOR, + ]; + } + /** * @phpstan-param class-string|null $class */ - public function createCategory(?string $class = null): object + private function createCategory(?string $class = null): object { if (!$class) { $class = self::CATEGORY; @@ -377,14 +385,6 @@ public function createCategory(?string $class = null): object return new $class(); } - protected function getUsedEntityFixtures(): array - { - return [ - self::CATEGORY, - self::CATEGORY_WITH_TRIMMED_SEPARATOR, - ]; - } - /** * @phpstan-param class-string|null $class */ diff --git a/tests/Gedmo/Tree/MaterializedPathORMRootAssociationTest.php b/tests/Gedmo/Tree/MaterializedPathORMRootAssociationTest.php index 809c8566ee..6331cc5a0f 100644 --- a/tests/Gedmo/Tree/MaterializedPathORMRootAssociationTest.php +++ b/tests/Gedmo/Tree/MaterializedPathORMRootAssociationTest.php @@ -129,14 +129,24 @@ public function testInsertUpdateAndRemove(): void static::assertSame($category4, $firstResult->getTreeRootEntity()); } - public function createCategory(): MPCategoryWithRootAssociation + protected function getUsedEntityFixtures(): array + { + return [ + self::CATEGORY, + ]; + } + + private function createCategory(): MPCategoryWithRootAssociation { $class = self::CATEGORY; return new $class(); } - public function generatePath(array $sources): string + /** + * @param array $sources + */ + private function generatePath(array $sources): string { $path = ''; @@ -146,11 +156,4 @@ public function generatePath(array $sources): string return $path; } - - protected function getUsedEntityFixtures(): array - { - return [ - self::CATEGORY, - ]; - } } diff --git a/tests/Gedmo/Tree/MaterializedPathORMTest.php b/tests/Gedmo/Tree/MaterializedPathORMTest.php index 839a820eb3..c825b5f83d 100644 --- a/tests/Gedmo/Tree/MaterializedPathORMTest.php +++ b/tests/Gedmo/Tree/MaterializedPathORMTest.php @@ -141,14 +141,24 @@ public function testUseOfSeparatorInPathSourceShouldThrowAnException(): void $this->em->flush(); } - public function createCategory(): MPCategory + protected function getUsedEntityFixtures(): array + { + return [ + self::CATEGORY, + ]; + } + + private function createCategory(): MPCategory { $class = self::CATEGORY; return new $class(); } - public function generatePath(array $sources): string + /** + * @param array $sources + */ + private function generatePath(array $sources): string { $path = ''; @@ -159,13 +169,6 @@ public function generatePath(array $sources): string return $path; } - protected function getUsedEntityFixtures(): array - { - return [ - self::CATEGORY, - ]; - } - private function getTreeRootValueOfRootNode(MPCategory $category): string { while (null !== $category->getParent()) { diff --git a/tests/Gedmo/Uploadable/UploadableEntityTest.php b/tests/Gedmo/Uploadable/UploadableEntityTest.php index 64b8791ba4..0940dffaf7 100644 --- a/tests/Gedmo/Uploadable/UploadableEntityTest.php +++ b/tests/Gedmo/Uploadable/UploadableEntityTest.php @@ -806,6 +806,8 @@ protected function assertPathEquals(string $expected, string $path, string $mess // Util /** + * @param array $info + * * @return array */ private function generateUploadedFile(?string $filePath = null, ?string $filename = null, array $info = []): array