diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 998834fc50..c6dd118b70 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -66,7 +66,7 @@ parameters: path: src/Loggable/LoggableListener.php - - message: "#^Method Gedmo\\\\Tool\\\\WrapperInterface\\\\:\\:getIdentifier\\(\\) invoked with 2 parameters, 0-1 required\\.#" + message: "#^Method Gedmo\\\\Tool\\\\WrapperInterface\\\\:\\:getIdentifier\\(\\) invoked with 2 parameters, 0\\-1 required\\.$#" count: 2 path: src/Loggable/LoggableListener.php @@ -360,21 +360,11 @@ parameters: count: 1 path: src/Timestampable/Mapping/Driver/Yaml.php - - - message: "#^PHPDoc tag \\@param references unknown parameter\\: \\$flatten$#" - count: 1 - path: src/Tool/WrapperInterface.php - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getUnitOfWork\\(\\)\\.$#" count: 1 path: src/Tool/Wrapper/EntityWrapper.php - - - message: "#^Method Gedmo\\\\Tool\\\\Wrapper\\\\EntityWrapper\\:\\:getIdentifier\\(\\) has parameter \\$flatten with no type specified\\.$#" - count: 1 - path: src/Tool/Wrapper/EntityWrapper.php - - message: "#^Parameter \\#2 \\$em of class Gedmo\\\\Tool\\\\Wrapper\\\\EntityWrapper constructor expects Doctrine\\\\ORM\\\\EntityManagerInterface, Doctrine\\\\Persistence\\\\ObjectManager given\\.$#" count: 1 @@ -390,11 +380,6 @@ parameters: count: 2 path: src/Tool/Wrapper/MongoDocumentWrapper.php - - - message: "#^Method Gedmo\\\\Tool\\\\Wrapper\\\\MongoDocumentWrapper\\:\\:getIdentifier\\(\\) has parameter \\$flatten with no type specified\\.$#" - count: 1 - path: src/Tool/Wrapper/MongoDocumentWrapper.php - - message: "#^Access to offset 'association' on an unknown class Doctrine\\\\ODM\\\\MongoDB\\\\Mapping\\\\FieldMapping\\.$#" count: 2 diff --git a/phpstan.neon.dist b/phpstan.neon.dist index c7e6bc0ab6..553d280e86 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,7 +4,7 @@ includes: - vendor/phpstan/phpstan-phpunit/extension.neon parameters: - level: 5 + level: 6 paths: - src - tests @@ -13,10 +13,15 @@ parameters: treatPhpDocTypesAsCertain: false checkMissingVarTagTypehint: true checkMissingTypehints: true + # @todo: Remove the "checkGenericClassInNonGenericObjectType" definition. + checkGenericClassInNonGenericObjectType: false ignoreErrors: - '#^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 - PHPStan\Rules\Functions\MissingFunctionParameterTypehintRule diff --git a/src/Loggable/Entity/MappedSuperclass/AbstractLogEntry.php b/src/Loggable/Entity/MappedSuperclass/AbstractLogEntry.php index fca72bd58a..0eed6757fd 100644 --- a/src/Loggable/Entity/MappedSuperclass/AbstractLogEntry.php +++ b/src/Loggable/Entity/MappedSuperclass/AbstractLogEntry.php @@ -81,7 +81,7 @@ abstract class AbstractLogEntry implements LogEntryInterface protected $version; /** - * @var array|null + * @var array|null * * @ORM\Column(type="array", nullable=true) */ @@ -108,8 +108,6 @@ public function getId() /** * Get action - * - * @return string|null */ public function getAction() { @@ -118,10 +116,6 @@ public function getAction() /** * Set action - * - * @param string $action - * - * @return void */ public function setAction($action) { @@ -130,8 +124,6 @@ public function setAction($action) /** * Get object class - * - * @return string|null */ public function getObjectClass() { @@ -140,10 +132,6 @@ public function getObjectClass() /** * Set object class - * - * @param string $objectClass - * - * @return void */ public function setObjectClass($objectClass) { @@ -152,8 +140,6 @@ public function setObjectClass($objectClass) /** * Get object id - * - * @return string|null */ public function getObjectId() { @@ -164,8 +150,6 @@ public function getObjectId() * Set object id * * @param string $objectId - * - * @return void */ public function setObjectId($objectId) { @@ -174,8 +158,6 @@ public function setObjectId($objectId) /** * Get username - * - * @return string|null */ public function getUsername() { @@ -186,8 +168,6 @@ public function getUsername() * Set username * * @param string $username - * - * @return void */ public function setUsername($username) { @@ -196,8 +176,6 @@ public function setUsername($username) /** * Get loggedAt - * - * @return \DateTime|null */ public function getLoggedAt() { @@ -206,8 +184,6 @@ public function getLoggedAt() /** * Set loggedAt to "now" - * - * @return void */ public function setLoggedAt() { @@ -216,8 +192,6 @@ public function setLoggedAt() /** * Get data - * - * @return array|null */ public function getData() { @@ -226,10 +200,6 @@ public function getData() /** * Set data - * - * @param array $data - * - * @return void */ public function setData($data) { @@ -240,8 +210,6 @@ public function setData($data) * Set current version * * @param int $version - * - * @return void */ public function setVersion($version) { @@ -250,8 +218,6 @@ public function setVersion($version) /** * Get current version - * - * @return int|null */ public function getVersion() { diff --git a/src/Mapping/Driver.php b/src/Mapping/Driver.php index 753fa51999..f0d42ef518 100644 --- a/src/Mapping/Driver.php +++ b/src/Mapping/Driver.php @@ -27,6 +27,7 @@ interface Driver * Read the extended metadata configuration for a single mapped class. * * @param ClassMetadata&(OdmClassMetadata|OrmClassMetadata) $meta + * @param array $config * * @return void * diff --git a/src/Mapping/Driver/AbstractAnnotationDriver.php b/src/Mapping/Driver/AbstractAnnotationDriver.php index a768e8137c..67bdcff207 100644 --- a/src/Mapping/Driver/AbstractAnnotationDriver.php +++ b/src/Mapping/Driver/AbstractAnnotationDriver.php @@ -116,6 +116,10 @@ protected function isValidField($meta, $field) * @param string $name the related object class name * * @return string related class name or empty string if does not exist + * + * @phpstan-param class-string|string $name + * + * @phpstan-return class-string|'' */ protected function getRelatedClassName($metadata, $name) { diff --git a/src/Mapping/Driver/File.php b/src/Mapping/Driver/File.php index 495accfebc..116bd1a8d0 100644 --- a/src/Mapping/Driver/File.php +++ b/src/Mapping/Driver/File.php @@ -103,7 +103,9 @@ public function setOriginalDriver($driver) * * @param string $file the mapping file to load * - * @return array + * @return array|object|null> + * + * @phpstan-return array|object|null> */ abstract protected function _loadMappingFile($file); @@ -112,7 +114,9 @@ abstract protected function _loadMappingFile($file); * * @param string $className * - * @return array|object|null + * @return array|object|null + * + * @phpstan-param class-string $className */ protected function _getMapping($className) { @@ -140,6 +144,10 @@ protected function _getMapping($className) * @param string $name the related object class name * * @return string related class name or empty string if does not exist + * + * @phpstan-param class-string|string $name + * + * @phpstan-return class-string|'' */ protected function getRelatedClassName($metadata, $name) { diff --git a/src/Mapping/Event/AdapterInterface.php b/src/Mapping/Event/AdapterInterface.php index 25bebb31c9..dcae65ab3e 100644 --- a/src/Mapping/Event/AdapterInterface.php +++ b/src/Mapping/Event/AdapterInterface.php @@ -92,7 +92,9 @@ public function getObjectState($uow, $object); * @param ORMUnitOfWork|MongoDBUnitOfWork $uow The UnitOfWork as provided by the object manager * @param object $object * - * @return array + * @return array|object> + * + * @phpstan-return array */ public function getObjectChangeSet($uow, $object); @@ -123,7 +125,7 @@ public function recomputeSingleObjectChangeSet($uow, $meta, $object); * * @param ORMUnitOfWork|MongoDBUnitOfWork $uow The UnitOfWork as provided by the object manager * - * @return array + * @return array */ public function getScheduledObjectUpdates($uow); @@ -132,7 +134,7 @@ public function getScheduledObjectUpdates($uow); * * @param ORMUnitOfWork|MongoDBUnitOfWork $uow The UnitOfWork as provided by the object manager * - * @return array + * @return array */ public function getScheduledObjectInsertions($uow); @@ -141,7 +143,7 @@ public function getScheduledObjectInsertions($uow); * * @param ORMUnitOfWork|MongoDBUnitOfWork $uow The UnitOfWork as provided by the object manager * - * @return array + * @return array */ public function getScheduledObjectDeletions($uow); diff --git a/src/Mapping/ExtensionMetadataFactory.php b/src/Mapping/ExtensionMetadataFactory.php index 6c9773cb67..2e239803f3 100644 --- a/src/Mapping/ExtensionMetadataFactory.php +++ b/src/Mapping/ExtensionMetadataFactory.php @@ -100,7 +100,7 @@ public function __construct(ObjectManager $objectManager, string $extensionNames * * @param ClassMetadata&(DocumentClassMetadata|EntityClassMetadata) $meta * - * @return array the metatada configuration + * @return array the metatada configuration */ public function getExtensionMetadata($meta) { diff --git a/src/ReferenceIntegrity/Mapping/Validator.php b/src/ReferenceIntegrity/Mapping/Validator.php index 183645e325..20281e79a0 100644 --- a/src/ReferenceIntegrity/Mapping/Validator.php +++ b/src/ReferenceIntegrity/Mapping/Validator.php @@ -38,7 +38,9 @@ class Validator /** * Returns a list of available integrity actions * - * @return array + * @return string[] + * + * @phpstan-return array */ public function getIntegrityActions() { diff --git a/src/References/Mapping/Event/ReferencesAdapter.php b/src/References/Mapping/Event/ReferencesAdapter.php index 907be0a0dc..9e46fad47d 100644 --- a/src/References/Mapping/Event/ReferencesAdapter.php +++ b/src/References/Mapping/Event/ReferencesAdapter.php @@ -28,7 +28,7 @@ interface ReferencesAdapter extends AdapterInterface * @param object $object * @param bool $single * - * @return array|string|int|null array or single identifier + * @return array|string|int|null array or single identifier */ public function getIdentifier($om, $object, $single = true); @@ -52,7 +52,7 @@ public function getSingleReference($om, $class, $identifier); * @param object $object * @param bool $single * - * @return array|string|int|null array or single identifier + * @return array|string|int|null array or single identifier */ public function extractIdentifier($om, $object, $single = true); } diff --git a/src/Sluggable/Mapping/Event/SluggableAdapter.php b/src/Sluggable/Mapping/Event/SluggableAdapter.php index ef7449e87b..b69cdc7742 100644 --- a/src/Sluggable/Mapping/Event/SluggableAdapter.php +++ b/src/Sluggable/Mapping/Event/SluggableAdapter.php @@ -30,7 +30,7 @@ interface SluggableAdapter extends AdapterInterface * @param string $slug * @phpstan-param SluggableConfiguration $config * - * @return array + * @return array> */ public function getSimilarSlugs($object, $meta, array $config, $slug); diff --git a/src/SoftDeleteable/Filter/ODM/SoftDeleteableFilter.php b/src/SoftDeleteable/Filter/ODM/SoftDeleteableFilter.php index 8ef4f00f4e..2a6aa7688f 100644 --- a/src/SoftDeleteable/Filter/ODM/SoftDeleteableFilter.php +++ b/src/SoftDeleteable/Filter/ODM/SoftDeleteableFilter.php @@ -39,7 +39,9 @@ class SoftDeleteableFilter extends BsonFilter /** * Gets the criteria part to add to a query. * - * @return array The criteria array, if there is available, empty array otherwise + * @return array|null>>|null> The criteria array, if there is available, empty array otherwise + * + * @phpstan-return array>|null> */ public function addFilterCriteria(ClassMetadata $targetEntity): array { @@ -96,7 +98,7 @@ public function enableForDocument($class) } /** - * @return SoftDeleteableListener|null + * @return SoftDeleteableListener */ protected function getListener() { diff --git a/src/Sortable/Entity/Repository/SortableRepository.php b/src/Sortable/Entity/Repository/SortableRepository.php index 13393eacbd..75e2367157 100644 --- a/src/Sortable/Entity/Repository/SortableRepository.php +++ b/src/Sortable/Entity/Repository/SortableRepository.php @@ -101,7 +101,7 @@ public function getBySortableGroupsQueryBuilder(array $groupValues = []) } /** - * @return array + * @return array */ public function getBySortableGroups(array $groupValues = []) { diff --git a/src/Sortable/Mapping/Driver/Yaml.php b/src/Sortable/Mapping/Driver/Yaml.php index 99a0aef30b..ba8a1cbb4e 100644 --- a/src/Sortable/Mapping/Driver/Yaml.php +++ b/src/Sortable/Mapping/Driver/Yaml.php @@ -98,6 +98,9 @@ protected function isValidField($meta, $field) return $mapping && in_array($mapping['type'], self::VALID_TYPES, true); } + /** + * @param iterable> $mapping + */ private function readSortableGroups(iterable $mapping, array &$config): void { foreach ($mapping as $field => $fieldMapping) { diff --git a/src/Sortable/Mapping/Event/Adapter/ORM.php b/src/Sortable/Mapping/Event/Adapter/ORM.php index ece9cc708c..1c6f292a18 100644 --- a/src/Sortable/Mapping/Event/Adapter/ORM.php +++ b/src/Sortable/Mapping/Event/Adapter/ORM.php @@ -112,6 +112,9 @@ public function updatePositions($relocation, $delta, $config) $q->getSingleScalarResult(); } + /** + * @param iterable $groups + */ private function addGroupWhere(QueryBuilder $qb, ClassMetadata $metadata, iterable $groups): void { $i = 1; diff --git a/src/Sortable/SortableListener.php b/src/Sortable/SortableListener.php index e85118fde0..fcaa737ddc 100644 --- a/src/Sortable/SortableListener.php +++ b/src/Sortable/SortableListener.php @@ -565,7 +565,7 @@ protected function persistRelocations(SortableAdapter $ea) } /** - * @param array $groups + * @param array $groups * * @return string */ @@ -668,11 +668,11 @@ protected function addRelocation($hash, $class, $groups, $start, $stop, $delta, } /** - * @param array $config - * @param ClassMetadata $meta - * @param object $object + * @param ClassMetadata $meta + * @param array> $config + * @param object $object * - * @return array + * @return array */ protected function getGroups($meta, $config, $object) { diff --git a/src/Tool/Logging/DBAL/QueryAnalyzer.php b/src/Tool/Logging/DBAL/QueryAnalyzer.php index 4178779024..c09f8a066a 100644 --- a/src/Tool/Logging/DBAL/QueryAnalyzer.php +++ b/src/Tool/Logging/DBAL/QueryAnalyzer.php @@ -187,6 +187,9 @@ public function getExecutionTimes() /** * Create the SQL with mapped parameters + * + * @param array|null $params + * @param array|null $types */ private function generateSql(string $sql, ?array $params, ?array $types): string { @@ -210,6 +213,11 @@ private function generateSql(string $sql, ?array $params, ?array $types): string /** * Get the converted parameter list + * + * @param array $params + * @param array $types + * + * @return array */ private function getConvertedParams(array $params, array $types): array { diff --git a/src/Tool/Wrapper/EntityWrapper.php b/src/Tool/Wrapper/EntityWrapper.php index fd557c0d5f..bb49bec115 100644 --- a/src/Tool/Wrapper/EntityWrapper.php +++ b/src/Tool/Wrapper/EntityWrapper.php @@ -30,7 +30,7 @@ class EntityWrapper extends AbstractWrapper /** * Entity identifier * - * @var array|null + * @var array|null */ private $identifier; @@ -78,6 +78,9 @@ public function getRootObjectName() return $this->meta->rootEntityName; } + /** + * @param bool $flatten + */ public function getIdentifier($single = true, $flatten = false) { $flatten = 1 < \func_num_args() && true === func_get_arg(1); diff --git a/src/Tool/Wrapper/MongoDocumentWrapper.php b/src/Tool/Wrapper/MongoDocumentWrapper.php index 6ff2d9a6e7..725772d4a8 100644 --- a/src/Tool/Wrapper/MongoDocumentWrapper.php +++ b/src/Tool/Wrapper/MongoDocumentWrapper.php @@ -28,7 +28,7 @@ class MongoDocumentWrapper extends AbstractWrapper /** * Document identifier * - * @var mixed + * @var string|null */ private $identifier; @@ -76,6 +76,11 @@ public function hasValidIdentifier() return (bool) $this->getIdentifier(); } + /** + * @param bool $flatten + * + * @return string + */ public function getIdentifier($single = true, $flatten = false) { if (!$this->identifier) { diff --git a/src/Tool/WrapperInterface.php b/src/Tool/WrapperInterface.php index 15004a51a7..0ee0939e55 100644 --- a/src/Tool/WrapperInterface.php +++ b/src/Tool/WrapperInterface.php @@ -75,13 +75,12 @@ public function getMetadata(); * Get the object identifier, single or composite. * * @param bool $single - * @param bool $flatten * - * @return array|mixed Array if a composite value, otherwise a single scalar + * @return array|mixed Array if a composite value, otherwise a single scalar * * @todo Uncomment the second parameter for 4.0 */ - public function getIdentifier($single = true/* , $flatten = false */); + public function getIdentifier($single = true/* , bool $flatten = false */); /** * Get the root object class name. diff --git a/src/Translatable/Document/Repository/TranslationRepository.php b/src/Translatable/Document/Repository/TranslationRepository.php index fa5cd1ade1..b3788167eb 100644 --- a/src/Translatable/Document/Repository/TranslationRepository.php +++ b/src/Translatable/Document/Repository/TranslationRepository.php @@ -111,7 +111,7 @@ public function translate($document, $field, $locale, $value) * * @param object $document * - * @return array list of translations in locale groups + * @return array> list of translations in locale groups */ public function findTranslations($document) { @@ -203,7 +203,7 @@ public function findObjectByTranslatedField($field, $value, $class) * * @param mixed $id primary key value of document * - * @return array + * @return array> */ public function findTranslationsByObjectId($id) { diff --git a/src/Translatable/Entity/Repository/TranslationRepository.php b/src/Translatable/Entity/Repository/TranslationRepository.php index 59db05d9f8..aa6f1f2fb8 100644 --- a/src/Translatable/Entity/Repository/TranslationRepository.php +++ b/src/Translatable/Entity/Repository/TranslationRepository.php @@ -116,7 +116,7 @@ public function translate($entity, $field, $locale, $value) * * @param object $entity Must implement Translatable * - * @return array list of translations in locale groups + * @return array> list of translations in locale groups */ public function findTranslations($entity) { @@ -199,7 +199,7 @@ public function findObjectByTranslatedField($field, $value, $class) * * @param mixed $id primary key value of an entity * - * @return array + * @return array> */ public function findTranslationsByObjectId($id) { diff --git a/src/Translatable/Mapping/Event/TranslatableAdapter.php b/src/Translatable/Mapping/Event/TranslatableAdapter.php index fc119ca352..be02f800cd 100644 --- a/src/Translatable/Mapping/Event/TranslatableAdapter.php +++ b/src/Translatable/Mapping/Event/TranslatableAdapter.php @@ -49,7 +49,7 @@ public function getDefaultTranslationClass(); * @phpstan-param class-string $translationClass * @phpstan-param class-string $objectClass * - * @return array + * @return array> */ public function loadTranslations($object, $translationClass, $locale, $objectClass); diff --git a/src/Tree/Document/MongoDB/Repository/MaterializedPathRepository.php b/src/Tree/Document/MongoDB/Repository/MaterializedPathRepository.php index b89468caeb..2b915aa68c 100644 --- a/src/Tree/Document/MongoDB/Repository/MaterializedPathRepository.php +++ b/src/Tree/Document/MongoDB/Repository/MaterializedPathRepository.php @@ -73,7 +73,7 @@ public function getRootNodesQuery($sortByField = null, $direction = 'asc') public function getRootNodes($sortByField = null, $direction = 'asc') { - return $this->getRootNodesQuery($sortByField, $direction)->execute(); + return $this->getRootNodesQuery($sortByField, $direction)->getIterator(); } public function childCount($node = null, $direct = false) @@ -137,7 +137,7 @@ public function getChildrenQueryBuilder($node = null, $direct = false, $sortByFi $qb->field($config['path'])->equals(new Regex($regex)); } - $qb->sort($sortByField ?? $config['path'], 'asc' === $direction ? 'asc' : 'desc'); + $qb->sort($sortByField ?? $config['path'], 'asc' === strtolower($direction) ? 'asc' : 'desc'); return $qb; } @@ -150,7 +150,7 @@ public function getChildrenQuery($node = null, $direct = false, $sortByField = n return $this->getChildrenQueryBuilder($node, $direct, $sortByField, $direction, $includeNode)->getQuery(); } - public function getChildren($node = null, $direct = false, $sortByField = null, $direction = 'asc', $includeNode = false) + public function getChildren($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false) { return $this->getChildrenQuery($node, $direct, $sortByField, $direction, $includeNode)->execute(); } diff --git a/src/Tree/Entity/Repository/AbstractTreeRepository.php b/src/Tree/Entity/Repository/AbstractTreeRepository.php index 3148e8141d..4772424e21 100644 --- a/src/Tree/Entity/Repository/AbstractTreeRepository.php +++ b/src/Tree/Entity/Repository/AbstractTreeRepository.php @@ -212,10 +212,12 @@ abstract public function getNodesHierarchyQuery($node = null, $direct = false, a * @param object|null $node If null, all tree nodes will be taken * @param bool $direct True to take only direct children * @param string|string[]|null $sortByField Field name or array of fields names to sort by - * @param string|string[] $direction Sort order ('ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements + * @param string|string[] $direction Sort order ('asc'|'desc'|'ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements * @param bool $includeNode Include the root node in results? * * @return QueryBuilder QueryBuilder object + * + * @phpstan-param 'asc'|'desc'|'ASC'|'DESC'|array $direction */ abstract public function getChildrenQueryBuilder($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false); @@ -225,10 +227,12 @@ abstract public function getChildrenQueryBuilder($node = null, $direct = false, * @param object|null $node If null, all tree nodes will be taken * @param bool $direct True to take only direct children * @param string|string[]|null $sortByField Field name or array of fields names to sort by - * @param string|string[] $direction Sort order ('ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements + * @param string|string[] $direction Sort order ('asc'|'desc'|'ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements * @param bool $includeNode Include the root node in results? * * @return Query Query object + * + * @phpstan-param 'asc'|'desc'|'ASC'|'DESC'|array $direction */ abstract public function getChildrenQuery($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false); diff --git a/src/Tree/Entity/Repository/ClosureTreeRepository.php b/src/Tree/Entity/Repository/ClosureTreeRepository.php index 2e38cf7820..f8568b5b3c 100644 --- a/src/Tree/Entity/Repository/ClosureTreeRepository.php +++ b/src/Tree/Entity/Repository/ClosureTreeRepository.php @@ -98,7 +98,7 @@ public function getPathQuery($node) * * @param object $node * - * @return array list of Nodes in path + * @return array list of Nodes in path */ public function getPath($node) { @@ -111,10 +111,12 @@ public function getPath($node) * @param object|null $node If null, all tree nodes will be taken * @param bool $direct True to take only direct children * @param string|string[]|null $sortByField Field name or array of fields names to sort by - * @param string|string[] $direction Sort order ('ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements + * @param string|string[] $direction Sort order ('asc'|'desc'|'ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements * @param bool $includeNode Include the root node in results? * * @return QueryBuilder QueryBuilder object + * + * @phpstan-param 'asc'|'desc'|'ASC'|'DESC'|array $direction */ public function childrenQueryBuilder($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false) { @@ -186,10 +188,12 @@ public function childrenQueryBuilder($node = null, $direct = false, $sortByField * @param object|null $node If null, all tree nodes will be taken * @param bool $direct True to take only direct children * @param string|string[]|null $sortByField Field name or array of fields names to sort by - * @param string|string[] $direction Sort order ('ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements + * @param string|string[] $direction Sort order ('asc'|'desc'|'ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements * @param bool $includeNode Include the root node in results? * * @return Query Query object + * + * @phpstan-param 'asc'|'desc'|'ASC'|'DESC'|array $direction */ public function childrenQuery($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false) { @@ -200,10 +204,12 @@ public function childrenQuery($node = null, $direct = false, $sortByField = null * @param object|null $node If null, all tree nodes will be taken * @param bool $direct True to take only direct children * @param string|string[]|null $sortByField Field name or array of fields names to sort by - * @param string|string[] $direction Sort order ('ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements + * @param string|string[] $direction Sort order ('asc'|'desc'|'ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements * @param bool $includeNode Include the root node in results? * - * @return array|null List of children or null on failure + * @return array List of children or null on failure + * + * @phpstan-param 'asc'|'desc'|'ASC'|'DESC'|array $direction */ public function children($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false) { @@ -227,6 +233,9 @@ public function getChildrenQuery($node = null, $direct = false, $sortByField = n return $this->childrenQuery($node, $direct, $sortByField, $direction, $includeNode); } + /** + * @return array + */ public function getChildren($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false) { return $this->children($node, $direct, $sortByField, $direction, $includeNode); @@ -306,14 +315,6 @@ public function removeFromTree($node) $node = null; } - /** - * Process nodes and produce an array with the - * structure of the tree - * - * @param array $nodes Array of nodes - * - * @return array Array with tree structure - */ public function buildTreeArray(array $nodes) { $meta = $this->getClassMetadata(); @@ -411,7 +412,7 @@ public function getNodesHierarchyQueryBuilder($node = null, $direct = false, arr } /** - * @return array|bool + * @return array|bool */ public function verify() { diff --git a/src/Tree/Entity/Repository/MaterializedPathRepository.php b/src/Tree/Entity/Repository/MaterializedPathRepository.php index ce1e846358..291a767772 100644 --- a/src/Tree/Entity/Repository/MaterializedPathRepository.php +++ b/src/Tree/Entity/Repository/MaterializedPathRepository.php @@ -33,7 +33,7 @@ class MaterializedPathRepository extends AbstractTreeRepository */ public function getTreeQueryBuilder($rootNode = null) { - return $this->getChildrenQueryBuilder($rootNode, false, null, 'asc', true); + return $this->getChildrenQueryBuilder($rootNode, false, null, 'ASC', true); } /** @@ -53,7 +53,7 @@ public function getTreeQuery($rootNode = null) * * @param object $rootNode * - * @return array + * @return array */ public function getTree($rootNode = null) { @@ -138,14 +138,14 @@ public function getPathQuery($node) * * @param object $node * - * @return array list of Nodes in path + * @return array list of Nodes in path */ public function getPath($node) { return $this->getPathQuery($node)->getResult(); } - public function getChildrenQueryBuilder($node = null, $direct = false, $sortByField = null, $direction = 'asc', $includeNode = false) + public function getChildrenQueryBuilder($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false) { $meta = $this->getClassMetadata(); $config = $this->listener->getConfiguration($this->_em, $meta->getName()); @@ -206,18 +206,18 @@ public function getChildrenQueryBuilder($node = null, $direct = false, $sortByFi } $orderByField = null === $sortByField ? $alias.'.'.$config['path'] : $alias.'.'.$sortByField; - $orderByDir = 'asc' === $direction ? 'asc' : 'desc'; + $orderByDir = 'asc' === strtolower($direction) ? 'asc' : 'desc'; $qb->orderBy($orderByField, $orderByDir); return $qb; } - public function getChildrenQuery($node = null, $direct = false, $sortByField = null, $direction = 'asc', $includeNode = false) + public function getChildrenQuery($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false) { return $this->getChildrenQueryBuilder($node, $direct, $sortByField, $direction, $includeNode)->getQuery(); } - public function getChildren($node = null, $direct = false, $sortByField = null, $direction = 'asc', $includeNode = false) + public function getChildren($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false) { return $this->getChildrenQuery($node, $direct, $sortByField, $direction, $includeNode)->execute(); } diff --git a/src/Tree/Entity/Repository/NestedTreeRepository.php b/src/Tree/Entity/Repository/NestedTreeRepository.php index 8fc45996f4..cd82be56e3 100644 --- a/src/Tree/Entity/Repository/NestedTreeRepository.php +++ b/src/Tree/Entity/Repository/NestedTreeRepository.php @@ -308,10 +308,12 @@ public function getPathAsString(object $node, array $options = []): string * @param object|null $node If null, all tree nodes will be taken * @param bool $direct True to take only direct children * @param string|string[]|null $sortByField Field name or array of fields names to sort by - * @param string|string[] $direction Sort order ('ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements + * @param string|string[] $direction Sort order ('asc'|'desc'|'ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements * @param bool $includeNode Include the root node in results? * * @return QueryBuilder QueryBuilder object + * + * @phpstan-param 'asc'|'desc'|'ASC'|'DESC'|array $direction */ public function childrenQueryBuilder($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false) { @@ -382,10 +384,12 @@ public function childrenQueryBuilder($node = null, $direct = false, $sortByField * @param object|null $node if null, all tree nodes will be taken * @param bool $direct true to take only direct children * @param string|string[]|null $sortByField Field name or array of fields names to sort by - * @param string|string[] $direction Sort order ('ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements + * @param string|string[] $direction Sort order ('asc'|'desc'|'ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements * @param bool $includeNode Include the root node in results? * * @return Query Query object + * + * @phpstan-param 'asc'|'desc'|'ASC'|'DESC'|array $direction */ public function childrenQuery($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false) { @@ -396,10 +400,12 @@ public function childrenQuery($node = null, $direct = false, $sortByField = null * @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 string|string[]|null $sortByField Field name or array of fields names to sort by - * @param string|string[] $direction Sort order ('ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements + * @param string|string[] $direction Sort order ('asc'|'desc'|'ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements * @param bool $includeNode Flag indicating whether the given node should be included in the results * - * @return array|null List of children or null on failure + * @return array List of children + * + * @phpstan-param 'asc'|'desc'|'ASC'|'DESC'|array $direction */ public function children($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false) { @@ -408,15 +414,6 @@ public function children($node = null, $direct = false, $sortByField = null, $di return $q->getResult(); } - /** - * @param object|null $node if null, all tree nodes will be taken - * @param bool $direct true to take only direct children - * @param string|string[]|null $sortByField Field name or array of fields names to sort by - * @param string|string[] $direction Sort order ('ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements - * @param bool $includeNode Include the root node in results? - * - * @return QueryBuilder Query object - */ public function getChildrenQueryBuilder($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false) { return $this->childrenQueryBuilder($node, $direct, $sortByField, $direction, $includeNode); @@ -427,6 +424,9 @@ public function getChildrenQuery($node = null, $direct = false, $sortByField = n return $this->childrenQuery($node, $direct, $sortByField, $direction, $includeNode); } + /** + * @return array + */ public function getChildren($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false) { return $this->children($node, $direct, $sortByField, $direction, $includeNode); @@ -442,6 +442,8 @@ public function getChildren($node = null, $direct = false, $sortByField = null, * @throws InvalidArgumentException if input is not valid * * @return QueryBuilder + * + * @phpstan-param 'asc'|'desc'|'ASC'|'DESC' $direction */ public function getLeafsQueryBuilder($root = null, $sortByField = null, $direction = 'ASC') { @@ -494,6 +496,8 @@ public function getLeafsQueryBuilder($root = null, $sortByField = null, $directi * @param string $direction sort direction : "ASC" or "DESC" * * @return Query + * + * @phpstan-param 'asc'|'desc'|'ASC'|'DESC' $direction */ public function getLeafsQuery($root = null, $sortByField = null, $direction = 'ASC') { @@ -507,7 +511,9 @@ public function getLeafsQuery($root = null, $sortByField = null, $direction = 'A * @param string $sortByField field name to sort by * @param string $direction sort direction : "ASC" or "DESC" * - * @return array + * @return array + * + * @phpstan-param 'asc'|'desc'|'ASC'|'DESC' $direction */ public function getLeafs($root = null, $sortByField = null, $direction = 'ASC') { @@ -587,7 +593,7 @@ public function getNextSiblingsQuery($node, $includeSelf = false) * @param object $node * @param bool $includeSelf include the node itself * - * @return array + * @return array */ public function getNextSiblings($node, $includeSelf = false) { @@ -666,7 +672,7 @@ public function getPrevSiblingsQuery($node, $includeSelf = false) * @param object $node * @param bool $includeSelf include the node itself * - * @return array + * @return array */ public function getPrevSiblings($node, $includeSelf = false) { @@ -931,7 +937,7 @@ public function reorderAll($sortByField = null, $direction = 'ASC', $verify = tr * options: * - treeRootNode: (object) Optional tree root node to verify, if not the whole forest (only available for forests, not for single trees). * - * @return array|bool true on success, error list on failure + * @return array|bool true on success, error list on failure */ public function verify(/* array $options = [] */) // @phpstan-ignore-line { @@ -1166,6 +1172,8 @@ protected function validate() /** * Collect errors on given tree if * where are any + * + * @param $errors array */ 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 5389b9152c..a9c4d0861a 100644 --- a/src/Tree/Hydrator/ORM/TreeObjectHydrator.php +++ b/src/Tree/Hydrator/ORM/TreeObjectHydrator.php @@ -61,7 +61,7 @@ public function setPropertyValue($object, $property, $value) /** * We hook into the `hydrateAllData` to map the children collection of the entity * - * @return mixed[] + * @return array */ protected function hydrateAllData() { @@ -93,9 +93,9 @@ protected function hydrateAllData() * [parentId => [child1, child2, ...], ...] * ``` * - * @param array $nodes + * @param array $nodes * - * @return array + * @return array> */ protected function buildChildrenHashmap($nodes) { @@ -116,8 +116,8 @@ protected function buildChildrenHashmap($nodes) } /** - * @param array $nodes - * @param array $childrenHashmap + * @param array $nodes + * @param array> $childrenHashmap * * @return void */ @@ -152,7 +152,7 @@ protected function populateChildrenArray($nodes, $childrenHashmap) /** * @param array $nodes * - * @return array + * @return array */ protected function getRootNodes($nodes) { @@ -182,7 +182,7 @@ protected function getRootNodes($nodes) * [node1.id => true, node2.id => true, ...] * ``` * - * @return array + * @return array */ protected function buildIdHashmap(array $nodes) { diff --git a/src/Tree/RepositoryInterface.php b/src/Tree/RepositoryInterface.php index 2440d27efd..56796e88f5 100644 --- a/src/Tree/RepositoryInterface.php +++ b/src/Tree/RepositoryInterface.php @@ -25,7 +25,7 @@ interface RepositoryInterface extends RepositoryUtilsInterface * @param string $sortByField * @param string $direction * - * @return array + * @return iterable */ public function getRootNodes($sortByField = null, $direction = 'asc'); @@ -37,7 +37,7 @@ public function getRootNodes($sortByField = null, $direction = 'asc'); * @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 + * @return array */ public function getNodesHierarchy($node = null, $direct = false, array $options = [], $includeNode = false); @@ -47,10 +47,12 @@ public function getNodesHierarchy($node = null, $direct = false, array $options * @param object|null $node If null, all tree nodes will be taken * @param bool $direct True to take only direct children * @param string|string[]|null $sortByField Field name or array of fields names to sort by - * @param string|string[] $direction Sort order ('ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements + * @param string|string[] $direction Sort order ('asc'|'desc'|'ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements * @param bool $includeNode Include the root node in results? * - * @return array|null List of children or null on failure + * @return array List of children + * + * @phpstan-param 'asc'|'desc'|'ASC'|'DESC'|array $direction */ public function getChildren($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false); diff --git a/src/Tree/RepositoryUtilsInterface.php b/src/Tree/RepositoryUtilsInterface.php index 7f1f4779ac..796f39c859 100644 --- a/src/Tree/RepositoryUtilsInterface.php +++ b/src/Tree/RepositoryUtilsInterface.php @@ -21,16 +21,16 @@ interface RepositoryUtilsInterface * @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' + * - 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 + * @return array>|string * * @throws InvalidArgumentException */ @@ -43,16 +43,16 @@ public function childrenHierarchy($node = null, $direct = false, array $options * * NOTE: nodes should be fetched and hydrated as array * - * @param object[] $nodes The nodes to build the tree from - * @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 + * @param array $nodes The nodes to build the tree from + * @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 * - * @return array|string + * @return array>|string * * @throws InvalidArgumentException */ @@ -63,7 +63,7 @@ public function buildTree(array $nodes, array $options = []); * * @param object[] $nodes The nodes to build the tree from * - * @return array + * @return array> */ public function buildTreeArray(array $nodes); diff --git a/src/Tree/Strategy/AbstractMaterializedPath.php b/src/Tree/Strategy/AbstractMaterializedPath.php index 40e898b353..cf81877273 100644 --- a/src/Tree/Strategy/AbstractMaterializedPath.php +++ b/src/Tree/Strategy/AbstractMaterializedPath.php @@ -467,7 +467,7 @@ abstract public function removeNode($om, $meta, $config, $node); * @param array $config config * @param string $originalPath original path of object * - * @return array|\Traversable + * @return array|\Traversable */ abstract public function getChildren($om, $meta, $config, $originalPath); diff --git a/src/Uploadable/UploadableListener.php b/src/Uploadable/UploadableListener.php index 928e042f11..40e7d74402 100644 --- a/src/Uploadable/UploadableListener.php +++ b/src/Uploadable/UploadableListener.php @@ -381,7 +381,7 @@ public function removeFile($filePath) * @param bool $appendNumber * @param object $object * - * @return array + * @return array * * @throws UploadableUploadException * @throws UploadableNoFileException diff --git a/tests/Gedmo/Mapping/Annotation/AnnotationArgumentsTest.php b/tests/Gedmo/Mapping/Annotation/AnnotationArgumentsTest.php index d7569a9bcd..691d9b7dca 100644 --- a/tests/Gedmo/Mapping/Annotation/AnnotationArgumentsTest.php +++ b/tests/Gedmo/Mapping/Annotation/AnnotationArgumentsTest.php @@ -46,6 +46,9 @@ public function testArguments(array $expected, string $class, array $args, ?stri } } + /** + * @phpstan-return iterable, 1: class-string, 2: array|string>, 3?: string}> + */ public static function getGedmoAnnotations(): iterable { yield 'args_without_data' => [['on' => 'delete', 'field' => 'some'], Blameable::class, [[], 'delete', 'some']]; diff --git a/tests/Gedmo/Mapping/Annotation/BaseClassAnnotationTestCase.php b/tests/Gedmo/Mapping/Annotation/BaseClassAnnotationTestCase.php index 9e49e9d8e2..dbd8c86d02 100644 --- a/tests/Gedmo/Mapping/Annotation/BaseClassAnnotationTestCase.php +++ b/tests/Gedmo/Mapping/Annotation/BaseClassAnnotationTestCase.php @@ -40,6 +40,9 @@ public function testLoadFromDoctrineAnnotation(string $annotationProperty, $expe static::assertSame($annotation->$annotationProperty, $expectedReturn); } + /** + * @phpstan-return iterable + */ abstract public static function getValidParameters(): iterable; abstract protected function getAnnotationClass(): string; diff --git a/tests/Gedmo/Mapping/Annotation/BasePropertyAnnotationTestCase.php b/tests/Gedmo/Mapping/Annotation/BasePropertyAnnotationTestCase.php index ff08e67e3a..f4e124814b 100644 --- a/tests/Gedmo/Mapping/Annotation/BasePropertyAnnotationTestCase.php +++ b/tests/Gedmo/Mapping/Annotation/BasePropertyAnnotationTestCase.php @@ -40,6 +40,9 @@ public function testLoadFromDoctrineAnnotation(string $annotationProperty, strin static::assertSame($annotation->$annotationProperty, $expectedReturn); } + /** + * @phpstan-return iterable + */ abstract public function getValidParameters(): iterable; abstract protected function getAnnotationClass(): string; diff --git a/tests/Gedmo/Mapping/MappingEventSubscriberTest.php b/tests/Gedmo/Mapping/MappingEventSubscriberTest.php index b5ed2bf7f6..d3851ad8cf 100644 --- a/tests/Gedmo/Mapping/MappingEventSubscriberTest.php +++ b/tests/Gedmo/Mapping/MappingEventSubscriberTest.php @@ -21,7 +21,6 @@ use Gedmo\Tests\Mapping\Fixture\Sluggable; use Gedmo\Tests\Mapping\Fixture\SuperClassExtension; use Gedmo\Tests\Mapping\Mock\Extension\Encoder\EncoderListener; -use Gedmo\Tests\SoftDeleteable\Fixture\Entity\MappedSuperclass; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -112,12 +111,4 @@ public function testGetMetadataFactoryCacheFromDoctrineForSuperClassExtension(): ], ], $config['encode']); } - - protected function getUsedEntityFixtures(): array - { - return [ - Sluggable::class, - MappedSuperclass::class, - ]; - } } diff --git a/tests/Gedmo/Tool/BaseTestCaseORM.php b/tests/Gedmo/Tool/BaseTestCaseORM.php index 1cea88094c..a1d534b4d8 100644 --- a/tests/Gedmo/Tool/BaseTestCaseORM.php +++ b/tests/Gedmo/Tool/BaseTestCaseORM.php @@ -117,6 +117,8 @@ protected function getMetadataDriverImplementation(): MappingDriver /** * Get a list of used fixture classes * + * @return array + * * @phpstan-return list */ abstract protected function getUsedEntityFixtures(): array; diff --git a/tests/Gedmo/Tool/QueryAnalyzer.php b/tests/Gedmo/Tool/QueryAnalyzer.php index 19bcd5958e..0b6477ee07 100644 --- a/tests/Gedmo/Tool/QueryAnalyzer.php +++ b/tests/Gedmo/Tool/QueryAnalyzer.php @@ -70,6 +70,9 @@ public function getNumExecutedQueries(): int /** * Create the SQL with mapped parameters + * + * @param array|null $params + * @param array|null $types */ private function generateSql(string $sql, ?array $params, ?array $types): string { @@ -93,6 +96,11 @@ private function generateSql(string $sql, ?array $params, ?array $types): string /** * Get the converted parameter list + * + * @param array $params + * @param array $types + * + * @return array */ private function getConvertedParams(array $params, array $types): array { diff --git a/tests/Gedmo/Translatable/Issue/Issue173Test.php b/tests/Gedmo/Translatable/Issue/Issue173Test.php index 9887c1301d..f8bae82598 100644 --- a/tests/Gedmo/Translatable/Issue/Issue173Test.php +++ b/tests/Gedmo/Translatable/Issue/Issue173Test.php @@ -66,7 +66,20 @@ public function testIssue173(): void static::assertCount(1, $categories, '$category3 has no associations'); } - public function getCategoriesThatHasNoAssociations(): array + protected function getUsedEntityFixtures(): array + { + return [ + self::CATEGORY, + self::ARTICLE, + self::PRODUCT, + self::TRANSLATION, + ]; + } + + /** + * @return array + */ + private function getCategoriesThatHasNoAssociations(): array { $query = $this->em->createQueryBuilder(); $query2 = $this->em->createQueryBuilder(); @@ -96,16 +109,6 @@ public function getCategoriesThatHasNoAssociations(): array )->getResult(); } - protected function getUsedEntityFixtures(): array - { - return [ - self::CATEGORY, - self::ARTICLE, - self::PRODUCT, - self::TRANSLATION, - ]; - } - private function populate(): void { // Categories diff --git a/tests/Gedmo/Tree/ClosureTreeTest.php b/tests/Gedmo/Tree/ClosureTreeTest.php index aa9b14cdd1..1071052115 100644 --- a/tests/Gedmo/Tree/ClosureTreeTest.php +++ b/tests/Gedmo/Tree/ClosureTreeTest.php @@ -22,6 +22,7 @@ use Gedmo\Tests\Tree\Fixture\Closure\Person; use Gedmo\Tests\Tree\Fixture\Closure\PersonClosure; use Gedmo\Tests\Tree\Fixture\Closure\User; +use Gedmo\Tree\Entity\MappedSuperclass\AbstractClosure; use Gedmo\Tree\Strategy\ORM\Closure; use Gedmo\Tree\TreeListener; @@ -333,6 +334,9 @@ public function testClosuresCreatedMustNotBeAffectedByPersistOrder(Category $fir static::assertCount(6, $closures); } + /** + * @return array> + */ public static function provideNodeOrders(): array { $grandpa = new Category(); @@ -370,6 +374,9 @@ protected function getUsedEntityFixtures(): array ]; } + /** + * @param iterable $closures + */ private function hasAncestor(iterable $closures, string $name): bool { foreach ($closures as $closure) { diff --git a/tests/Gedmo/Tree/MaterializedPathODMMongoDBRepositoryTest.php b/tests/Gedmo/Tree/MaterializedPathODMMongoDBRepositoryTest.php index 782495bc4d..5ca4b1201f 100644 --- a/tests/Gedmo/Tree/MaterializedPathODMMongoDBRepositoryTest.php +++ b/tests/Gedmo/Tree/MaterializedPathODMMongoDBRepositoryTest.php @@ -319,13 +319,6 @@ public function createCategory(): Category return new $class(); } - protected function getUsedEntityFixtures(): array - { - return [ - self::CATEGORY, - ]; - } - private function populate(): void { $root = $this->createCategory(); diff --git a/tests/Gedmo/Tree/NestedTreeRootRepositoryTest.php b/tests/Gedmo/Tree/NestedTreeRootRepositoryTest.php index 8eca517867..4e8dd48a4b 100644 --- a/tests/Gedmo/Tree/NestedTreeRootRepositoryTest.php +++ b/tests/Gedmo/Tree/NestedTreeRootRepositoryTest.php @@ -257,6 +257,9 @@ public function testGetPathAsStringWithInvalidStringMethod($stringMethod): void ]); } + /** + * @phpstan-return iterable + */ public static function invalidStringMethods(): iterable { yield [null]; diff --git a/tests/Gedmo/Uploadable/UploadableEntityTest.php b/tests/Gedmo/Uploadable/UploadableEntityTest.php index 4ba12ea216..64b8791ba4 100644 --- a/tests/Gedmo/Uploadable/UploadableEntityTest.php +++ b/tests/Gedmo/Uploadable/UploadableEntityTest.php @@ -15,6 +15,7 @@ use Gedmo\Exception\InvalidArgumentException; use Gedmo\Exception\UploadableCantWriteException; use Gedmo\Exception\UploadableCouldntGuessMimeTypeException; +use Gedmo\Exception\UploadableException; use Gedmo\Exception\UploadableExtensionException; use Gedmo\Exception\UploadableFileAlreadyExistsException; use Gedmo\Exception\UploadableFormSizeException; @@ -512,6 +513,9 @@ public function testRemoveFileIfItsNotAFileThenReturnFalse(): void static::assertFalse($this->listener->removeFile('non_existent_file')); } + /** + * @return array> + */ public static function dataProvider_testMoveFileUsingAppendNumberOptionAppendsNumberToFilenameIfItAlreadyExists(): array { return [ @@ -741,6 +745,10 @@ public function testUseGeneratedFilenameWhenAppendingNumbers(): void } // Data Providers + + /** + * @return array> + */ public static function invalidFileInfoClassesProvider(): array { return [ @@ -753,6 +761,11 @@ public static function invalidFileInfoClassesProvider(): array ]; } + /** + * @return array> + * + * @phpstan-return array>> + */ public static function uploadExceptionsProvider(): array { return [ @@ -792,6 +805,9 @@ protected function assertPathEquals(string $expected, string $path, string $mess // Util + /** + * @return array + */ private function generateUploadedFile(?string $filePath = null, ?string $filename = null, array $info = []): array { $defaultInfo = [