-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some sort functions do not preserve a list
- Loading branch information
1 parent
fbc6bca
commit 034f731
Showing
4 changed files
with
118 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace Bug10627; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class HelloWorld | ||
{ | ||
public function sayHello(): void | ||
{ | ||
$list = ['A', 'C', 'B']; | ||
natcasesort($list); | ||
assertType("non-empty-array<0|1|2, 'A'|'B'|'C'>", $list); | ||
} | ||
|
||
public function sayHello2(): void | ||
{ | ||
$list = ['A', 'C', 'B']; | ||
natsort($list); | ||
assertType("non-empty-array<0|1|2, 'A'|'B'|'C'>", $list); | ||
} | ||
|
||
public function sayHello3(): void | ||
{ | ||
$list = ['A', 'C', 'B']; | ||
arsort($list); | ||
assertType("non-empty-array<0|1|2, 'A'|'B'|'C'>", $list); | ||
} | ||
|
||
public function sayHello4(): void | ||
{ | ||
$list = ['A', 'C', 'B']; | ||
asort($list); | ||
assertType("non-empty-array<0|1|2, 'A'|'B'|'C'>", $list); | ||
} | ||
|
||
public function sayHello5(): void | ||
{ | ||
$list = ['A', 'C', 'B']; | ||
ksort($list); | ||
assertType("non-empty-array<0|1|2, 'A'|'B'|'C'>", $list); | ||
} | ||
|
||
public function sayHello6(): void | ||
{ | ||
$list = ['A', 'C', 'B']; | ||
uasort($list, function () { | ||
|
||
}); | ||
assertType("non-empty-array<0|1|2, 'A'|'B'|'C'>", $list); | ||
} | ||
|
||
public function sayHello7(): void | ||
{ | ||
$list = ['A', 'C', 'B']; | ||
uksort($list, function () { | ||
|
||
}); | ||
assertType("non-empty-array<0|1|2, 'A'|'B'|'C'>", $list); | ||
} | ||
|
||
public function sayHello8(): void | ||
{ | ||
$list = ['A', 'C', 'B']; | ||
krsort($list); | ||
assertType("non-empty-array<0|1|2, 'A'|'B'|'C'>", $list); | ||
} | ||
|
||
/** | ||
* @param list<string> $list | ||
* @return void | ||
*/ | ||
public function sayHello9(array $list): void | ||
{ | ||
krsort($list); | ||
assertType("array<int<0, max>, string>", $list); | ||
} | ||
} |
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