-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
927d71f
commit 5473b67
Showing
6 changed files
with
95 additions
and
3 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
83 changes: 83 additions & 0 deletions
83
tests/PHPStan/Rules/Methods/data/array-push-preserves-list.php
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,83 @@ | ||
<?php | ||
|
||
namespace ArrayPushPreservesList; | ||
|
||
use function array_unshift; | ||
|
||
class Foo | ||
{ | ||
|
||
/** | ||
* @param list<int> $a | ||
* @return list<int> | ||
*/ | ||
public function doFoo(array $a): array | ||
{ | ||
array_push($a, ...$a); | ||
|
||
return $a; | ||
} | ||
|
||
/** | ||
* @param list<int> $a | ||
* @return list<int> | ||
*/ | ||
public function doFoo2(array $a): array | ||
{ | ||
array_push($a, ...[1, 2, 3]); | ||
|
||
return $a; | ||
} | ||
|
||
/** | ||
* @param list<int> $a | ||
* @return list<int> | ||
*/ | ||
public function doFoo3(array $a): array | ||
{ | ||
$b = [1, 2, 3]; | ||
array_push($b, ...$a); | ||
|
||
return $b; | ||
} | ||
|
||
} | ||
|
||
class Bar | ||
{ | ||
|
||
/** | ||
* @param list<int> $a | ||
* @return list<int> | ||
*/ | ||
public function doFoo(array $a): array | ||
{ | ||
array_unshift($a, ...$a); | ||
|
||
return $a; | ||
} | ||
|
||
/** | ||
* @param list<int> $a | ||
* @return list<int> | ||
*/ | ||
public function doFoo2(array $a): array | ||
{ | ||
array_unshift($a, ...[1, 2, 3]); | ||
|
||
return $a; | ||
} | ||
|
||
/** | ||
* @param list<int> $a | ||
* @return list<int> | ||
*/ | ||
public function doFoo3(array $a): array | ||
{ | ||
$b = [1, 2, 3]; | ||
array_unshift($b, ...$a); | ||
|
||
return $b; | ||
} | ||
|
||
} |