From 94d81259284068c3311c70b238fc385c916b9ce0 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 9 Feb 2025 16:57:02 +0000 Subject: [PATCH] use phpstan 2.X --- generated/8.1/mbstring.php | 2 +- generated/8.2/mbstring.php | 2 +- generated/8.3/mbstring.php | 2 +- generated/8.4/mbstring.php | 2 +- generated/8.5/mbstring.php | 2 +- generator/composer.json | 2 +- generator/composer.lock | 14 +++++++------- generator/src/PhpStanFunctions/PhpStanType.php | 16 +++++++++------- 8 files changed, 22 insertions(+), 20 deletions(-) diff --git a/generated/8.1/mbstring.php b/generated/8.1/mbstring.php index ac717e41..c95a8bc9 100644 --- a/generated/8.1/mbstring.php +++ b/generated/8.1/mbstring.php @@ -74,7 +74,7 @@ function mb_convert_encoding($string, string $to_encoding, $from_encoding = null * Sets the automatic character * encoding detection order to encoding. * - * @param mixed $encoding encoding is an array or + * @param non-empty-array|non-falsy-string $encoding encoding is an array or * comma separated list of character encoding. See supported encodings. * * If encoding is omitted or NULL, it returns diff --git a/generated/8.2/mbstring.php b/generated/8.2/mbstring.php index 5de5c520..a31938e1 100644 --- a/generated/8.2/mbstring.php +++ b/generated/8.2/mbstring.php @@ -77,7 +77,7 @@ function mb_convert_encoding($string, string $to_encoding, $from_encoding = null * Sets the automatic character * encoding detection order to encoding. * - * @param mixed $encoding encoding is an array or + * @param non-empty-array|non-falsy-string $encoding encoding is an array or * comma separated list of character encoding. See supported encodings. * * If encoding is omitted or NULL, it returns diff --git a/generated/8.3/mbstring.php b/generated/8.3/mbstring.php index 5de5c520..a31938e1 100644 --- a/generated/8.3/mbstring.php +++ b/generated/8.3/mbstring.php @@ -77,7 +77,7 @@ function mb_convert_encoding($string, string $to_encoding, $from_encoding = null * Sets the automatic character * encoding detection order to encoding. * - * @param mixed $encoding encoding is an array or + * @param non-empty-array|non-falsy-string $encoding encoding is an array or * comma separated list of character encoding. See supported encodings. * * If encoding is omitted or NULL, it returns diff --git a/generated/8.4/mbstring.php b/generated/8.4/mbstring.php index d5432627..2a0b4f09 100644 --- a/generated/8.4/mbstring.php +++ b/generated/8.4/mbstring.php @@ -77,7 +77,7 @@ function mb_convert_encoding($string, string $to_encoding, $from_encoding = null * Sets the automatic character * encoding detection order to encoding. * - * @param mixed $encoding encoding is an array or + * @param non-empty-array|non-falsy-string $encoding encoding is an array or * comma separated list of character encoding. See supported encodings. * * If encoding is omitted or NULL, it returns diff --git a/generated/8.5/mbstring.php b/generated/8.5/mbstring.php index d5432627..2a0b4f09 100644 --- a/generated/8.5/mbstring.php +++ b/generated/8.5/mbstring.php @@ -77,7 +77,7 @@ function mb_convert_encoding($string, string $to_encoding, $from_encoding = null * Sets the automatic character * encoding detection order to encoding. * - * @param mixed $encoding encoding is an array or + * @param non-empty-array|non-falsy-string $encoding encoding is an array or * comma separated list of character encoding. See supported encodings. * * If encoding is omitted or NULL, it returns diff --git a/generator/composer.json b/generator/composer.json index 555f1c15..08fd0457 100644 --- a/generator/composer.json +++ b/generator/composer.json @@ -11,7 +11,7 @@ "php": "^8.3", "ext-simplexml": "*", "ext-json": "*", - "phpstan/phpstan": "^1", + "phpstan/phpstan": "^2", "symfony/console": "^7", "symfony/process": "^7", "symfony/finder": "^7" diff --git a/generator/composer.lock b/generator/composer.lock index 91016646..0bd65a4f 100644 --- a/generator/composer.lock +++ b/generator/composer.lock @@ -4,24 +4,24 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a1d21e048fd90dc9c48db9427b14407c", + "content-hash": "9248a405e94bae2f2709e35a62b3893d", "packages": [ { "name": "phpstan/phpstan", - "version": "1.12.17", + "version": "2.1.3", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "7027b3b0270bf392de0cfba12825979768d728bf" + "reference": "64ae44e48214f3deebdaeebf2694297a10a2bea9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7027b3b0270bf392de0cfba12825979768d728bf", - "reference": "7027b3b0270bf392de0cfba12825979768d728bf", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/64ae44e48214f3deebdaeebf2694297a10a2bea9", + "reference": "64ae44e48214f3deebdaeebf2694297a10a2bea9", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -62,7 +62,7 @@ "type": "github" } ], - "time": "2025-02-07T15:01:57+00:00" + "time": "2025-02-07T15:05:24+00:00" }, { "name": "psr/container", diff --git a/generator/src/PhpStanFunctions/PhpStanType.php b/generator/src/PhpStanFunctions/PhpStanType.php index 48c11582..00845393 100644 --- a/generator/src/PhpStanFunctions/PhpStanType.php +++ b/generator/src/PhpStanFunctions/PhpStanType.php @@ -73,6 +73,7 @@ public function __construct(string|\SimpleXMLElement $data, bool $writeOnly = fa $returnType = ''; } foreach ($returnTypes as &$returnType) { + $returnType = \trim($returnType); if (str_contains($returnType, '?')) { $nullable = true; $returnType = \str_replace('?', '', $returnType); @@ -87,19 +88,20 @@ public function __construct(string|\SimpleXMLElement $data, bool $writeOnly = fa $returnType = 'string'; } - if ($returnType === 'positive-int') { - $returnType = 'int'; - } elseif (is_numeric($returnType)) { + if ($returnType === 'positive-int' || + str_contains($returnType, 'int<') || + str_contains($returnType, 'int-mask<') || + is_numeric($returnType) || + # constants like FTP_ASCII, FTP_BINARY + (defined($returnType) && is_numeric(constant($returnType))) + ) { $returnType = 'int'; } + if (str_contains($returnType, 'list<')) { $returnType = \str_replace('list', 'array', $returnType); } - if (str_contains($returnType, 'int<')) { - $returnType = 'int'; - } - $returnType = Type::toRootNamespace($returnType); } sort($returnTypes);