Browse Source

Update phpstan's config

ADmad 6 years ago
parent
commit
2cf79efb9e

+ 1 - 1
composer.json

@@ -110,7 +110,7 @@
             "@phpstan",
             "@psalm"
         ],
-        "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12 psalm/phar:~3.8.0 && mv composer.backup composer.json"
+        "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12.7 psalm/phar:~3.8.0 && mv composer.backup composer.json"
     },
     "config": {
         "sort-packages": true,

+ 14 - 14
phpstan-baseline.neon

@@ -111,11 +111,6 @@ parameters:
 			path: src/ORM/ResultSet.php
 
 		-
-			message: "#^Method Cake\\\\ORM\\\\ResultSet\\:\\:first\\(\\) should return array\\|object but return statement is missing\\.$#"
-			count: 1
-			path: src/ORM/ResultSet.php
-
-		-
 			message: "#^Call to an undefined method Traversable\\:\\:getArrayCopy\\(\\)\\.$#"
 			count: 1
 			path: src/Collection/Iterator/ExtractIterator.php
@@ -521,19 +516,24 @@ parameters:
 			path: src/I18n/Time.php
 
 		-
+			message: "#^Access to undefined constant NumberFormatter\\:\\:CURRENCY_ACCOUNTING\\.$#"
+			count: 1
+			path: src/I18n/Number.php
+
+		-
 			message: "#^PHPDoc tag @var has invalid value \\(\\\\Psr\\\\SimpleCache\\\\CacheInterface&\\\\Cake\\\\Cache\\\\CacheEngineInterface\\|null\\)\\: Unexpected token \"\\|\", expected TOKEN_OTHER at offset 175$#"
 			count: 1
 			path: src/I18n/TranslatorRegistry.php
 
 		-
-			message: "#^Method Cake\\\\Mailer\\\\Email\\:\\:deliver\\(\\) should return static\\(Cake\\\\Mailer\\\\Email\\) but returns Cake\\\\Mailer\\\\Email\\.$#"
+			message: "#^Property Cake\\\\I18n\\\\TranslatorRegistry\\:\\:\\$_cacher has no typehint specified\\.$#"
 			count: 1
-			path: src/Mailer/Email.php
+			path: src/I18n/TranslatorRegistry.php
 
 		-
-			message: "#^Call to sprintf contains 0 placeholders, 1 value given\\.$#"
+			message: "#^Method Cake\\\\Mailer\\\\Email\\:\\:deliver\\(\\) should return static\\(Cake\\\\Mailer\\\\Email\\) but returns Cake\\\\Mailer\\\\Email\\.$#"
 			count: 1
-			path: src/Mailer/Message.php
+			path: src/Mailer/Email.php
 
 		-
 			message: "#^Method Cake\\\\Mailer\\\\Renderer\\:\\:render\\(\\) should return array\\(\\)\\|array\\('html' \\=\\> string, 'text' \\=\\> string\\) but returns array\\<string, string\\>\\.$#"
@@ -731,6 +731,11 @@ parameters:
 			path: src/TestSuite/IntegrationTestCase.php
 
 		-
+			message: "#^Unable to resolve the template type RealInstanceType in call to method PHPUnit\\\\Framework\\\\TestCase\\:\\:getMockBuilder\\(\\)$#"
+			count: 1
+			path: src/TestSuite/TestCase.php
+
+		-
 			message: "#^Result of \\|\\| is always true\\.$#"
 			count: 2
 			path: src/Utility/Hash.php
@@ -751,11 +756,6 @@ parameters:
 			path: src/View/Form/NullContext.php
 
 		-
-			message: "#^Method Cake\\\\View\\\\Helper\\:\\:__get\\(\\) should return Cake\\\\View\\\\Helper\\|null but return statement is missing\\.$#"
-			count: 1
-			path: src/View/Helper.php
-
-		-
 			message: "#^Offset 'debug' does not exist on array\\('fields' \\=\\> string, 'unlocked' \\=\\> string\\)\\.$#"
 			count: 1
 			path: src/View/Helper/FormHelper.php

+ 3 - 3
phpstan.neon

@@ -2,11 +2,11 @@ includes:
     - phpstan-baseline.neon
 
 parameters:
-    level: 5
+    level: 6
+    checkMissingIterableValueType: false
+    checkGenericClassInNonGenericObjectType: false
     autoload_files:
         - tests/bootstrap.php
-    ignoreErrors:
-        - '#Access to undefined constant NumberFormatter::CURRENCY_ACCOUNTING#'
     earlyTerminatingMethodCalls:
         Cake\Console\Shell:
             - abort

+ 1 - 0
src/Cache/Cache.php

@@ -72,6 +72,7 @@ class Cache
      * class names.
      *
      * @var string[]
+     * @psalm-var array<string, class-string>
      */
     protected static $_dsnClassMap = [
         'array' => Engine\ArrayEngine::class,

+ 2 - 0
src/Core/StaticConfigTrait.php

@@ -304,6 +304,7 @@ REGEXP;
      *
      * @param string[] $map Additions/edits to the class map to apply.
      * @return void
+     * @psalm-param array<string, class-string> $map
      */
     public static function setDsnClassMap(array $map): void
     {
@@ -314,6 +315,7 @@ REGEXP;
      * Returns the DSN class map for this class.
      *
      * @return string[]
+     * @psalm-return array<string, class-string>
      */
     public static function getDsnClassMap(): array
     {

+ 2 - 1
src/Datasource/ConnectionManager.php

@@ -50,7 +50,8 @@ class ConnectionManager
     /**
      * An array mapping url schemes to fully qualified driver class names
      *
-     * @return string[]
+     * @var string[]
+     * @psalm-var array<string, class-string>
      */
     protected static $_dsnClassMap = [
         'mysql' => Mysql::class,

+ 1 - 0
src/Log/Log.php

@@ -114,6 +114,7 @@ class Log
      * An array mapping url schemes to fully qualified Log engine class names
      *
      * @var string[]
+     * @psalm-var array<string, class-string>
      */
     protected static $_dsnClassMap = [
         'console' => Engine\ConsoleLog::class,

+ 1 - 0
src/Mailer/Mailer.php

@@ -182,6 +182,7 @@ class Mailer implements EventListenerInterface
      * Mailer driver class map.
      *
      * @var array
+     * @psalm-var array<string, class-string>
      */
     protected static $_dsnClassMap = [];
 

+ 1 - 1
src/Mailer/Message.php

@@ -1496,7 +1496,7 @@ class Message implements JsonSerializable, Serializable
         foreach ($content as $type => $text) {
             if (!in_array($type, $this->emailFormatAvailable, true)) {
                 throw new InvalidArgumentException(sprintf(
-                    'Invalid message type: "$s". Valid types are: "text", "html".',
+                    'Invalid message type: "%s". Valid types are: "text", "html".',
                     $type
                 ));
             }

+ 1 - 0
src/Mailer/TransportFactory.php

@@ -37,6 +37,7 @@ class TransportFactory
      * An array mapping url schemes to fully qualified Transport class names
      *
      * @var string[]
+     * @psalm-var array<string, class-string>
      */
     protected static $_dsnClassMap = [
         'debug' => Transport\DebugTransport::class,

+ 3 - 2
src/ORM/ResultSet.php

@@ -276,8 +276,7 @@ class ResultSet implements ResultSetInterface
      *
      * This method will also close the underlying statement cursor.
      *
-     * @return array|object
-     * @psalm-suppress InvalidNullableReturnType
+     * @return array|object|null
      */
     public function first()
     {
@@ -288,6 +287,8 @@ class ResultSet implements ResultSetInterface
 
             return $result;
         }
+
+        return null;
     }
 
     /**

+ 1 - 1
src/View/Helper.php

@@ -106,7 +106,7 @@ class Helper implements EventListenerInterface
      * Lazy loads helpers.
      *
      * @param string $name Name of the property being accessed.
-     * @return \Cake\View\Helper|null Helper instance if helper with provided name exists
+     * @return \Cake\View\Helper|null|void Helper instance if helper with provided name exists
      */
     public function __get(string $name)
     {