From cf6a241e5e1c2f716ba7bc29c662fe5b0ddcf784 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Wed, 8 May 2024 20:45:44 +0200 Subject: [PATCH] Add BC typehint --- src/Admin/AbstractAdmin.php | 2 +- src/Datagrid/DatagridMapper.php | 8 +++++--- src/Datagrid/ListMapper.php | 12 ++++++++---- src/Datagrid/ProxyQueryInterface.php | 8 ++++---- src/FieldDescription/BaseFieldDescription.php | 15 +++++---------- src/Filter/Filter.php | 6 +++--- src/Filter/Model/FilterData.php | 5 +---- .../Field/Type/FormTypeFieldExtension.php | 4 +--- src/Mapper/BaseGroupedMapper.php | 18 +++++++++--------- src/Mapper/MapperInterface.php | 4 ++-- src/Object/Metadata.php | 2 +- src/Route/RouteCollection.php | 17 ++++++----------- src/Route/RouteCollectionInterface.php | 12 ++++++------ src/Security/Handler/AclSecurityHandler.php | 4 ++-- src/Show/ShowMapper.php | 8 +++++--- src/SonataConfiguration.php | 5 +---- src/Twig/Extension/RenderElementExtension.php | 4 +--- src/Twig/Extension/SonataAdminExtension.php | 2 +- src/Twig/RenderElementRuntime.php | 4 +--- src/Util/AdminObjectAclData.php | 15 ++++++++++++--- src/Util/AdminObjectAclManipulator.php | 2 -- tests/App/Datagrid/ProxyQuery.php | 10 +++++----- .../App/FieldDescription/FieldDescription.php | 10 +--------- tests/App/Model/ModelManager.php | 2 +- tests/App/Model/RepositoryInterface.php | 2 +- tests/Datagrid/PagerTest.php | 4 +--- .../BaseFieldDescriptionTest.php | 4 +--- tests/Form/DataTransformerResolverTest.php | 2 +- tests/Twig/CanonicalizeRuntimeTest.php | 4 ++-- .../Extension/CanonicalizeExtensionTest.php | 4 ++-- 30 files changed, 90 insertions(+), 109 deletions(-) diff --git a/src/Admin/AbstractAdmin.php b/src/Admin/AbstractAdmin.php index 5708dee7b0..98e653519a 100644 --- a/src/Admin/AbstractAdmin.php +++ b/src/Admin/AbstractAdmin.php @@ -1413,7 +1413,7 @@ final public function getPersistentParameters(): array return $parameters; } - final public function getPersistentParameter(string $name, mixed $default = null) + final public function getPersistentParameter(string $name, mixed $default = null): mixed { $parameters = $this->getPersistentParameters(); diff --git a/src/Datagrid/DatagridMapper.php b/src/Datagrid/DatagridMapper.php index 1b612b9f46..ecd65fcd3e 100644 --- a/src/Datagrid/DatagridMapper.php +++ b/src/Datagrid/DatagridMapper.php @@ -54,6 +54,8 @@ public function getAdmin(): AdminInterface * * @throws \LogicException * + * @return $this + * * @phpstan-param class-string|null $type * @phpstan-param FieldDescriptionOptions $fieldDescriptionOptions */ @@ -62,7 +64,7 @@ public function add( ?string $type = null, array $filterOptions = [], array $fieldDescriptionOptions = [] - ): static { + ): self { if ( isset($fieldDescriptionOptions['role']) && \is_string($fieldDescriptionOptions['role']) @@ -107,7 +109,7 @@ public function keys(): array return array_keys($this->datagrid->getFilters()); } - public function remove(string $key): static + public function remove(string $key): self { $this->getAdmin()->removeFilterFieldDescription($key); $this->datagrid->removeFilter($key); @@ -115,7 +117,7 @@ public function remove(string $key): static return $this; } - public function reorder(array $keys): static + public function reorder(array $keys): self { $this->datagrid->reorderFilters($keys); diff --git a/src/Datagrid/ListMapper.php b/src/Datagrid/ListMapper.php index 940f20274c..41b47d6388 100644 --- a/src/Datagrid/ListMapper.php +++ b/src/Datagrid/ListMapper.php @@ -60,9 +60,11 @@ public function getAdmin(): AdminInterface /** * @param array $fieldDescriptionOptions * + * @return $this + * * @phpstan-param FieldDescriptionOptions $fieldDescriptionOptions */ - public function addIdentifier(string $name, ?string $type = null, array $fieldDescriptionOptions = []): static + public function addIdentifier(string $name, ?string $type = null, array $fieldDescriptionOptions = []): self { $fieldDescriptionOptions['identifier'] = true; @@ -74,9 +76,11 @@ public function addIdentifier(string $name, ?string $type = null, array $fieldDe * * @throws \LogicException * + * @return $this + * * @phpstan-param FieldDescriptionOptions $fieldDescriptionOptions */ - public function add(string $name, ?string $type = null, array $fieldDescriptionOptions = []): static + public function add(string $name, ?string $type = null, array $fieldDescriptionOptions = []): self { if ( isset($fieldDescriptionOptions['role']) @@ -151,7 +155,7 @@ public function has(string $key): bool return $this->list->has($key); } - public function remove(string $key): static + public function remove(string $key): self { $this->getAdmin()->removeListFieldDescription($key); $this->list->remove($key); @@ -164,7 +168,7 @@ public function keys(): array return array_keys($this->list->getElements()); } - public function reorder(array $keys): static + public function reorder(array $keys): self { $this->list->reorder($keys); diff --git a/src/Datagrid/ProxyQueryInterface.php b/src/Datagrid/ProxyQueryInterface.php index 52749fdc73..4d95cc1856 100644 --- a/src/Datagrid/ProxyQueryInterface.php +++ b/src/Datagrid/ProxyQueryInterface.php @@ -33,28 +33,28 @@ public function execute(); * @param array> $parentAssociationMappings * @param array $fieldMapping * - * @return static + * @return $this */ public function setSortBy(array $parentAssociationMappings, array $fieldMapping): self; public function getSortBy(): ?string; /** - * @return static + * @return $this */ public function setSortOrder(string $sortOrder): self; public function getSortOrder(): ?string; /** - * @return static + * @return $this */ public function setFirstResult(?int $firstResult): self; public function getFirstResult(): ?int; /** - * @return static + * @return $this */ public function setMaxResults(?int $maxResults): self; diff --git a/src/FieldDescription/BaseFieldDescription.php b/src/FieldDescription/BaseFieldDescription.php index 6e27f15f5a..ed31ddcce7 100644 --- a/src/FieldDescription/BaseFieldDescription.php +++ b/src/FieldDescription/BaseFieldDescription.php @@ -177,7 +177,7 @@ final public function getName(): string return $this->name; } - final public function getOption(string $name, mixed $default = null) + final public function getOption(string $name, mixed $default = null): mixed { return $this->options[$name] ?? $default; } @@ -324,15 +324,12 @@ final public function mergeOption(string $name, array $options = []): void $this->options[$name] = array_merge($this->options[$name], $options); } - final public function getMappingType() + final public function getMappingType(): int|string|null { return $this->mappingType; } - /** - * @return string|false|null - */ - final public function getLabel() + final public function getLabel(): string|false|null { return $this->getOption('label'); } @@ -352,7 +349,7 @@ final public function getSortParentAssociationMapping(): array return $this->getOption('sort_parent_association_mappings'); } - final public function getTranslationDomain() + final public function getTranslationDomain(): string|false { return $this->getOption('translation_domain') ?? $this->getAdmin()->getTranslationDomain(); } @@ -384,10 +381,8 @@ abstract protected function setParentAssociationMappings(array $parentAssociatio /** * @throws NoValueException - * - * @return mixed */ - final protected function getFieldValue(?object $object, string $fieldName) + final protected function getFieldValue(?object $object, string $fieldName): mixed { if ($this->isVirtual() || null === $object) { return null; diff --git a/src/Filter/Filter.php b/src/Filter/Filter.php index 05cce37744..00198f7d5b 100644 --- a/src/Filter/Filter.php +++ b/src/Filter/Filter.php @@ -72,7 +72,7 @@ final public function getFormName(): string return str_replace('.', '__', $this->getName()); } - final public function getOption(string $name, mixed $default = null) + final public function getOption(string $name, mixed $default = null): mixed { if (\array_key_exists($name, $this->options)) { return $this->options[$name]; @@ -96,7 +96,7 @@ final public function getFieldOptions(): array return $this->getOption('field_options', []); } - final public function getFieldOption(string $name, mixed $default = null) + final public function getFieldOption(string $name, mixed $default = null): mixed { if (isset($this->options['field_options'][$name]) && \is_array($this->options['field_options'])) { return $this->options['field_options'][$name]; @@ -110,7 +110,7 @@ final public function setFieldOption(string $name, mixed $value): void $this->options['field_options'][$name] = $value; } - final public function getLabel() + final public function getLabel(): string|false|null { return $this->getOption('label'); } diff --git a/src/Filter/Model/FilterData.php b/src/Filter/Model/FilterData.php index 64a247c864..8dc88a1548 100644 --- a/src/Filter/Model/FilterData.php +++ b/src/Filter/Model/FilterData.php @@ -56,10 +56,7 @@ public static function fromArray(array $data): self return new self($type, \array_key_exists('value', $data), $data['value'] ?? null); } - /** - * @return mixed - */ - public function getValue() + public function getValue(): mixed { if (!$this->hasValue) { throw new \LogicException('The FilterData object does not have a value.'); diff --git a/src/Form/Extension/Field/Type/FormTypeFieldExtension.php b/src/Form/Extension/Field/Type/FormTypeFieldExtension.php index ca7abb6fb6..be7324e04e 100644 --- a/src/Form/Extension/Field/Type/FormTypeFieldExtension.php +++ b/src/Form/Extension/Field/Type/FormTypeFieldExtension.php @@ -201,10 +201,8 @@ public function configureOptions(OptionsResolver $resolver): void * * return the value related to FieldDescription, if the associated object does no * exists => a temporary one is created. - * - * @return mixed */ - public function getValueFromFieldDescription(?object $object, FieldDescriptionInterface $fieldDescription) + public function getValueFromFieldDescription(?object $object, FieldDescriptionInterface $fieldDescription): mixed { @trigger_error(sprintf( 'The method "%s()" is deprecated since sonata-project/admin-bundle 4.3 and will be removed in 5.0.', diff --git a/src/Mapper/BaseGroupedMapper.php b/src/Mapper/BaseGroupedMapper.php index 22d416c9c5..dbdd34170a 100644 --- a/src/Mapper/BaseGroupedMapper.php +++ b/src/Mapper/BaseGroupedMapper.php @@ -45,7 +45,7 @@ abstract class BaseGroupedMapper implements MapperInterface * * @throws \LogicException * - * @return static + * @return $this */ final public function with(string $name, array $options = []): self { @@ -168,7 +168,7 @@ final public function with(string $name, array $options = []): self /** * Only nested add if the condition match true. * - * @return static + * @return $this */ final public function ifTrue(bool $bool): self { @@ -180,7 +180,7 @@ final public function ifTrue(bool $bool): self /** * Only nested add if the condition match false. * - * @return static + * @return $this */ final public function ifFalse(bool $bool): self { @@ -192,7 +192,7 @@ final public function ifFalse(bool $bool): self /** * @throws \LogicException * - * @return static + * @return $this */ final public function ifEnd(): self { @@ -210,7 +210,7 @@ final public function ifEnd(): self * * @param array $options * - * @return static + * @return $this */ final public function tab(string $name, array $options = []): self { @@ -222,7 +222,7 @@ final public function tab(string $name, array $options = []): self * * @throws \LogicException * - * @return static + * @return $this */ final public function end(): self { @@ -256,9 +256,9 @@ final public function hasOpenTab(): bool * @param string $tab The tab the group belongs to, defaults to 'default' * @param bool $deleteEmptyTab Whether or not the Tab should be deleted, when the deleted group leaves the tab empty after deletion * - * @return static + * @return $this */ - final public function removeGroup(string $group, string $tab = 'default', bool $deleteEmptyTab = false) + final public function removeGroup(string $group, string $tab = 'default', bool $deleteEmptyTab = false): self { $groups = $this->getGroups(); @@ -293,7 +293,7 @@ final public function removeGroup(string $group, string $tab = 'default', bool $ /** * Removes a tab. * - * @return static + * @return $this */ final public function removeTab(string $tab): self { diff --git a/src/Mapper/MapperInterface.php b/src/Mapper/MapperInterface.php index 12c27a28af..d8ab787058 100644 --- a/src/Mapper/MapperInterface.php +++ b/src/Mapper/MapperInterface.php @@ -37,7 +37,7 @@ public function get(string $key); public function has(string $key): bool; /** - * @return static + * @return $this */ public function remove(string $key); @@ -51,7 +51,7 @@ public function keys(): array; /** * @param string[] $keys * - * @return static + * @return $this */ public function reorder(array $keys); } diff --git a/src/Object/Metadata.php b/src/Object/Metadata.php index ac49ff937e..f837b22d33 100644 --- a/src/Object/Metadata.php +++ b/src/Object/Metadata.php @@ -65,7 +65,7 @@ public function getOptions(): array return $this->options; } - public function getOption($name, mixed $default = null) + public function getOption($name, mixed $default = null): mixed { return \array_key_exists($name, $this->options) ? $this->options[$name] : $default; } diff --git a/src/Route/RouteCollection.php b/src/Route/RouteCollection.php index 3a1837410e..69d6ea44d0 100644 --- a/src/Route/RouteCollection.php +++ b/src/Route/RouteCollection.php @@ -53,7 +53,7 @@ public function add( array $schemes = [], array $methods = [], string $condition = '' - ): RouteCollectionInterface { + ): self { $pattern = sprintf('%s/%s', $this->baseRoutePattern, $pattern ?? $name); $code = $this->getCode($name); @@ -84,7 +84,7 @@ public function getCode(string $name): string return sprintf('%s.%s', $this->baseCodeRoute, $name); } - public function addCollection(RouteCollectionInterface $collection): RouteCollectionInterface + public function addCollection(RouteCollectionInterface $collection): self { foreach ($collection->getElements() as $code => $element) { $this->addElement($code, $element); @@ -127,14 +127,14 @@ public function get(string $name): Route throw new \InvalidArgumentException(sprintf('Element "%s" does not exist.', $name)); } - public function remove(string $name): RouteCollectionInterface + public function remove(string $name): self { unset($this->elements[$this->getCode($name)]); return $this; } - public function restore(string $name): RouteCollectionInterface + public function restore(string $name): self { if ($this->hasCached($name)) { $code = $this->getCode($name); @@ -146,12 +146,7 @@ public function restore(string $name): RouteCollectionInterface throw new \InvalidArgumentException(sprintf('Element "%s" does not exist in cache.', $name)); } - /** - * @param string|string[] $routeList - * - * @return static - */ - public function clearExcept($routeList): RouteCollectionInterface + public function clearExcept($routeList): self { if (!\is_array($routeList)) { $routeList = [$routeList]; @@ -172,7 +167,7 @@ public function clearExcept($routeList): RouteCollectionInterface return $this; } - public function clear(): RouteCollectionInterface + public function clear(): self { $this->elements = []; diff --git a/src/Route/RouteCollectionInterface.php b/src/Route/RouteCollectionInterface.php index eb09e824e6..52e05dc8da 100644 --- a/src/Route/RouteCollectionInterface.php +++ b/src/Route/RouteCollectionInterface.php @@ -27,7 +27,7 @@ interface RouteCollectionInterface * @param string[] $schemes * @param string[] $methods * - * @return static + * @return $this */ public function add( string $name, @@ -44,7 +44,7 @@ public function add( public function getCode(string $name): string; /** - * @return static + * @return $this */ public function addCollection(self $collection): self; @@ -63,14 +63,14 @@ public function hasCached(string $name): bool; public function get(string $name): Route; /** - * @return static + * @return $this */ public function remove(string $name): self; /** * @throws \InvalidArgumentException * - * @return static + * @return $this */ public function restore(string $name): self; @@ -79,12 +79,12 @@ public function restore(string $name): self; * * @param string[]|string $routeList * - * @return static + * @return $this */ public function clearExcept($routeList): self; /** - * @return static + * @return $this */ public function clear(): self; diff --git a/src/Security/Handler/AclSecurityHandler.php b/src/Security/Handler/AclSecurityHandler.php index 427e8c9589..3338266d07 100644 --- a/src/Security/Handler/AclSecurityHandler.php +++ b/src/Security/Handler/AclSecurityHandler.php @@ -256,7 +256,7 @@ public function deleteAcl(ObjectIdentityInterface $objectIdentity): void $this->aclProvider->deleteAcl($objectIdentity); } - public function findClassAceIndexByRole(MutableAclInterface $acl, string $role) + public function findClassAceIndexByRole(MutableAclInterface $acl, string $role): int|false { foreach ($acl->getClassAces() as $index => $entry) { $securityIdentity = $entry->getSecurityIdentity(); @@ -268,7 +268,7 @@ public function findClassAceIndexByRole(MutableAclInterface $acl, string $role) return false; } - public function findClassAceIndexByUsername(MutableAclInterface $acl, string $username) + public function findClassAceIndexByUsername(MutableAclInterface $acl, string $username): int|false { foreach ($acl->getClassAces() as $index => $entry) { $securityIdentity = $entry->getSecurityIdentity(); diff --git a/src/Show/ShowMapper.php b/src/Show/ShowMapper.php index 2f0b350bf5..1d10104f36 100644 --- a/src/Show/ShowMapper.php +++ b/src/Show/ShowMapper.php @@ -52,9 +52,11 @@ public function getAdmin(): AdminInterface /** * @throws \LogicException * + * @return $this + * * @phpstan-param FieldDescriptionOptions $fieldDescriptionOptions */ - public function add(string $name, ?string $type = null, array $fieldDescriptionOptions = []): static + public function add(string $name, ?string $type = null, array $fieldDescriptionOptions = []): self { if (!$this->shouldApply()) { return $this; @@ -103,7 +105,7 @@ public function has(string $key): bool return $this->list->has($key); } - public function remove(string $key): static + public function remove(string $key): self { $this->getAdmin()->removeShowFieldDescription($key); $this->getAdmin()->removeFieldFromShowGroup($key); @@ -117,7 +119,7 @@ public function keys(): array return array_keys($this->list->getElements()); } - public function reorder(array $keys): static + public function reorder(array $keys): self { $this->getAdmin()->reorderShowGroup($this->getCurrentGroupName(), $keys); diff --git a/src/SonataConfiguration.php b/src/SonataConfiguration.php index 44956dab51..32fbfa4e5e 100644 --- a/src/SonataConfiguration.php +++ b/src/SonataConfiguration.php @@ -66,10 +66,7 @@ public function getLogo(): string return $this->logo; } - /** - * @return mixed - */ - public function getOption(string $name, mixed $default = null) + public function getOption(string $name, mixed $default = null): mixed { return $this->options[$name] ?? $default; } diff --git a/src/Twig/Extension/RenderElementExtension.php b/src/Twig/Extension/RenderElementExtension.php index 7dc21e250a..538c918081 100644 --- a/src/Twig/Extension/RenderElementExtension.php +++ b/src/Twig/Extension/RenderElementExtension.php @@ -146,10 +146,8 @@ public function renderViewElementCompare( * @deprecated since sonata-project/admin-bundle version 4.7 use RenderElementRuntime::renderRelationElement() instead * * @throws \RuntimeException - * - * @return mixed */ - public function renderRelationElement(mixed $element, FieldDescriptionInterface $fieldDescription) + public function renderRelationElement(mixed $element, FieldDescriptionInterface $fieldDescription): mixed { @trigger_error(sprintf( 'The method "%s()" is deprecated since sonata-project/admin-bundle 4.7 and will be removed in 5.0.' diff --git a/src/Twig/Extension/SonataAdminExtension.php b/src/Twig/Extension/SonataAdminExtension.php index 961819ce7b..1779c037c2 100644 --- a/src/Twig/Extension/SonataAdminExtension.php +++ b/src/Twig/Extension/SonataAdminExtension.php @@ -36,7 +36,7 @@ public function __construct( /** * @return TwigFilter[] */ - public function getFilters() + public function getFilters(): array { return [ new TwigFilter( diff --git a/src/Twig/RenderElementRuntime.php b/src/Twig/RenderElementRuntime.php index 54445b607d..5aa7b61c02 100644 --- a/src/Twig/RenderElementRuntime.php +++ b/src/Twig/RenderElementRuntime.php @@ -125,10 +125,8 @@ public function renderViewElementCompare( /** * @throws \RuntimeException - * - * @return mixed */ - public function renderRelationElement(mixed $element, FieldDescriptionInterface $fieldDescription) + public function renderRelationElement(mixed $element, FieldDescriptionInterface $fieldDescription): mixed { if (!\is_object($element)) { return $element; diff --git a/src/Util/AdminObjectAclData.php b/src/Util/AdminObjectAclData.php index 6533dc9888..6e7d721576 100644 --- a/src/Util/AdminObjectAclData.php +++ b/src/Util/AdminObjectAclData.php @@ -98,7 +98,10 @@ public function getAclRoles(): \Traversable return $this->aclRoles; } - public function setAcl(MutableAclInterface $acl): static + /** + * @return $this + */ + public function setAcl(MutableAclInterface $acl): self { $this->acl = $acl; @@ -118,7 +121,10 @@ public function getMasks(): array return $this->masks; } - public function setAclUsersForm(FormInterface $form): static + /** + * @return $this + */ + public function setAclUsersForm(FormInterface $form): self { $this->aclUsersForm = $form; @@ -130,7 +136,10 @@ public function getAclUsersForm(): ?FormInterface return $this->aclUsersForm; } - public function setAclRolesForm(FormInterface $form): static + /** + * @return $this + */ + public function setAclRolesForm(FormInterface $form): self { $this->aclRolesForm = $form; diff --git a/src/Util/AdminObjectAclManipulator.php b/src/Util/AdminObjectAclManipulator.php index da6037f8b5..7e760ee051 100644 --- a/src/Util/AdminObjectAclManipulator.php +++ b/src/Util/AdminObjectAclManipulator.php @@ -226,8 +226,6 @@ private function buildForm(AdminObjectAclData $data, FormBuilderInterface $formB /** * Gets a user or a role security identity. - * - * @return RoleSecurityIdentity|UserSecurityIdentity */ private function getSecurityIdentity(string|UserInterface $aclValue): SecurityIdentityInterface { diff --git a/tests/App/Datagrid/ProxyQuery.php b/tests/App/Datagrid/ProxyQuery.php index 9580855c6e..b2068417fc 100644 --- a/tests/App/Datagrid/ProxyQuery.php +++ b/tests/App/Datagrid/ProxyQuery.php @@ -21,12 +21,12 @@ */ final class ProxyQuery implements ProxyQueryInterface { - public function execute() + public function execute(): iterable { throw new \BadMethodCallException('Not implemented.'); } - public function setSortBy(array $parentAssociationMappings, array $fieldMapping): ProxyQueryInterface + public function setSortBy(array $parentAssociationMappings, array $fieldMapping): self { throw new \BadMethodCallException('Not implemented.'); } @@ -36,7 +36,7 @@ public function getSortBy(): string return 'e.id'; } - public function setSortOrder(string $sortOrder): ProxyQueryInterface + public function setSortOrder(string $sortOrder): self { throw new \BadMethodCallException('Not implemented.'); } @@ -46,7 +46,7 @@ public function getSortOrder(): string return 'ASC'; } - public function setFirstResult(?int $firstResult): ProxyQueryInterface + public function setFirstResult(?int $firstResult): self { if (null === $firstResult) { return $this; @@ -60,7 +60,7 @@ public function getFirstResult(): ?int throw new \BadMethodCallException('Not implemented.'); } - public function setMaxResults(?int $maxResults): ProxyQueryInterface + public function setMaxResults(?int $maxResults): self { if (null === $maxResults) { return $this; diff --git a/tests/App/FieldDescription/FieldDescription.php b/tests/App/FieldDescription/FieldDescription.php index 5a59b70ad4..cf7b803368 100644 --- a/tests/App/FieldDescription/FieldDescription.php +++ b/tests/App/FieldDescription/FieldDescription.php @@ -21,14 +21,6 @@ public function setAssociationMapping($associationMapping): void { } - /** - * @return null - */ - public function getTargetEntity() - { - return null; - } - public function getTargetModel(): ?string { return null; @@ -47,7 +39,7 @@ public function isIdentifier(): bool return false; } - public function getValue(object $object) + public function getValue(object $object): mixed { return $this->getFieldValue($object, $this->fieldName); } diff --git a/tests/App/Model/ModelManager.php b/tests/App/Model/ModelManager.php index 806829351b..3ed922fee3 100644 --- a/tests/App/Model/ModelManager.php +++ b/tests/App/Model/ModelManager.php @@ -114,7 +114,7 @@ public function addIdentifiersToQuery(string $class, ProxyQueryInterface $query, { } - public function getLockVersion(object $object) + public function getLockVersion(object $object): mixed { return null; } diff --git a/tests/App/Model/RepositoryInterface.php b/tests/App/Model/RepositoryInterface.php index 88edb82500..2b7d34747b 100644 --- a/tests/App/Model/RepositoryInterface.php +++ b/tests/App/Model/RepositoryInterface.php @@ -21,7 +21,7 @@ interface RepositoryInterface /** * @return T|null */ - public function byId(string $id); + public function byId(string $id): ?EntityInterface; /** * @return array diff --git a/tests/Datagrid/PagerTest.php b/tests/Datagrid/PagerTest.php index 9bc5e0d69d..36358d9cb2 100644 --- a/tests/Datagrid/PagerTest.php +++ b/tests/Datagrid/PagerTest.php @@ -224,10 +224,8 @@ public function testGetPreviousPage(): void /** * @param mixed[] $args - * - * @return mixed */ - protected function callMethod(object $obj, string $name, array $args = []) + protected function callMethod(object $obj, string $name, array $args = []): mixed { $class = new \ReflectionClass($obj); $method = $class->getMethod($name); diff --git a/tests/FieldDescription/BaseFieldDescriptionTest.php b/tests/FieldDescription/BaseFieldDescriptionTest.php index 9464afc73d..b95db61cb1 100644 --- a/tests/FieldDescription/BaseFieldDescriptionTest.php +++ b/tests/FieldDescription/BaseFieldDescriptionTest.php @@ -266,10 +266,8 @@ public function testGetTranslationDomainWithFalse(): void /** * @param mixed[] $args - * - * @return mixed */ - protected function callMethod(object $obj, string $name, array $args = []) + protected function callMethod(object $obj, string $name, array $args = []): mixed { $class = new \ReflectionClass($obj); $method = $class->getMethod($name); diff --git a/tests/Form/DataTransformerResolverTest.php b/tests/Form/DataTransformerResolverTest.php index e2616f9c03..6212fc6273 100644 --- a/tests/Form/DataTransformerResolverTest.php +++ b/tests/Form/DataTransformerResolverTest.php @@ -234,7 +234,7 @@ public function testAddCustomGlobalTransformer(string $fieldType): void } /** - * @return DataTransformerInterface + * @return DataTransformerInterface|null */ private function resolve(): ?DataTransformerInterface { diff --git a/tests/Twig/CanonicalizeRuntimeTest.php b/tests/Twig/CanonicalizeRuntimeTest.php index 4d40051845..b91a092a13 100644 --- a/tests/Twig/CanonicalizeRuntimeTest.php +++ b/tests/Twig/CanonicalizeRuntimeTest.php @@ -64,7 +64,7 @@ public function testCanonicalizedLocaleForSelect2(?string $expected, string $ori /** * NEXT_MAJOR: Remove this function. * - * @return iterable + * @return iterable */ public function provideCanonicalizedLocaleForMomentCases(): iterable { @@ -186,7 +186,7 @@ public function provideCanonicalizedLocaleForMomentCases(): iterable } /** - * @return iterable + * @return iterable */ public function provideCanonicalizedLocaleForSelect2Cases(): iterable { diff --git a/tests/Twig/Extension/CanonicalizeExtensionTest.php b/tests/Twig/Extension/CanonicalizeExtensionTest.php index 70c94294a8..e262a3269b 100644 --- a/tests/Twig/Extension/CanonicalizeExtensionTest.php +++ b/tests/Twig/Extension/CanonicalizeExtensionTest.php @@ -70,7 +70,7 @@ public function testCanonicalizedLocaleForSelect2(?string $expected, string $ori } /** - * @return iterable + * @return iterable */ public function provideCanonicalizedLocaleForMomentCases(): iterable { @@ -192,7 +192,7 @@ public function provideCanonicalizedLocaleForMomentCases(): iterable } /** - * @return iterable + * @return iterable */ public function provideCanonicalizedLocaleForSelect2Cases(): iterable {