Browse Source

Fix more psalm errors

ADmad 6 years ago
parent
commit
357e686fc3

+ 0 - 32
psalm-baseline.xml

@@ -321,12 +321,6 @@
       <code>static::alias($shell, "$plugin.$shell")</code>
       <code>static::alias($shell)</code>
     </DeprecatedClass>
-    <LessSpecificReturnStatement occurrences="1">
-      <code>$instance</code>
-    </LessSpecificReturnStatement>
-    <MoreSpecificReturnType occurrences="1">
-      <code>Shell</code>
-    </MoreSpecificReturnType>
     <UndefinedConstant occurrences="1">
       <code>CAKE_CORE_INCLUDE_PATH</code>
     </UndefinedConstant>
@@ -417,16 +411,10 @@
     </PropertyNotSetInConstructor>
   </file>
   <file src="src/Controller/ComponentRegistry.php">
-    <LessSpecificReturnStatement occurrences="1">
-      <code>$instance</code>
-    </LessSpecificReturnStatement>
     <MoreSpecificImplementedParamType occurrences="2">
       <code>$class</code>
       <code>$class</code>
     </MoreSpecificImplementedParamType>
-    <MoreSpecificReturnType occurrences="1">
-      <code>Component</code>
-    </MoreSpecificReturnType>
     <PropertyNotSetInConstructor occurrences="1">
       <code>ComponentRegistry</code>
     </PropertyNotSetInConstructor>
@@ -1153,9 +1141,6 @@
     </MoreSpecificImplementedParamType>
   </file>
   <file src="src/Database/Type/DateTimeType.php">
-    <LessSpecificReturnStatement occurrences="1">
-      <code>$date</code>
-    </LessSpecificReturnStatement>
     <MissingParamType occurrences="1">
       <code>$name</code>
     </MissingParamType>
@@ -1163,9 +1148,6 @@
       <code>$value</code>
       <code>$value</code>
     </MoreSpecificImplementedParamType>
-    <MoreSpecificReturnType occurrences="1">
-      <code>?DateTimeInterface</code>
-    </MoreSpecificReturnType>
     <PossiblyInvalidArgument occurrences="2">
       <code>$value</code>
       <code>$value</code>
@@ -1202,14 +1184,6 @@
       <code>$this-&gt;_driver</code>
     </PossiblyNullArgument>
   </file>
-  <file src="src/Database/TypeFactory.php">
-    <LessSpecificReturnStatement occurrences="1">
-      <code>static::$_builtTypes[$name] = new static::$_types[$name]($name)</code>
-    </LessSpecificReturnStatement>
-    <MoreSpecificReturnType occurrences="1">
-      <code>TypeInterface</code>
-    </MoreSpecificReturnType>
-  </file>
   <file src="src/Datasource/ConnectionManager.php">
     <PossiblyNullArgument occurrences="1">
       <code>$config</code>
@@ -1947,16 +1921,10 @@
     </PropertyNotSetInConstructor>
   </file>
   <file src="src/ORM/BehaviorRegistry.php">
-    <LessSpecificReturnStatement occurrences="1">
-      <code>$instance</code>
-    </LessSpecificReturnStatement>
     <MoreSpecificImplementedParamType occurrences="2">
       <code>$class</code>
       <code>$class</code>
     </MoreSpecificImplementedParamType>
-    <MoreSpecificReturnType occurrences="1">
-      <code>Behavior</code>
-    </MoreSpecificReturnType>
     <PropertyNotSetInConstructor occurrences="2">
       <code>$_table</code>
       <code>BehaviorRegistry</code>

+ 1 - 0
src/Console/ShellDispatcher.php

@@ -381,6 +381,7 @@ class ShellDispatcher
     protected function _createShell(string $className, string $shortName): Shell
     {
         [$plugin] = pluginSplit($shortName);
+        /** @var \Cake\Console\Shell $instance */
         $instance = new $className();
         $instance->plugin = trim((string)$plugin, '.');
 

+ 1 - 0
src/Controller/ComponentRegistry.php

@@ -124,6 +124,7 @@ class ComponentRegistry extends ObjectRegistry implements EventDispatcherInterfa
      */
     protected function _create($class, string $alias, array $config): Component
     {
+        /** @var \Cake\Controller\Component $instance */
         $instance = new $class($this, $config);
         $enable = $config['enabled'] ?? true;
         if ($enable) {

+ 4 - 0
src/Database/Expression/QueryExpression.php

@@ -425,6 +425,7 @@ class QueryExpression implements ExpressionInterface, Countable
             return $conditions(new static([], $this->getTypeMap()->setTypes($types)));
         }
 
+        /** @var \Cake\Database\Expression\QueryExpression */
         return new static($conditions, $this->getTypeMap()->setTypes($types));
     }
 
@@ -443,6 +444,7 @@ class QueryExpression implements ExpressionInterface, Countable
             return $conditions(new static([], $this->getTypeMap()->setTypes($types), 'OR'));
         }
 
+        /** @var \Cake\Database\Expression\QueryExpression */
         return new static($conditions, $this->getTypeMap()->setTypes($types), 'OR');
     }
 // phpcs:enable
@@ -656,6 +658,7 @@ class QueryExpression implements ExpressionInterface, Countable
             $numericKey = is_numeric($k);
 
             if ($this->isCallable($c)) {
+                /** @var \Cake\Database\Expression\QueryExpression $expr */
                 $expr = new static([], $typeMap);
                 $c = $c($expr, $this);
             }
@@ -687,6 +690,7 @@ class QueryExpression implements ExpressionInterface, Countable
             }
 
             if ($numericKey && $isArray || $isOperator) {
+                /** @var \Cake\Database\Expression\QueryExpression $this->_conditions[] */
                 $this->_conditions[] = new static($c, $typeMap, $numericKey ? 'AND' : $k);
                 continue;
             }

+ 2 - 0
src/Database/Type/DateTimeType.php

@@ -234,10 +234,12 @@ class DateTimeType extends BaseType
             }
             $isString = is_string($value);
             if (ctype_digit($value)) {
+                /** @var \DateTimeInterface $date */
                 $date = new $class('@' . $value);
             } elseif ($isString && $this->_useLocaleParser) {
                 return $this->_parseValue($value);
             } elseif ($isString) {
+                /** @var \DateTimeInterface $date */
                 $date = new $class($value);
                 $compare = true;
             }

+ 1 - 0
src/Database/TypeFactory.php

@@ -73,6 +73,7 @@ class TypeFactory
             throw new InvalidArgumentException(sprintf('Unknown type "%s"', $name));
         }
 
+        /** @var \Cake\Database\TypeInterface */
         return static::$_builtTypes[$name] = new static::$_types[$name]($name);
     }
 

+ 1 - 0
src/ORM/BehaviorRegistry.php

@@ -141,6 +141,7 @@ class BehaviorRegistry extends ObjectRegistry implements EventDispatcherInterfac
      */
     protected function _create($class, string $alias, array $config): Behavior
     {
+        /** @var \Cake\ORM\Behavior $instance */
         $instance = new $class($this->_table, $config);
         $enable = $config['enabled'] ?? true;
         if ($enable) {