Browse Source

Merge branch '4.next' into 5.x

ADmad 4 years ago
parent
commit
0d381bd7b7

+ 1 - 1
composer.json

@@ -107,7 +107,7 @@
             "@phpstan",
             "@psalm"
         ],
-        "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:0.12.94 psalm/phar:~4.9.3 && mv composer.backup composer.json",
+        "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:0.12.96 psalm/phar:~4.10.0 && mv composer.backup composer.json",
         "test": "phpunit",
         "test-coverage": "phpunit --coverage-clover=clover.xml"
     },

+ 0 - 40
phpstan-baseline.neon

@@ -231,31 +231,6 @@ parameters:
 			path: src/Http/Client/Auth/Digest.php
 
 		-
-			message: "#^Array \\(array\\<non\\-empty\\-string, non\\-empty\\-string\\>\\) does not accept \\(int\\|string\\)\\.$#"
-			count: 1
-			path: src/Http/Client/Request.php
-
-		-
-			message: "#^Array \\(array\\<string, string\\>\\) does not accept key string\\.$#"
-			count: 1
-			path: src/Http/Client/Request.php
-
-		-
-			message: "#^Array \\(array\\<non\\-empty\\-string, non\\-empty\\-string\\>\\) does not accept string\\.$#"
-			count: 1
-			path: src/Http/Client/Response.php
-
-		-
-			message: "#^Array \\(array\\<string, array\\<int, string\\>\\>\\) does not accept key string\\.$#"
-			count: 1
-			path: src/Http/Client/Response.php
-
-		-
-			message: "#^Array \\(array\\<string, string\\>\\) does not accept key string\\.$#"
-			count: 1
-			path: src/Http/Client/Response.php
-
-		-
 			message: "#^Call to an undefined method DateTimeInterface\\:\\:setTimezone\\(\\)\\.$#"
 			count: 3
 			path: src/Http/Cookie/Cookie.php
@@ -271,21 +246,6 @@ parameters:
 			path: src/Http/Cookie/CookieCollection.php
 
 		-
-			message: "#^Array \\(array\\<non\\-empty\\-string, non\\-empty\\-string\\>\\) does not accept string\\.$#"
-			count: 1
-			path: src/Http/Response.php
-
-		-
-			message: "#^Array \\(array\\<string, array\\<int, string\\>\\>\\) does not accept key string\\.$#"
-			count: 1
-			path: src/Http/Response.php
-
-		-
-			message: "#^Array \\(array\\<string, string\\>\\) does not accept key string\\.$#"
-			count: 1
-			path: src/Http/Response.php
-
-		-
 			message: "#^Call to an undefined method DateTimeInterface\\:\\:setTimezone\\(\\)\\.$#"
 			count: 1
 			path: src/Http/Response.php

+ 2 - 1
phpunit.xml.dist

@@ -3,7 +3,8 @@
     colors="true"
     bootstrap="tests/bootstrap.php"
     backupGlobals="true"
->
+    convertDeprecationsToExceptions="true"
+    >
     <testsuites>
         <testsuite name="cakephp">
             <directory>tests/TestCase/</directory>

+ 3 - 3
src/Core/App.php

@@ -128,11 +128,11 @@ class App
             return $class;
         }
 
-        $pluginName = substr($class, 0, $pos);
-        $name = substr($class, $pos + strlen($type));
+        $pluginName = (string)substr($class, 0, $pos);
+        $name = (string)substr($class, $pos + strlen($type));
 
         if ($suffix) {
-            $name = substr($name, 0, -strlen($suffix));
+            $name = (string)substr($name, 0, -strlen($suffix));
         }
 
         $nonPluginNamespaces = [

+ 1 - 1
src/Database/Type/DateType.php

@@ -69,7 +69,7 @@ class DateType extends DateTimeType
         $date = parent::marshal($value);
         if ($date && !$date instanceof I18nDateTimeInterface) {
             // Clear time manually when I18n types aren't available and raw DateTime used
-            /** @psalm-var \DateTime|\DateTimeImmutable $date */
+            /** @var \DateTime|\DateTimeImmutable $date */
             $date->setTime(0, 0, 0);
         }
 

+ 1 - 1
src/Database/Type/ExpressionTypeCasterTrait.php

@@ -49,7 +49,7 @@ trait ExpressionTypeCasterTrait
         $multi = $type !== $baseType;
 
         if ($multi) {
-            /** @psalm-var \Cake\Database\Type\ExpressionTypeInterface $converter */
+            /** @var \Cake\Database\Type\ExpressionTypeInterface $converter */
             return array_map([$converter, 'toExpression'], $value);
         }
 

+ 1 - 1
src/Datasource/QueryTrait.php

@@ -441,7 +441,7 @@ trait QueryTrait
      * ```
      *
      * @param callable|null $formatter The formatting callable.
-     * @param int|true $mode Whether to overwrite, append or prepend the formatter.
+     * @param int|bool $mode Whether to overwrite, append or prepend the formatter.
      * @return $this
      * @throws \InvalidArgumentException
      */

+ 3 - 1
src/Http/Client.php

@@ -619,6 +619,7 @@ class Client implements ClientInterface
      */
     protected function _createRequest(string $method, string $url, mixed $data, array $options): Request
     {
+        /** @var array<non-empty-string, non-empty-string> $headers */
         $headers = (array)($options['headers'] ?? []);
         if (isset($options['type'])) {
             $headers = array_merge($headers, $this->_typeHeaders($options['type']));
@@ -647,10 +648,11 @@ class Client implements ClientInterface
      * Returns headers for Accept/Content-Type based on a short type
      * or full mime-type.
      *
+     * @phpstan-param non-empty-string $type
      * @param string $type short type alias or full mimetype.
      * @return array<string, string> Headers to set on the request.
      * @throws \Cake\Core\Exception\CakeException When an unknown type alias is used.
-     * @psalm-return array{Accept: string, Content-Type: string}
+     * @psalm-return array<non-empty-string, non-empty-string>
      */
     protected function _typeHeaders(string $type): array
     {

+ 6 - 2
src/Http/Client/Request.php

@@ -34,6 +34,7 @@ class Request extends Message implements RequestInterface
      *
      * Provides backwards compatible defaults for some properties.
      *
+     * @phpstan-param array<non-empty-string, non-empty-string> $headers
      * @param string $url The request URL
      * @param string $method The HTTP method to use.
      * @param array $headers The HTTP headers to set.
@@ -63,7 +64,8 @@ class Request extends Message implements RequestInterface
     /**
      * Add an array of headers to the request.
      *
-     * @param array $headers The headers to add.
+     * @phpstan-param array<non-empty-string, non-empty-string> $headers
+     * @param array<string, string> $headers The headers to add.
      * @return void
      */
     protected function addHeaders(array $headers): void
@@ -89,7 +91,9 @@ class Request extends Message implements RequestInterface
         if (is_array($content)) {
             $formData = new FormData();
             $formData->addMany($content);
-            $this->addHeaders(['Content-Type' => $formData->contentType()]);
+            /** @phpstan-var array<non-empty-string, non-empty-string> $headers */
+            $headers = ['Content-Type' => $formData->contentType()];
+            $this->addHeaders($headers);
             $content = (string)$formData;
         }
 

+ 1 - 0
src/Http/Client/Response.php

@@ -189,6 +189,7 @@ class Response extends Message implements ResponseInterface
             }
             [$name, $value] = explode(':', $value, 2);
             $value = trim($value);
+            /** @phpstan-var non-empty-string $name */
             $name = trim($name);
 
             $normalized = strtolower($name);

+ 1 - 0
src/Http/Response.php

@@ -543,6 +543,7 @@ class Response implements ResponseInterface, Stringable
     /**
      * Sets a header.
      *
+     * @phpstan-param non-empty-string $header
      * @param string $header Header key.
      * @param string $value Header value.
      * @return void

+ 1 - 0
src/Mailer/Message.php

@@ -1900,6 +1900,7 @@ class Message implements JsonSerializable
             }
         });
 
+        /** @psalm-var array */
         return $array;
     }
 

+ 1 - 1
src/View/AjaxView.php

@@ -18,7 +18,7 @@ namespace Cake\View;
 
 /**
  * A view class that is used for AJAX responses.
- * Currently only switches the default layout and sets the response type - which just maps to
+ * Currently, only switches the default layout and sets the response type - which just maps to
  * text/html by default.
  */
 class AjaxView extends View

+ 0 - 9
src/View/XmlView.php

@@ -82,15 +82,6 @@ class XmlView extends SerializedView
     protected string $_responseType = 'xml';
 
     /**
-     * Option to allow setting an array of custom options for Xml::fromArray()
-     *
-     * For e.g. 'format' as 'attributes' instead of 'tags'.
-     *
-     * @var array|null
-     */
-    protected ?array $xmlOptions = null;
-
-    /**
      * Default config options.
      *
      * Use ViewBuilder::setOption()/setOptions() in your controller to set these options.