From ad1e20abb74cc743d4d0bd9ce5fb25f266a39065 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Tue, 7 Dec 2021 13:34:36 +0200 Subject: [PATCH] Fixed phpstan level 4 issues in Framework --- composer.json | 2 +- .../Grav/Framework/Collection/AbstractIndexCollection.php | 1 + system/src/Grav/Framework/Flex/FlexCollection.php | 2 ++ system/src/Grav/Framework/Object/ObjectCollection.php | 2 +- system/src/Grav/Framework/Object/ObjectIndex.php | 6 ++++-- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index f7be6fe53..6a7455b9d 100644 --- a/composer.json +++ b/composer.json @@ -109,7 +109,7 @@ "api-17": "vendor/bin/phpdoc-md generate system/src > user/pages/14.api/default.17.md", "post-create-project-cmd": "bin/grav install", "phpstan": "vendor/bin/phpstan analyse -l 1 -c ./tests/phpstan/phpstan.neon --memory-limit=720M system/src", - "phpstan-framework": "vendor/bin/phpstan analyse -l 3 -c ./tests/phpstan/phpstan.neon --memory-limit=480M system/src/Grav/Framework system/src/Grav/Events system/src/Grav/Installer", + "phpstan-framework": "vendor/bin/phpstan analyse -l 4 -c ./tests/phpstan/phpstan.neon --memory-limit=480M system/src/Grav/Framework system/src/Grav/Events system/src/Grav/Installer", "phpstan-plugins": "vendor/bin/phpstan analyse -l 1 -c ./tests/phpstan/plugins.neon --memory-limit=400M user/plugins", "test": "vendor/bin/codecept run unit", "test-windows": "vendor\\bin\\codecept run unit" diff --git a/system/src/Grav/Framework/Collection/AbstractIndexCollection.php b/system/src/Grav/Framework/Collection/AbstractIndexCollection.php index 9d7d6bb3d..8c98a8111 100644 --- a/system/src/Grav/Framework/Collection/AbstractIndexCollection.php +++ b/system/src/Grav/Framework/Collection/AbstractIndexCollection.php @@ -452,6 +452,7 @@ abstract class AbstractIndexCollection implements CollectionInterface */ public function chunk($size) { + /** @phpstan-var array> */ return $this->loadCollection($this->entries)->chunk($size); } diff --git a/system/src/Grav/Framework/Flex/FlexCollection.php b/system/src/Grav/Framework/Flex/FlexCollection.php index 2a8a16712..8ad78f06a 100644 --- a/system/src/Grav/Framework/Flex/FlexCollection.php +++ b/system/src/Grav/Framework/Flex/FlexCollection.php @@ -19,6 +19,7 @@ use Grav\Common\User\Interfaces\UserInterface; use Grav\Common\Utils; use Grav\Framework\Cache\CacheInterface; use Grav\Framework\ContentBlock\HtmlBlock; +use Grav\Framework\Flex\Interfaces\FlexIndexInterface; use Grav\Framework\Flex\Interfaces\FlexObjectInterface; use Grav\Framework\Object\ObjectCollection; use Grav\Framework\Flex\Interfaces\FlexCollectionInterface; @@ -342,6 +343,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface */ public function getIndex() { + /** @phpstan-var FlexIndexInterface */ return $this->getFlexDirectory()->getIndex($this->getKeys(), $this->getKeyField()); } diff --git a/system/src/Grav/Framework/Object/ObjectCollection.php b/system/src/Grav/Framework/Object/ObjectCollection.php index af861c2ce..40774fc5d 100644 --- a/system/src/Grav/Framework/Object/ObjectCollection.php +++ b/system/src/Grav/Framework/Object/ObjectCollection.php @@ -125,7 +125,7 @@ class ObjectCollection extends ArrayCollection implements NestedObjectCollection */ protected function setElements(array $elements) { - /** @phpstan-var array */ + /** @phpstan-var array $elements */ return $elements; } } diff --git a/system/src/Grav/Framework/Object/ObjectIndex.php b/system/src/Grav/Framework/Object/ObjectIndex.php index bc1fad248..e09c0dd95 100644 --- a/system/src/Grav/Framework/Object/ObjectIndex.php +++ b/system/src/Grav/Framework/Object/ObjectIndex.php @@ -257,8 +257,10 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje { $collection = $this->loadCollection($this->getEntries()); - /** @phpstan-var C */ - return $collection->matching($criteria); + /** @phpstan-var C $matching */ + $matching = $collection->matching($criteria); + + return $matching; } /**