From f1ce2b27e5126074436ec6b0d77384bfd475b1a9 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Tue, 16 Apr 2024 17:21:42 +0200 Subject: [PATCH 1/2] Fixed PHPDoc syntax (#311) * URLAlias: Fix $languageCodes class property's phpdoc * AbstractInMemoryCollection.php: Fix phpstan VS phpdoc * ArrayList.php: Fix phpstan VS phpdoc * ArrayMap.php: Fix phpstan VS phpdoc * phpstan-baseline.neon: Remove fixed `Unexpected token \"languageCodes\"` in URLAlias.php * phpstan-baseline.neon: Rm related to URLAlias::$languageCodes fix * phpstan-baseline.neon: Rm related to URLAlias::$languageCodes fix --------- Co-authored-by: Adrien Dupuis --- phpstan-baseline.neon | 25 ------------------- .../Collection/AbstractInMemoryCollection.php | 4 +-- src/contracts/Collection/ArrayList.php | 8 +++--- src/contracts/Collection/ArrayMap.php | 4 +-- .../Repository/Values/Content/URLAlias.php | 2 +- 5 files changed, 9 insertions(+), 34 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1d393d75b9..3fd6b490fa 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -7375,11 +7375,6 @@ parameters: count: 1 path: src/contracts/Repository/Values/Content/Trash/TrashItemDeleteResultList.php - - - message: "#^PHPDoc tag @property\\-read has invalid value \\(string\\[\\] languageCodes the languages for which this alias is valid\\)\\: Unexpected token \"languageCodes\", expected variable at offset 451$#" - count: 1 - path: src/contracts/Repository/Values/Content/URLAlias.php - - message: "#^Class Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\URLWildcard\\\\SearchResult implements generic interface IteratorAggregate but does not specify its types\\: TKey, TValue$#" count: 1 @@ -21215,11 +21210,6 @@ parameters: count: 1 path: src/lib/Repository/TrashService.php - - - message: "#^Access to protected property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\URLAlias\\:\\:\\$languageCodes\\.$#" - count: 2 - path: src/lib/Repository/URLAliasService.php - - message: "#^Class Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\UrlAlias referenced with incorrect case\\: Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\URLAlias\\.$#" count: 7 @@ -27370,11 +27360,6 @@ parameters: count: 9 path: tests/integration/Core/Repository/ContentServiceTest.php - - - message: "#^Access to protected property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\URLAlias\\:\\:\\$languageCodes\\.$#" - count: 2 - path: tests/integration/Core/Repository/ContentServiceTest.php - - message: "#^Argument of an invalid type Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\ContentMetadataUpdateStruct supplied for foreach, only iterables are supported\\.$#" count: 1 @@ -38810,11 +38795,6 @@ parameters: count: 1 path: tests/integration/Core/Repository/URLAliasServiceAuthorizationTest.php - - - message: "#^Access to protected property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\URLAlias\\:\\:\\$languageCodes\\.$#" - count: 1 - path: tests/integration/Core/Repository/URLAliasServiceTest.php - - message: "#^Cannot access offset 0 on iterable\\\\.$#" count: 1 @@ -59800,11 +59780,6 @@ parameters: count: 1 path: tests/lib/Repository/Service/Mock/SearchTest.php - - - message: "#^Access to protected property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\URLAlias\\:\\:\\$languageCodes\\.$#" - count: 3 - path: tests/lib/Repository/Service/Mock/UrlAliasTest.php - - message: "#^Cannot access offset 0 on iterable\\\\.$#" count: 3 diff --git a/src/contracts/Collection/AbstractInMemoryCollection.php b/src/contracts/Collection/AbstractInMemoryCollection.php index 529cbeea85..5acfc79edb 100644 --- a/src/contracts/Collection/AbstractInMemoryCollection.php +++ b/src/contracts/Collection/AbstractInMemoryCollection.php @@ -20,11 +20,11 @@ */ abstract class AbstractInMemoryCollection implements CollectionInterface, StreamableInterface { - /** @var TValue[] */ + /** @phpstan-var TValue[] */ protected array $items; /** - * @param TValue[] $items + * @phpstan-param TValue[] $items */ public function __construct(array $items = []) { diff --git a/src/contracts/Collection/ArrayList.php b/src/contracts/Collection/ArrayList.php index c6eaa41cca..4a639645a8 100644 --- a/src/contracts/Collection/ArrayList.php +++ b/src/contracts/Collection/ArrayList.php @@ -19,7 +19,7 @@ class ArrayList extends AbstractInMemoryCollection implements ListInterface { /** - * @param TValue[] $items + * @phpstan-param TValue[] $items */ public function __construct(array $items = []) { @@ -45,7 +45,7 @@ public function last() } /** - * @param TValue $value + * @phpstan-param TValue $value */ public function contains($value): bool { @@ -53,9 +53,9 @@ public function contains($value): bool } /** - * @param TValue[] $items + * @phpstan-param TValue[] $items * - * @return \Ibexa\Contracts\Core\Collection\ArrayList + * @phpstan-return \Ibexa\Contracts\Core\Collection\ArrayList */ protected function createFrom(array $items): self { diff --git a/src/contracts/Collection/ArrayMap.php b/src/contracts/Collection/ArrayMap.php index 37ddcf3749..698dc3a0f7 100644 --- a/src/contracts/Collection/ArrayMap.php +++ b/src/contracts/Collection/ArrayMap.php @@ -34,9 +34,9 @@ public function has($key): bool } /** - * @param TValue[] $items + * @phpstan-param TValue[] $items * - * @return \Ibexa\Contracts\Core\Collection\ArrayMap + * @phpstan-return \Ibexa\Contracts\Core\Collection\ArrayMap */ protected function createFrom(array $items): self { diff --git a/src/contracts/Repository/Values/Content/URLAlias.php b/src/contracts/Repository/Values/Content/URLAlias.php index 41c7e9136f..6e4502ff90 100644 --- a/src/contracts/Repository/Values/Content/URLAlias.php +++ b/src/contracts/Repository/Values/Content/URLAlias.php @@ -17,7 +17,7 @@ * @property-read int $type The type of the URL Alias i.e. one of URLAlias::LOCATION, URLAlias::RESOURCE, URLAlias::VIRTUAL * @property-read mixed $destination If type = URLAlias::LOCATION it is a Location id otherwise a string (e.g. /content/search) * @property-read string $path the alias path - * @property-read string[] languageCodes the languages for which this alias is valid + * @property-read string[] $languageCodes the languages for which this alias is valid * @property-read bool $alwaysAvailable Fallback indicator for other languages * @property-read bool $isHistory Indicates that this alias was autogenerated for an in the meanwhile archived version of the content * @property-read bool $isCustom If false this alias was autogenerated otherwise manuel created From 81464c68ca1b0663f181e8dbc76757ceded2b5e1 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 17 Apr 2024 16:38:58 +0200 Subject: [PATCH 2/2] Fixed missing return types for DebugTemplate class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For more details see https://github.com/ezsystems/ezplatform-kernel/pull/406 Co-Authored-By: Paweł Niedzielski --- .../Twig/DebugTemplate.php | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/eZ/Bundle/EzPublishDebugBundle/Twig/DebugTemplate.php b/eZ/Bundle/EzPublishDebugBundle/Twig/DebugTemplate.php index 313386a7f9..0d10379826 100644 --- a/eZ/Bundle/EzPublishDebugBundle/Twig/DebugTemplate.php +++ b/eZ/Bundle/EzPublishDebugBundle/Twig/DebugTemplate.php @@ -7,6 +7,7 @@ namespace eZ\Bundle\EzPublishDebugBundle\Twig; use Symfony\Component\Filesystem\Filesystem; +use Twig\Source; use Twig\Template; /** @@ -19,7 +20,7 @@ class DebugTemplate extends Template { private $fileSystem; - public function display(array $context, array $blocks = []) + public function display(array $context, array $blocks = []): void { $this->fileSystem = $this->fileSystem ?: new Filesystem(); @@ -65,34 +66,25 @@ public function display(array $context, array $blocks = []) } } - /** - * {@inheritdoc} - */ - public function getTemplateName() + public function getTemplateName(): string { return ''; } - /** - * {@inheritdoc} - */ - public function getSourceContext() + public function getSourceContext(): Source { - return ''; + return new Source('', ''); } - /** - * {@inheritdoc} - */ - protected function doDisplay(array $context, array $blocks = []) + protected function doDisplay(array $context, array $blocks = []): string { return ''; } /** - * {@inheritdoc} + * @return array */ - public function getDebugInfo() + public function getDebugInfo(): array { return []; }