Skip to content

Commit

Permalink
api: fix phpstan errors
Browse files Browse the repository at this point in the history
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.
 ------ -------------------------------------------------------------------------------------
  • Loading branch information
BacLuc authored and usu committed Aug 14, 2023
1 parent c115180 commit ad2bdaa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions api/src/State/ContentNode/ContentNodePersistProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions api/src/State/Util/AbstractPersistProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProcessorInterface;
use App\Entity\BaseEntity;

/**
* @template T
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit ad2bdaa

Please sign in to comment.