forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix native type of array after
array_push()
Closes phpstan/phpstan#9403
- Loading branch information
1 parent
903ffc6
commit 564f79f
Showing
5 changed files
with
158 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Bug9403; | ||
|
||
use function PHPStan\Testing\assertNativeType; | ||
use function PHPStan\Testing\assertType; | ||
|
||
class HelloWorld | ||
{ | ||
|
||
/** | ||
* @param int $max | ||
* @return int[] | ||
*/ | ||
public function testMe(int $max): array | ||
{ | ||
$result = []; | ||
for ($i = 0; $i < $max; $i++) { | ||
array_push($result, $i); | ||
} | ||
|
||
assertType('list<int<0, max>>', $result); | ||
assertNativeType('list<int<0, max>>', $result); | ||
|
||
if (!empty($result)) { | ||
rsort($result); | ||
} | ||
return $result; | ||
} | ||
|
||
} |