Skip to content

Commit 94d8125

Browse files
committed
use phpstan 2.X
1 parent 6214ed0 commit 94d8125

File tree

8 files changed

+22
-20
lines changed

8 files changed

+22
-20
lines changed

generated/8.1/mbstring.php

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/8.2/mbstring.php

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/8.3/mbstring.php

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/8.4/mbstring.php

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/8.5/mbstring.php

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generator/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"php": "^8.3",
1212
"ext-simplexml": "*",
1313
"ext-json": "*",
14-
"phpstan/phpstan": "^1",
14+
"phpstan/phpstan": "^2",
1515
"symfony/console": "^7",
1616
"symfony/process": "^7",
1717
"symfony/finder": "^7"

generator/composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generator/src/PhpStanFunctions/PhpStanType.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public function __construct(string|\SimpleXMLElement $data, bool $writeOnly = fa
7373
$returnType = '';
7474
}
7575
foreach ($returnTypes as &$returnType) {
76+
$returnType = \trim($returnType);
7677
if (str_contains($returnType, '?')) {
7778
$nullable = true;
7879
$returnType = \str_replace('?', '', $returnType);
@@ -87,19 +88,20 @@ public function __construct(string|\SimpleXMLElement $data, bool $writeOnly = fa
8788
$returnType = 'string';
8889
}
8990

90-
if ($returnType === 'positive-int') {
91-
$returnType = 'int';
92-
} elseif (is_numeric($returnType)) {
91+
if ($returnType === 'positive-int' ||
92+
str_contains($returnType, 'int<') ||
93+
str_contains($returnType, 'int-mask<') ||
94+
is_numeric($returnType) ||
95+
# constants like FTP_ASCII, FTP_BINARY
96+
(defined($returnType) && is_numeric(constant($returnType)))
97+
) {
9398
$returnType = 'int';
9499
}
100+
95101
if (str_contains($returnType, 'list<')) {
96102
$returnType = \str_replace('list', 'array', $returnType);
97103
}
98104

99-
if (str_contains($returnType, 'int<')) {
100-
$returnType = 'int';
101-
}
102-
103105
$returnType = Type::toRootNamespace($returnType);
104106
}
105107
sort($returnTypes);

0 commit comments

Comments
 (0)