Browse Source

Fix parameter name mismatches.

ADmad 5 years ago
parent
commit
19ac8faa29

+ 17 - 3
psalm-baseline.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<files psalm-version="3.12.2@7c7ebd068f8acaba211d4a2c707c4ba90874fa26">
+<files psalm-version="3.14.2@3538fe1955d47f6ee926c0769d71af6db08aa488">
   <file src="src/Collection/CollectionTrait.php">
     <ArgumentTypeCoercion occurrences="4">
       <code>$iterator</code>
@@ -19,8 +19,7 @@
     </DeprecatedClass>
   </file>
   <file src="src/Console/CommandCollection.php">
-    <DeprecatedClass occurrences="5">
-      <code>(\Cake\Console\Shell|\Cake\Console\CommandInterface|class-string)[]</code>
+    <DeprecatedClass occurrences="4">
       <code>string|\Cake\Console\Shell|\Cake\Console\CommandInterface</code>
       <code>Shell::class</code>
       <code>class-string|\Cake\Console\Shell|\Cake\Console\CommandInterface</code>
@@ -99,11 +98,26 @@
       <code>$time</code>
     </ArgumentTypeCoercion>
   </file>
+  <file src="src/I18n/Formatter/IcuFormatter.php">
+    <ParamNameMismatch occurrences="1">
+      <code>$tokenValues</code>
+    </ParamNameMismatch>
+  </file>
+  <file src="src/I18n/Formatter/SprintfFormatter.php">
+    <ParamNameMismatch occurrences="1">
+      <code>$tokensValues</code>
+    </ParamNameMismatch>
+  </file>
   <file src="src/I18n/FrozenDate.php">
     <ArgumentTypeCoercion occurrences="1">
       <code>$time</code>
     </ArgumentTypeCoercion>
   </file>
+  <file src="src/I18n/Translator.php">
+    <ParamNameMismatch occurrences="1">
+      <code>$tokensValues</code>
+    </ParamNameMismatch>
+  </file>
   <file src="src/ORM/Locator/LocatorAwareTrait.php">
     <DeprecatedClass occurrences="1">
       <code>$this</code>

+ 3 - 3
src/Cache/Engine/ArrayEngine.php

@@ -43,17 +43,17 @@ class ArrayEngine extends CacheEngine
      * Write data for key into cache
      *
      * @param string $key Identifier for the data
-     * @param mixed $data Data to be cached
+     * @param mixed $value Data to be cached
      * @param \DateInterval|int|null $ttl Optional. The TTL value of this item. If no value is sent and
      *   the driver supports TTL then the library may set a default value
      *   for it or let the driver take care of that.
      * @return bool True on success and false on failure.
      */
-    public function set($key, $data, $ttl = null): bool
+    public function set($key, $value, $ttl = null): bool
     {
         $key = $this->_key($key);
         $expires = time() + $this->duration($ttl);
-        $this->data[$key] = ['exp' => $expires, 'val' => $data];
+        $this->data[$key] = ['exp' => $expires, 'val' => $value];
 
         return true;
     }

+ 5 - 5
src/Cache/Engine/FileEngine.php

@@ -105,15 +105,15 @@ class FileEngine extends CacheEngine
      * Write data for key into cache
      *
      * @param string $key Identifier for the data
-     * @param mixed $data Data to be cached
+     * @param mixed $value Data to be cached
      * @param \DateInterval|int|null $ttl Optional. The TTL value of this item. If no value is sent and
      *   the driver supports TTL then the library may set a default value
      *   for it or let the driver take care of that.
      * @return bool True on success and false on failure.
      */
-    public function set($key, $data, $ttl = null): bool
+    public function set($key, $value, $ttl = null): bool
     {
-        if ($data === '' || !$this->_init) {
+        if ($value === '' || !$this->_init) {
             return false;
         }
 
@@ -124,11 +124,11 @@ class FileEngine extends CacheEngine
         }
 
         if (!empty($this->_config['serialize'])) {
-            $data = serialize($data);
+            $value = serialize($value);
         }
 
         $expires = time() + $this->duration($ttl);
-        $contents = implode([$expires, PHP_EOL, $data, PHP_EOL]);
+        $contents = implode([$expires, PHP_EOL, $value, PHP_EOL]);
 
         if ($this->_config['lock']) {
             /** @psalm-suppress PossiblyNullReference */

+ 3 - 3
src/Cache/Engine/MemcachedEngine.php

@@ -302,16 +302,16 @@ class MemcachedEngine extends CacheEngine
     /**
      * Write many cache entries to the cache at once
      *
-     * @param iterable $data An array of data to be stored in the cache
+     * @param iterable $values An array of data to be stored in the cache
      * @param \DateInterval|int|null $ttl Optional. The TTL value of this item. If no value is sent and
      *   the driver supports TTL then the library may set a default value
      *   for it or let the driver take care of that.
      * @return bool Whether the write was successful or not.
      */
-    public function setMultiple($data, $ttl = null): bool
+    public function setMultiple($values, $ttl = null): bool
     {
         $cacheData = [];
-        foreach ($data as $key => $value) {
+        foreach ($values as $key => $value) {
             $cacheData[$this->_key($key)] = $value;
         }
         $duration = $this->duration($ttl);

+ 3 - 3
src/Console/HelperRegistry.php

@@ -94,14 +94,14 @@ class HelperRegistry extends ObjectRegistry
      *
      * @param string $class The classname to create.
      * @param string $alias The alias of the helper.
-     * @param array $settings An array of settings to use for the helper.
+     * @param array $config An array of settings to use for the helper.
      * @return \Cake\Console\Helper The constructed helper class.
      * @psalm-suppress MoreSpecificImplementedParamType
      */
-    protected function _create($class, string $alias, array $settings): Helper
+    protected function _create($class, string $alias, array $config): Helper
     {
         // phpcs:ignore SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.InvalidFormat
         /** @var \Cake\Console\Helper */
-        return new $class($this->_io, $settings);
+        return new $class($this->_io, $config);
     }
 }

+ 2 - 2
src/Console/TaskRegistry.php

@@ -85,11 +85,11 @@ class TaskRegistry extends ObjectRegistry
      *
      * @param string $class The classname to create.
      * @param string $alias The alias of the task.
-     * @param array $settings An array of settings to use for the task.
+     * @param array $config An array of settings to use for the task.
      * @return \Cake\Console\Shell The constructed task class.
      * @psalm-suppress MoreSpecificImplementedParamType
      */
-    protected function _create($class, string $alias, array $settings): Shell
+    protected function _create($class, string $alias, array $config): Shell
     {
         // phpcs:ignore SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.InvalidFormat
         /** @var \Cake\Console\Shell */

+ 3 - 3
src/Database/Expression/FunctionExpression.php

@@ -99,7 +99,7 @@ class FunctionExpression extends QueryExpression implements TypedResultInterface
     /**
      * Adds one or more arguments for the function call.
      *
-     * @param array $params list of arguments to be passed to the function
+     * @param array $conditions list of arguments to be passed to the function
      * If associative the key would be used as argument when value is 'literal'
      * @param array $types associative array of types to be associated with the
      * passed arguments
@@ -108,11 +108,11 @@ class FunctionExpression extends QueryExpression implements TypedResultInterface
      * @return $this
      * @psalm-suppress MoreSpecificImplementedParamType
      */
-    public function add($params, array $types = [], bool $prepend = false)
+    public function add($conditions, array $types = [], bool $prepend = false)
     {
         $put = $prepend ? 'array_unshift' : 'array_push';
         $typeMap = $this->getTypeMap()->setTypes($types);
-        foreach ($params as $k => $p) {
+        foreach ($conditions as $k => $p) {
             if ($p === 'literal') {
                 $put($this->_conditions, $k);
                 continue;

+ 4 - 4
src/Database/Expression/OrderByExpression.php

@@ -62,13 +62,13 @@ class OrderByExpression extends QueryExpression
      *
      * New order by expressions are merged to existing ones
      *
-     * @param array $orders list of order by expressions
+     * @param array $conditions list of order by expressions
      * @param array $types list of types associated on fields referenced in $conditions
      * @return void
      */
-    protected function _addConditions(array $orders, array $types): void
+    protected function _addConditions(array $conditions, array $types): void
     {
-        foreach ($orders as $key => $val) {
+        foreach ($conditions as $key => $val) {
             if (
                 is_string($key) &&
                 is_string($val) &&
@@ -82,6 +82,6 @@ class OrderByExpression extends QueryExpression
             }
         }
 
-        $this->_conditions = array_merge($this->_conditions, $orders);
+        $this->_conditions = array_merge($this->_conditions, $conditions);
     }
 }

+ 4 - 4
src/Datasource/ConnectionRegistry.php

@@ -70,10 +70,10 @@ class ConnectionRegistry extends ObjectRegistry
      *
      * @param string|\Cake\Datasource\ConnectionInterface|callable $class The classname or object to make.
      * @param string $alias The alias of the object.
-     * @param array $settings An array of settings to use for the datasource.
+     * @param array $config An array of settings to use for the datasource.
      * @return \Cake\Datasource\ConnectionInterface A connection with the correct settings.
      */
-    protected function _create($class, string $alias, array $settings)
+    protected function _create($class, string $alias, array $config)
     {
         if (is_callable($class)) {
             return $class($alias);
@@ -83,11 +83,11 @@ class ConnectionRegistry extends ObjectRegistry
             return $class;
         }
 
-        unset($settings['className']);
+        unset($config['className']);
 
         // phpcs:ignore SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.InvalidFormat
         /** @var \Cake\Datasource\ConnectionInterface */
-        return new $class($settings);
+        return new $class($config);
     }
 
     /**

+ 6 - 5
src/I18n/Formatter/IcuFormatter.php

@@ -30,17 +30,18 @@ class IcuFormatter implements FormatterInterface
      * message. Variables are interpolated using the MessageFormatter class.
      *
      * @param string $locale The locale in which the message is presented.
-     * @param string $message The message to be translated
-     * @param array $vars The list of values to interpolate in the message
+     * @param string $string The message to be translated
+     * @param array $tokenValues The list of values to interpolate in the message
      * @return string The formatted message
      * @throws \Aura\Intl\Exception\CannotFormat
      * @throws \Aura\Intl\Exception\CannotInstantiateFormatter
+     * @psalm-suppress ParamNameMismatch
      */
-    public function format($locale, $message, array $vars): string
+    public function format($locale, $string, array $tokenValues): string
     {
-        unset($vars['_singular'], $vars['_count']);
+        unset($tokenValues['_singular'], $tokenValues['_count']);
 
-        return $this->_formatMessage($locale, $message, $vars);
+        return $this->_formatMessage($locale, $string, $tokenValues);
     }
 
     /**

+ 6 - 5
src/I18n/Formatter/SprintfFormatter.php

@@ -29,14 +29,15 @@ class SprintfFormatter implements FormatterInterface
      * message. Variables are interpolated using the sprintf format.
      *
      * @param string $locale The locale in which the message is presented.
-     * @param string $message The message to be translated
-     * @param array $vars The list of values to interpolate in the message
+     * @param string $string The message to be translated
+     * @param array $tokensValues The list of values to interpolate in the message
      * @return string The formatted message
+     * @psalm-suppress ParamNameMismatch
      */
-    public function format($locale, $message, array $vars): string
+    public function format($locale, $string, array $tokensValues): string
     {
-        unset($vars['_singular']);
+        unset($tokensValues['_singular']);
 
-        return vsprintf($message, $vars);
+        return vsprintf($string, $tokensValues);
     }
 }

+ 1 - 0
src/I18n/Translator.php

@@ -35,6 +35,7 @@ class Translator extends BaseTranslator
      * @param array $tokensValues Token values to interpolate into the
      *   message.
      * @return string The translated message with tokens replaced.
+     * @psalm-suppress ParamNameMismatch
      */
     public function translate($key, array $tokensValues = []): string
     {

+ 3 - 3
src/Log/LogEngineRegistry.php

@@ -64,11 +64,11 @@ class LogEngineRegistry extends ObjectRegistry
      *
      * @param string|\Psr\Log\LoggerInterface $class The classname or object to make.
      * @param string $alias The alias of the object.
-     * @param array $settings An array of settings to use for the logger.
+     * @param array $config An array of settings to use for the logger.
      * @return \Psr\Log\LoggerInterface The constructed logger class.
      * @throws \RuntimeException when an object doesn't implement the correct interface.
      */
-    protected function _create($class, string $alias, array $settings): LoggerInterface
+    protected function _create($class, string $alias, array $config): LoggerInterface
     {
         if (is_callable($class)) {
             $class = $class($alias);
@@ -80,7 +80,7 @@ class LogEngineRegistry extends ObjectRegistry
 
         if (!isset($instance)) {
             /** @psalm-suppress UndefinedClass */
-            $instance = new $class($settings);
+            $instance = new $class($config);
         }
 
         if ($instance instanceof LoggerInterface) {

+ 2 - 2
src/TestSuite/TestListenerTrait.php

@@ -86,14 +86,14 @@ trait TestListenerTrait
     /**
      * @inheritDoc
      */
-    public function addRiskyTest(Test $test, Throwable $e, float $time): void
+    public function addRiskyTest(Test $test, Throwable $t, float $time): void
     {
     }
 
     /**
      * @inheritDoc
      */
-    public function addIncompleteTest(Test $test, Throwable $e, float $time): void
+    public function addIncompleteTest(Test $test, Throwable $t, float $time): void
     {
     }
 }

+ 4 - 4
src/View/HelperRegistry.php

@@ -143,16 +143,16 @@ class HelperRegistry extends ObjectRegistry implements EventDispatcherInterface
      *
      * @param string $class The class to create.
      * @param string $alias The alias of the loaded helper.
-     * @param array $settings An array of settings to use for the helper.
+     * @param array $config An array of settings to use for the helper.
      * @return \Cake\View\Helper The constructed helper class.
      * @psalm-suppress MoreSpecificImplementedParamType
      */
-    protected function _create($class, string $alias, array $settings): Helper
+    protected function _create($class, string $alias, array $config): Helper
     {
         /** @var \Cake\View\Helper $instance */
-        $instance = new $class($this->_View, $settings);
+        $instance = new $class($this->_View, $config);
 
-        $enable = $settings['enabled'] ?? true;
+        $enable = $config['enabled'] ?? true;
         if ($enable) {
             $this->getEventManager()->on($instance);
         }