Fixed phpstan level 4 issues in Framework

This commit is contained in:
Matias Griese 2021-12-07 13:34:36 +02:00
parent 2165743810
commit ad1e20abb7
5 changed files with 9 additions and 4 deletions

View File

@ -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"

View File

@ -452,6 +452,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
*/
public function chunk($size)
{
/** @phpstan-var array<array<TKey,T>> */
return $this->loadCollection($this->entries)->chunk($size);
}

View File

@ -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<T> */
return $this->getFlexDirectory()->getIndex($this->getKeys(), $this->getKeyField());
}

View File

@ -125,7 +125,7 @@ class ObjectCollection extends ArrayCollection implements NestedObjectCollection
*/
protected function setElements(array $elements)
{
/** @phpstan-var array<TKey,T> */
/** @phpstan-var array<TKey,T> $elements */
return $elements;
}
}

View File

@ -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;
}
/**