-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Empty array infers key and value type as never
- Loading branch information
1 parent
7ddd284
commit c2b9e71
Showing
13 changed files
with
212 additions
and
34 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
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,55 @@ | ||
<?php | ||
|
||
namespace GenericsEmptyArray; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class Foo | ||
{ | ||
|
||
/** | ||
* @template TKey of array-key | ||
* @template T | ||
* @param array<T, TKey> $a | ||
* @return array{TKey, T} | ||
*/ | ||
public function doFoo(array $a = []): array | ||
{ | ||
|
||
} | ||
|
||
public function doBar() | ||
{ | ||
assertType('array{*NEVER*, *NEVER*}', $this->doFoo()); | ||
assertType('array{*NEVER*, *NEVER*}', $this->doFoo([])); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* @template TKey of array-key | ||
* @template T | ||
*/ | ||
class ArrayCollection | ||
{ | ||
|
||
/** | ||
* @param array<TKey, T> $items | ||
*/ | ||
public function __construct(array $items = []) | ||
{ | ||
|
||
} | ||
|
||
} | ||
|
||
class Bar | ||
{ | ||
|
||
public function doFoo() | ||
{ | ||
assertType('GenericsEmptyArray\\ArrayCollection<*NEVER*, *NEVER*>', new ArrayCollection()); | ||
assertType('GenericsEmptyArray\\ArrayCollection<*NEVER*, *NEVER*>', new ArrayCollection([])); | ||
} | ||
|
||
} |
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,25 @@ | ||
<?php | ||
|
||
namespace GenericsEmptyArrayCall; | ||
|
||
class Foo | ||
{ | ||
|
||
/** | ||
* @template TKey of array-key | ||
* @template T | ||
* @param array<TKey, T> $a | ||
* @return array{TKey, T} | ||
*/ | ||
public function doFoo(array $a = []): array | ||
{ | ||
|
||
} | ||
|
||
public function doBar() | ||
{ | ||
$this->doFoo(); | ||
$this->doFoo([]); | ||
} | ||
|
||
} |
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