From ad2bdaaebbf2e9e0f15104e0889440c53d44f4cf Mon Sep 17 00:00:00 2001 From: BacLuc Date: Mon, 14 Aug 2023 09:51:21 +0200 Subject: [PATCH] api: fix phpstan errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After fixing the psalm errors and an update of phpstan, we have now phpstan errors. This fixes the following errors: ------ --------------------------------------------------------------------------------------------------------------------------------------------------- Line State/ContentNode/ContentNodePersistProcessor.php ------ --------------------------------------------------------------------------------------------------------------------------------------------------- 24 Access to an undefined property App\Entity\BaseEntity::$parent. 💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property 25 Access to an undefined property App\Entity\BaseEntity::$parent. 💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property 28 Method App\State\ContentNode\ContentNodePersistProcessor::onBefore() should return T of App\Entity\ContentNode but returns App\Entity\BaseEntity. ------ --------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------------------------------------------------------------------------------------- Line State/Util/AbstractPersistProcessor.php ------ ------------------------------------------------------------------------------------- 72 PHPDoc tag @return with type T is not subtype of native type App\Entity\BaseEntity. 💡 Write @template T of App\Entity\BaseEntity to fix this. ------ ------------------------------------------------------------------------------------- --- api/src/State/ContentNode/ContentNodePersistProcessor.php | 1 + api/src/State/Util/AbstractPersistProcessor.php | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/State/ContentNode/ContentNodePersistProcessor.php b/api/src/State/ContentNode/ContentNodePersistProcessor.php index 63038181f2..c4bdba5c2c 100644 --- a/api/src/State/ContentNode/ContentNodePersistProcessor.php +++ b/api/src/State/ContentNode/ContentNodePersistProcessor.php @@ -17,6 +17,7 @@ class ContentNodePersistProcessor extends AbstractPersistProcessor { * @param T $data */ public function onBefore($data, Operation $operation, array $uriVariables = [], array $context = []): ContentNode { + /** @var ContentNode $data */ $data = parent::onBefore($data, $operation, $uriVariables, $context); if ($operation instanceof Post) { diff --git a/api/src/State/Util/AbstractPersistProcessor.php b/api/src/State/Util/AbstractPersistProcessor.php index 76aefbb3f3..af8aef972d 100644 --- a/api/src/State/Util/AbstractPersistProcessor.php +++ b/api/src/State/Util/AbstractPersistProcessor.php @@ -4,7 +4,6 @@ use ApiPlatform\Metadata\Operation; use ApiPlatform\State\ProcessorInterface; -use App\Entity\BaseEntity; /** * @template T @@ -69,7 +68,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables = * * @return T */ - public function onBefore($data, Operation $operation, array $uriVariables = [], array $context = []): BaseEntity { + public function onBefore($data, Operation $operation, array $uriVariables = [], array $context = []) { return $data; }