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
db4d241
commit 75d11e7
Showing
6 changed files
with
122 additions
and
23 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,35 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug7153; | ||
|
||
use Exception; | ||
use function PHPStan\Testing\assertType; | ||
|
||
function blah(): string | ||
{ | ||
return 'blah'; | ||
} | ||
|
||
function bleh(): ?string | ||
{ | ||
return random_int(0, 1) > 0 ? 'bleh' : null; | ||
} | ||
|
||
function blih(string $blah, string $bleh): void | ||
{ | ||
} | ||
|
||
function () { | ||
$data = [blah(), bleh()]; | ||
|
||
assertType('array{string, string|null}', $data); | ||
|
||
if (in_array(null, $data, true)) { | ||
assertType('array{string, string|null}', $data); | ||
throw new Exception(); | ||
} | ||
|
||
assertType('array{string, string}', $data); | ||
|
||
blih($data[0], $data[1]); | ||
}; |
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,28 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug7275; | ||
|
||
class HelloWorld | ||
{ | ||
/** | ||
* @param array<HelloWorld|null> $collectionWithPotentialNulls | ||
* | ||
* @return mixed[] | ||
*/ | ||
public function doSomething(array $collectionWithPotentialNulls): array | ||
{ | ||
return !in_array(null, $collectionWithPotentialNulls, true) | ||
? $this->doSomethingElse($collectionWithPotentialNulls) | ||
: []; | ||
} | ||
|
||
/** | ||
* @param array<HelloWorld> $collectionWithoutNulls | ||
* | ||
* @return mixed[] | ||
*/ | ||
public function doSomethingElse(array $collectionWithoutNulls): array | ||
{ | ||
return []; | ||
} | ||
} |