diff --git a/composer.json b/composer.json index f327f549b61..d2bac23b535 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,7 @@ "mikey179/vfsstream": "^1.6.10", "mockery/mockery": "^1.6", "paragonie/csp-builder": "^2.3 || ^3.0", - "phpstan/phpstan": "1.11.*", + "phpstan/phpstan": "1.12.0", "phpstan/extension-installer": "^1.3", "symplify/phpstan-rules": "^12.4", "phpunit/phpunit": "^10.5.5 || ^11.1.3" diff --git a/src/Database/Driver/Mysql.php b/src/Database/Driver/Mysql.php index 80d0b029e7c..21386847b9a 100644 --- a/src/Database/Driver/Mysql.php +++ b/src/Database/Driver/Mysql.php @@ -272,6 +272,7 @@ public function version(): string if (str_contains($this->_version, 'MariaDB')) { $this->serverType = static::SERVER_TYPE_MARIADB; preg_match('/^(?:5\.5\.5-)?(\d+\.\d+\.\d+.*-MariaDB[^:]*)/', $this->_version, $matches); + /** @phpstan-ignore-next-line */ $this->_version = $matches[1]; } } diff --git a/src/Database/composer.json b/src/Database/composer.json index ca18395802e..b912763efdf 100644 --- a/src/Database/composer.json +++ b/src/Database/composer.json @@ -42,6 +42,6 @@ "require-dev": { "cakephp/i18n": "^5.0", "cakephp/log": "^5.0", - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "1.12.0" } } diff --git a/src/Datasource/composer.json b/src/Datasource/composer.json index 12941a4b629..05d4619d56c 100644 --- a/src/Datasource/composer.json +++ b/src/Datasource/composer.json @@ -42,6 +42,6 @@ "cakephp/cache": "^5.0", "cakephp/collection": "^5.0", "cakephp/utility": "^5.0", - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "1.12.0" } } diff --git a/src/Http/Client/Response.php b/src/Http/Client/Response.php index 6f3b7c148b3..854aa87595c 100644 --- a/src/Http/Client/Response.php +++ b/src/Http/Client/Response.php @@ -179,8 +179,11 @@ protected function _parseHeaders(array $headers): void foreach ($headers as $value) { if (str_starts_with($value, 'HTTP/')) { preg_match('/HTTP\/([\d.]+) ([0-9]+)(.*)/i', $value, $matches); + /** @phpstan-ignore-next-line */ $this->protocol = $matches[1]; + /** @phpstan-ignore-next-line */ $this->code = (int)$matches[2]; + /** @phpstan-ignore-next-line */ $this->reasonPhrase = trim($matches[3]); continue; } diff --git a/src/Http/HeaderUtility.php b/src/Http/HeaderUtility.php index 6d80e7dfb40..ae4e004fddd 100644 --- a/src/Http/HeaderUtility.php +++ b/src/Http/HeaderUtility.php @@ -34,6 +34,10 @@ protected static function parseLinkItem(string $value): array { preg_match('/<(.*)>[; ]?[; ]?(.*)?/i', $value, $matches); + if ($matches === []) { + return []; + } + $url = $matches[1]; $parsedParams = ['link' => $url]; @@ -48,8 +52,11 @@ protected static function parseLinkItem(string $value): array // See https://www.rfc-editor.org/rfc/rfc8187#section-3.2.3 preg_match("/(.*)'(.*)'(.*)/i", $trimedValue, $matches); $trimedValue = [ + /** @phpstan-ignore-next-line */ 'language' => $matches[2], + /** @phpstan-ignore-next-line */ 'encoding' => $matches[1], + /** @phpstan-ignore-next-line */ 'value' => urldecode($matches[3]), ]; } @@ -117,6 +124,7 @@ public static function parseWwwAuthenticate(string $value): array $return = []; foreach ($matches as $match) { + /** @phpstan-ignore-next-line */ $return[$match[1]] = $match[3] ?? $match[2]; } diff --git a/src/Http/composer.json b/src/Http/composer.json index f691da675b1..409beadf1fb 100644 --- a/src/Http/composer.json +++ b/src/Http/composer.json @@ -60,6 +60,6 @@ "cakephp/orm": "^5.0", "cakephp/i18n": "^5.0", "paragonie/csp-builder": "^2.3", - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "1.12.0" } } diff --git a/src/ORM/composer.json b/src/ORM/composer.json index c29f4853403..93575e1ecab 100644 --- a/src/ORM/composer.json +++ b/src/ORM/composer.json @@ -47,6 +47,6 @@ "require-dev": { "cakephp/cache": "^5.0", "cakephp/i18n": "^5.0", - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "1.12.0" } } diff --git a/src/Validation/composer.json b/src/Validation/composer.json index 3e20e90521f..76cbd879477 100644 --- a/src/Validation/composer.json +++ b/src/Validation/composer.json @@ -37,6 +37,6 @@ }, "require-dev": { "cakephp/i18n": "^5.0", - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "1.12.0" } } diff --git a/src/View/Helper/FormHelper.php b/src/View/Helper/FormHelper.php index e92f1de3e7d..86a35b969a2 100644 --- a/src/View/Helper/FormHelper.php +++ b/src/View/Helper/FormHelper.php @@ -1352,12 +1352,15 @@ protected function enumOptions(string $enumClass): array { assert(is_subclass_of($enumClass, BackedEnum::class)); + $hasLabel = is_a($enumClass, EnumLabelInterface::class, true) || method_exists($enumClass, 'label'); $values = []; - /** @var \BackedEnum $case */ - foreach ($enumClass::cases() as $case) { - $hasLabel = $case instanceof EnumLabelInterface || method_exists($case, 'label'); - $values[$case->value] = $hasLabel ? $case->label() - : Inflector::humanize(Inflector::underscore($case->name)); + foreach ($enumClass::cases() as $enumClass) { + /** + * @psalm-suppress UndefinedInterfaceMethod + * @phpstan-ignore-next-line + */ + $values[$enumClass->value] = $hasLabel ? $enumClass->label() + : Inflector::humanize(Inflector::underscore($enumClass->name)); } return $values;