Browse Source

Update phpstan config

ADmad 3 years ago
parent
commit
172b3dd016

+ 25 - 5
phpstan-baseline.neon

@@ -1,19 +1,19 @@
 parameters:
 	ignoreErrors:
 		-
-			message: "#^Unsafe usage of new static\\(\\)\\.$#"
+			message: "#^Property Cake\\\\Collection\\\\Iterator\\\\BufferedIterator\\:\\:\\$_buffer with generic class SplDoublyLinkedList does not specify its types\\: TValue$#"
 			count: 1
-			path: src/Collection/Iterator/NestIterator.php
+			path: src/Collection/Iterator/BufferedIterator.php
 
 		-
 			message: "#^Unsafe usage of new static\\(\\)\\.$#"
 			count: 1
-			path: src/Collection/Iterator/NoChildrenIterator.php
+			path: src/Collection/Iterator/NestIterator.php
 
 		-
-			message: "#^Parameter \\#1 \\$items of class Cake\\\\Collection\\\\Iterator\\\\TreePrinter constructor expects RecursiveIterator, Iterator\\<mixed, mixed\\> given\\.$#"
+			message: "#^Unsafe usage of new static\\(\\)\\.$#"
 			count: 1
-			path: src/Collection/Iterator/TreeIterator.php
+			path: src/Collection/Iterator/NoChildrenIterator.php
 
 		-
 			message: "#^Unsafe usage of new static\\(\\)\\.$#"
@@ -141,6 +141,26 @@ parameters:
 			path: src/Routing/RouteBuilder.php
 
 		-
+			message: "#^Method Cake\\\\Utility\\\\Hash\\:\\:_matches\\(\\) has parameter \\$data with generic interface ArrayAccess but does not specify its types\\: TKey, TValue$#"
+			count: 1
+			path: src/Utility/Hash.php
+
+		-
+			message: "#^Method Cake\\\\Utility\\\\Hash\\:\\:extract\\(\\) has parameter \\$data with generic interface ArrayAccess but does not specify its types\\: TKey, TValue$#"
+			count: 1
+			path: src/Utility/Hash.php
+
+		-
+			message: "#^Method Cake\\\\Utility\\\\Hash\\:\\:extract\\(\\) return type with generic interface ArrayAccess does not specify its types\\: TKey, TValue$#"
+			count: 1
+			path: src/Utility/Hash.php
+
+		-
+			message: "#^Method Cake\\\\Utility\\\\Hash\\:\\:get\\(\\) has parameter \\$data with generic interface ArrayAccess but does not specify its types\\: TKey, TValue$#"
+			count: 1
+			path: src/Utility/Hash.php
+
+		-
 			message: "#^Dead catch \\- Error is never thrown in the try block\\.$#"
 			count: 1
 			path: src/View/Cell.php

+ 0 - 1
phpstan.neon.dist

@@ -4,7 +4,6 @@ includes:
 parameters:
 	level: 6
 	checkMissingIterableValueType: false
-	checkGenericClassInNonGenericObjectType: false
 	treatPhpDocTypesAsCertain: false
 	bootstrapFiles:
 		- tests/bootstrap.php

+ 2 - 2
src/Collection/ExtractTrait.php

@@ -61,7 +61,7 @@ trait ExtractTrait
      * by iterating over the column names contained in $path.
      * It will return arrays for elements in represented with `{*}`
      *
-     * @param \ArrayAccess|array $data Data.
+     * @param \ArrayAccess<string|int, mixed>|array $data Data.
      * @param array<string> $parts Path to extract from.
      * @return mixed
      */
@@ -107,7 +107,7 @@ trait ExtractTrait
      * Returns a column from $data that can be extracted
      * by iterating over the column names contained in $path
      *
-     * @param \ArrayAccess|array $data Data.
+     * @param \ArrayAccess<string|int, mixed>|array $data Data.
      * @param array<string> $parts Path to extract from.
      * @return mixed
      */

+ 1 - 1
src/Collection/Iterator/FilterIterator.php

@@ -64,7 +64,7 @@ class FilterIterator extends Collection
      */
     public function unwrap(): Iterator
     {
-        /** @var \IteratorIterator $filter */
+        /** @var \IteratorIterator<mixed, mixed, \Iterator> $filter */
         $filter = $this->getInnerIterator();
         $iterator = $filter->getInnerIterator();
 

+ 1 - 1
src/Collection/Iterator/NestIterator.php

@@ -51,7 +51,7 @@ class NestIterator extends Collection implements RecursiveIterator
     /**
      * Returns a traversable containing the children for the current item
      *
-     * @return \RecursiveIterator
+     * @return \RecursiveIterator<mixed, mixed>
      */
     public function getChildren(): RecursiveIterator
     {

+ 1 - 1
src/Collection/Iterator/NoChildrenIterator.php

@@ -41,7 +41,7 @@ class NoChildrenIterator extends Collection implements RecursiveIterator
     /**
      * Returns a self instance without any elements.
      *
-     * @return \RecursiveIterator
+     * @return \RecursiveIterator<mixed, mixed>
      */
     public function getChildren(): RecursiveIterator
     {

+ 1 - 1
src/Collection/Iterator/TreeIterator.php

@@ -41,7 +41,7 @@ class TreeIterator extends RecursiveIteratorIterator implements CollectionInterf
     /**
      * Constructor
      *
-     * @param \RecursiveIterator $items The iterator to flatten.
+     * @param \RecursiveIterator<mixed, mixed> $items The iterator to flatten.
      * @param int $mode Iterator mode.
      * @param int $flags Iterator flags.
      */

+ 1 - 1
src/Collection/Iterator/TreePrinter.php

@@ -62,7 +62,7 @@ class TreePrinter extends RecursiveIteratorIterator implements CollectionInterfa
     /**
      * Constructor
      *
-     * @param \RecursiveIterator $items The iterator to flatten.
+     * @param \RecursiveIterator<mixed, mixed> $items The iterator to flatten.
      * @param callable|string $valuePath The property to extract or a callable to return
      * the display value.
      * @param callable|string $keyPath The property to use as iteration key or a

+ 1 - 1
src/Collection/Iterator/UnfoldIterator.php

@@ -77,7 +77,7 @@ class UnfoldIterator extends IteratorIterator implements RecursiveIterator
      * Returns an iterator containing the items generated by transforming
      * the current value with the callable function.
      *
-     * @return \RecursiveIterator
+     * @return \RecursiveIterator<mixed, mixed>
      */
     public function getChildren(): RecursiveIterator
     {

+ 1 - 1
src/Datasource/RulesAwareTrait.php

@@ -44,7 +44,7 @@ trait RulesAwareTrait
      *
      * @param \Cake\Datasource\EntityInterface $entity The entity to check for validity.
      * @param string $operation The operation being run. Either 'create', 'update' or 'delete'.
-     * @param \ArrayObject|array|null $options The options To be passed to the rules.
+     * @param \ArrayObject<string, mixed>|array|null $options The options To be passed to the rules.
      * @return bool
      */
     public function checkRules(

+ 1 - 1
src/Error/Debug/DebugContext.php

@@ -39,7 +39,7 @@ class DebugContext
     private int $depth = 0;
 
     /**
-     * @var \SplObjectStorage
+     * @var \SplObjectStorage<object, int>
      */
     private SplObjectStorage $refs;
 

+ 2 - 0
src/Http/BaseApplication.php

@@ -77,6 +77,7 @@ abstract class BaseApplication implements
      * Controller factory
      *
      * @var \Cake\Http\ControllerFactoryInterface|null
+     * @phpstan-ignore-next-line
      */
     protected ?ControllerFactoryInterface $controllerFactory = null;
 
@@ -93,6 +94,7 @@ abstract class BaseApplication implements
      * @param string $configDir The directory the bootstrap configuration is held in.
      * @param \Cake\Event\EventManagerInterface|null $eventManager Application event manager instance.
      * @param \Cake\Http\ControllerFactoryInterface|null $controllerFactory Controller factory.
+     * @phpstan-ignore-next-line
      */
     public function __construct(
         string $configDir,

+ 3 - 3
src/ORM/Behavior/CounterCacheBehavior.php

@@ -117,7 +117,7 @@ class CounterCacheBehavior extends Behavior
      *
      * @param \Cake\Event\EventInterface $event The beforeSave event that was fired
      * @param \Cake\Datasource\EntityInterface $entity The entity that is going to be saved
-     * @param \ArrayObject $options The options for the query
+     * @param \ArrayObject<string, mixed> $options The options for the query
      * @return void
      */
     public function beforeSave(EventInterface $event, EntityInterface $entity, ArrayObject $options): void
@@ -155,7 +155,7 @@ class CounterCacheBehavior extends Behavior
      *
      * @param \Cake\Event\EventInterface $event The afterSave event that was fired.
      * @param \Cake\Datasource\EntityInterface $entity The entity that was saved.
-     * @param \ArrayObject $options The options for the query
+     * @param \ArrayObject<string, mixed> $options The options for the query
      * @return void
      */
     public function afterSave(EventInterface $event, EntityInterface $entity, ArrayObject $options): void
@@ -175,7 +175,7 @@ class CounterCacheBehavior extends Behavior
      *
      * @param \Cake\Event\EventInterface $event The afterDelete event that was fired.
      * @param \Cake\Datasource\EntityInterface $entity The entity that was deleted.
-     * @param \ArrayObject $options The options for the query
+     * @param \ArrayObject<string, mixed> $options The options for the query
      * @return void
      */
     public function afterDelete(EventInterface $event, EntityInterface $entity, ArrayObject $options): void

+ 2 - 2
src/ORM/Behavior/Translate/EavStrategy.php

@@ -162,7 +162,7 @@ class EavStrategy implements TranslateStrategyInterface
      *
      * @param \Cake\Event\EventInterface $event The beforeFind event that was fired.
      * @param \Cake\ORM\Query\SelectQuery $query Query
-     * @param \ArrayObject $options The options for the query
+     * @param \ArrayObject<string, mixed> $options The options for the query
      * @return void
      */
     public function beforeFind(EventInterface $event, SelectQuery $query, ArrayObject $options): void
@@ -226,7 +226,7 @@ class EavStrategy implements TranslateStrategyInterface
      *
      * @param \Cake\Event\EventInterface $event The beforeSave event that was fired
      * @param \Cake\Datasource\EntityInterface $entity The entity that is going to be saved
-     * @param \ArrayObject $options the options passed to the save method
+     * @param \ArrayObject<string, mixed> $options the options passed to the save method
      * @return void
      */
     public function beforeSave(EventInterface $event, EntityInterface $entity, ArrayObject $options): void

+ 3 - 3
src/ORM/Behavior/Translate/ShadowTableStrategy.php

@@ -120,7 +120,7 @@ class ShadowTableStrategy implements TranslateStrategyInterface
      *
      * @param \Cake\Event\EventInterface $event The beforeFind event that was fired.
      * @param \Cake\ORM\Query\SelectQuery $query Query.
-     * @param \ArrayObject $options The options for the query.
+     * @param \ArrayObject<string, mixed> $options The options for the query.
      * @return void
      */
     public function beforeFind(EventInterface $event, SelectQuery $query, ArrayObject $options): void
@@ -154,7 +154,7 @@ class ShadowTableStrategy implements TranslateStrategyInterface
      * Create a hasOne association for record with required locale.
      *
      * @param string $locale Locale
-     * @param \ArrayObject $options Find options
+     * @param \ArrayObject<string, mixed> $options Find options
      * @return void
      */
     protected function setupHasOneAssociation(string $locale, ArrayObject $options): void
@@ -338,7 +338,7 @@ class ShadowTableStrategy implements TranslateStrategyInterface
      *
      * @param \Cake\Event\EventInterface $event The beforeSave event that was fired.
      * @param \Cake\Datasource\EntityInterface $entity The entity that is going to be saved.
-     * @param \ArrayObject $options the options passed to the save method.
+     * @param \ArrayObject<string, mixed> $options the options passed to the save method.
      * @return void
      */
     public function beforeSave(EventInterface $event, EntityInterface $entity, ArrayObject $options): void

+ 2 - 2
src/ORM/Behavior/Translate/TranslateStrategyInterface.php

@@ -92,7 +92,7 @@ interface TranslateStrategyInterface extends PropertyMarshalInterface
      *
      * @param \Cake\Event\EventInterface $event The beforeFind event that was fired.
      * @param \Cake\ORM\Query\SelectQuery $query Query
-     * @param \ArrayObject $options The options for the query
+     * @param \ArrayObject<string, mixed> $options The options for the query
      * @return void
      */
     public function beforeFind(EventInterface $event, SelectQuery $query, ArrayObject $options): void;
@@ -103,7 +103,7 @@ interface TranslateStrategyInterface extends PropertyMarshalInterface
      *
      * @param \Cake\Event\EventInterface $event The beforeSave event that was fired
      * @param \Cake\Datasource\EntityInterface $entity The entity that is going to be saved
-     * @param \ArrayObject $options the options passed to the save method
+     * @param \ArrayObject<string, mixed> $options the options passed to the save method
      * @return void
      */
     public function beforeSave(EventInterface $event, EntityInterface $entity, ArrayObject $options): void;

+ 1 - 1
src/ORM/ResultSet.php

@@ -52,7 +52,7 @@ class ResultSet implements ResultSetInterface
     /**
      * Results that have been fetched or hydrated into the results.
      *
-     * @var \SplFixedArray
+     * @var \SplFixedArray<\Cake\Datasource\EntityInterface|array>
      */
     protected SplFixedArray $_results;
 

+ 3 - 3
src/ORM/Table.php

@@ -1941,7 +1941,7 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
      * Performs the actual saving of an entity based on the passed options.
      *
      * @param \Cake\Datasource\EntityInterface $entity the entity to be saved
-     * @param \ArrayObject $options the options to use for the save operation
+     * @param \ArrayObject<string, mixed> $options the options to use for the save operation
      * @return \Cake\Datasource\EntityInterface|false
      * @throws \Cake\Database\Exception\DatabaseException When an entity is missing some of the primary keys.
      * @throws \Cake\ORM\Exception\RolledbackTransactionException If the transaction
@@ -2024,7 +2024,7 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
      * once the entity for this table has been saved successfully.
      *
      * @param \Cake\Datasource\EntityInterface $entity the entity to be saved
-     * @param \ArrayObject $options the options to use for the save operation
+     * @param \ArrayObject<string, mixed> $options the options to use for the save operation
      * @return bool True on success
      * @throws \Cake\ORM\Exception\RolledbackTransactionException If the transaction
      *   is aborted in the afterSave event.
@@ -2486,7 +2486,7 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
      * dependent associations, and clear out join tables for BelongsToMany associations.
      *
      * @param \Cake\Datasource\EntityInterface $entity The entity to delete.
-     * @param \ArrayObject $options The options for the delete.
+     * @param \ArrayObject<string, mixed> $options The options for the delete.
      * @throws \InvalidArgumentException if there are no primary key values of the
      * passed entity
      * @return bool success

+ 1 - 1
src/Validation/RulesProvider.php

@@ -36,7 +36,7 @@ class RulesProvider
     /**
      * The proxied class' reflection
      *
-     * @var \ReflectionClass
+     * @var \ReflectionClass<object>
      */
     protected ReflectionClass $_reflection;
 

+ 1 - 1
src/View/Widget/SelectBoxWidget.php

@@ -197,7 +197,7 @@ class SelectBoxWidget extends BasicWidget
      * Render the contents of an optgroup element.
      *
      * @param string $label The optgroup label text
-     * @param \ArrayAccess|array $optgroup The opt group data.
+     * @param \ArrayAccess<string, mixed>|array $optgroup The opt group data.
      * @param array|null $disabled The options to disable.
      * @param array|string|int|false|null $selected The options to select.
      * @param array $templateVars Additional template variables.