diff --git a/src/ArgumentResolver/CompatibleValueResolverInterface.php b/src/ArgumentResolver/CompatibleValueResolverInterface.php index 810a17e3e1..c34a63e071 100644 --- a/src/ArgumentResolver/CompatibleValueResolverInterface.php +++ b/src/ArgumentResolver/CompatibleValueResolverInterface.php @@ -17,14 +17,14 @@ use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; // TODO: Remove this interface when dropping support of Symfony < 6.2 and replace its usage with ValueResolverInterface -if (interface_exists(ArgumentValueResolverInterface::class)) { +if (interface_exists(ValueResolverInterface::class)) { /** @internal */ - interface CompatibleValueResolverInterface extends ArgumentValueResolverInterface + interface CompatibleValueResolverInterface extends ValueResolverInterface { } -} else { +} elseif (interface_exists(ArgumentValueResolverInterface::class)) { /** @internal */ - interface CompatibleValueResolverInterface extends ValueResolverInterface + interface CompatibleValueResolverInterface extends ArgumentValueResolverInterface { } } diff --git a/src/Twig/Extension/TemplateRegistryExtension.php b/src/Twig/Extension/TemplateRegistryExtension.php index 39637fad7b..8d87fed8b4 100644 --- a/src/Twig/Extension/TemplateRegistryExtension.php +++ b/src/Twig/Extension/TemplateRegistryExtension.php @@ -50,7 +50,7 @@ public function getFunctions(): array * @throws ServiceNotFoundException * @throws ServiceCircularReferenceException */ - public function getAdminTemplate(string $name, string $adminCode): ?string + public function getAdminTemplate(string $name, string $adminCode): string { @trigger_error(sprintf( 'The method "%s()" is deprecated since sonata-project/admin-bundle 4.7 and will be removed in 5.0.' @@ -68,7 +68,7 @@ public function getAdminTemplate(string $name, string $adminCode): ?string * * @deprecated since sonata-project/admin-bundle version 4.7 use TemplateRegistryRuntime::getGlobalTemplate() instead */ - public function getGlobalTemplate(string $name): ?string + public function getGlobalTemplate(string $name): string { @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/TemplateRegistryRuntime.php b/src/Twig/TemplateRegistryRuntime.php index 651d6b69e1..0065bbb784 100644 --- a/src/Twig/TemplateRegistryRuntime.php +++ b/src/Twig/TemplateRegistryRuntime.php @@ -35,12 +35,12 @@ public function __construct( * @throws ServiceNotFoundException * @throws ServiceCircularReferenceException */ - public function getAdminTemplate(string $name, string $adminCode): ?string + public function getAdminTemplate(string $name, string $adminCode): string { return $this->getTemplateRegistry($adminCode)->getTemplate($name); } - public function getGlobalTemplate(string $name): ?string + public function getGlobalTemplate(string $name): string { return $this->globalTemplateRegistry->getTemplate($name); } diff --git a/tests/App/Datagrid/Pager.php b/tests/App/Datagrid/Pager.php index 523e2ade49..b764006595 100644 --- a/tests/App/Datagrid/Pager.php +++ b/tests/App/Datagrid/Pager.php @@ -79,7 +79,10 @@ public function isLastPage(): bool return false; } - public function getQuery(): ?ProxyQueryInterface + /** + * @phpstan-return ProxyQueryInterface + */ + public function getQuery(): ProxyQueryInterface { return new ProxyQuery(); } diff --git a/tests/App/Datagrid/ProxyQuery.php b/tests/App/Datagrid/ProxyQuery.php index abbc5f9276..9580855c6e 100644 --- a/tests/App/Datagrid/ProxyQuery.php +++ b/tests/App/Datagrid/ProxyQuery.php @@ -31,7 +31,7 @@ public function setSortBy(array $parentAssociationMappings, array $fieldMapping) throw new \BadMethodCallException('Not implemented.'); } - public function getSortBy(): ?string + public function getSortBy(): string { return 'e.id'; } @@ -41,7 +41,7 @@ public function setSortOrder(string $sortOrder): ProxyQueryInterface throw new \BadMethodCallException('Not implemented.'); } - public function getSortOrder(): ?string + public function getSortOrder(): string { return 'ASC'; } @@ -69,7 +69,7 @@ public function setMaxResults(?int $maxResults): ProxyQueryInterface throw new \BadMethodCallException('Not implemented.'); } - public function getMaxResults(): ?int + public function getMaxResults(): int { return 1; } diff --git a/tests/App/FieldDescription/FieldDescription.php b/tests/App/FieldDescription/FieldDescription.php index 6b65e53152..5a59b70ad4 100644 --- a/tests/App/FieldDescription/FieldDescription.php +++ b/tests/App/FieldDescription/FieldDescription.php @@ -21,7 +21,10 @@ public function setAssociationMapping($associationMapping): void { } - public function getTargetEntity(): ?string + /** + * @return null + */ + public function getTargetEntity() { return null; } diff --git a/tests/Fixtures/Model/AuditReader.php b/tests/Fixtures/Model/AuditReader.php index 1e8ccc7dce..0c43924f10 100644 --- a/tests/Fixtures/Model/AuditReader.php +++ b/tests/Fixtures/Model/AuditReader.php @@ -21,7 +21,7 @@ */ final class AuditReader implements AuditReaderInterface { - public function find(string $className, $id, $revisionId): ?object + public function find(string $className, $id, $revisionId): object { return new $className(); } @@ -33,7 +33,7 @@ public function findRevisionHistory(string $className, int $limit = 20, int $off ]; } - public function findRevision(string $className, $revisionId): ?Revision + public function findRevision(string $className, $revisionId): Revision { return new Revision(1, new \DateTime(), 'Jack'); }