Browse Source

Fix errors reported by psalm

ADmad 3 years ago
parent
commit
dd5dc8ca24

+ 0 - 1
.github/workflows/ci.yml

@@ -238,7 +238,6 @@ jobs:
     - name: Run psalm
       if: always()
       run: vendor/bin/psalm.phar --output-format=github
-      continue-on-error: true
 
     - name: Run phpstan
       if: always()

+ 1 - 0
src/Database/Driver/TupleComparisonTranslatorTrait.php

@@ -70,6 +70,7 @@ trait TupleComparisonTranslatorTrait
         $true = new QueryExpression('1');
 
         if ($value instanceof Query) {
+            /** @var array<string> $selected */
             $selected = array_values($value->clause('select'));
             foreach ($fields as $i => $field) {
                 $value->andWhere([$field => new IdentifierExpression($selected[$i])]);

+ 1 - 0
src/Datasource/SchemaInterface.php

@@ -88,6 +88,7 @@ interface SchemaInterface
      * Get the column names in the table.
      *
      * @return array<string>
+     * @psalm-return list<string>
      */
     public function columns(): array;
 

+ 1 - 0
src/ORM/Behavior/TimestampBehavior.php

@@ -134,6 +134,7 @@ class TimestampBehavior extends Behavior
      */
     public function implementedEvents(): array
     {
+        /** @var array<string, mixed> */
         return array_fill_keys(array_keys($this->_config['events']), 'handleEvent');
     }
 

+ 1 - 1
src/TestSuite/Fixture/TestFixture.php

@@ -193,11 +193,11 @@ class TestFixture implements FixtureInterface
         foreach ($this->records as $record) {
             $fields = array_merge($fields, array_intersect(array_keys($record), $columns));
         }
+        /** @var array<string> $fields */
         $fields = array_values(array_unique($fields));
         foreach ($fields as $field) {
             /** @var array $column */
             $column = $this->_schema->getColumn($field);
-            /** @psalm-suppress InvalidArrayOffset */
             $types[$field] = $column['type'];
         }
         $default = array_fill_keys($fields, null);

+ 2 - 0
src/Utility/Hash.php

@@ -1196,6 +1196,7 @@ class Hash
      * @see \Cake\Utility\Hash::extract()
      * @throws \InvalidArgumentException When providing invalid data.
      * @link https://book.cakephp.org/4/en/core-libraries/hash.html#Cake\Utility\Hash::nest
+     * @psalm-return list<array>
      */
     public static function nest(array $data, array $options = []): array
     {
@@ -1259,6 +1260,7 @@ class Hash
             }
         }
 
+        /** @psalm-var list<array> */
         return array_values($return);
     }
 }

+ 1 - 0
src/View/Form/ArrayContext.php

@@ -259,6 +259,7 @@ class ArrayContext implements ContextInterface
         $schema = $this->_context['schema'];
         unset($schema['_constraints'], $schema['_indexes']);
 
+        /** @psalm-var list<string> */
         return array_keys($schema);
     }
 

+ 1 - 0
src/View/Form/ContextInterface.php

@@ -97,6 +97,7 @@ interface ContextInterface
      * Get the field names of the top level object in this context.
      *
      * @return array<string> A list of the field names in the context.
+     * @psalm-return list<string>
      */
     public function fieldNames(): array;
 

+ 1 - 0
src/View/Form/EntityContext.php

@@ -559,6 +559,7 @@ class EntityContext implements ContextInterface
      * If the context is for an array of entities, the 0th index will be used.
      *
      * @return array<string> Array of field names in the table/entity.
+     * @psalm-return list<string>
      */
     public function fieldNames(): array
     {