Skip to content

Commit

Permalink
use phpstan 2.X
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Feb 9, 2025
1 parent 6214ed0 commit 94d8125
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion generated/8.1/mbstring.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion generated/8.2/mbstring.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion generated/8.3/mbstring.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion generated/8.4/mbstring.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion generated/8.5/mbstring.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion generator/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 7 additions & 7 deletions generator/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions generator/src/PhpStanFunctions/PhpStanType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 94d8125

Please sign in to comment.