Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes phpstan/phpstan#6464 Closes phpstan/phpstan#6423 Closes phpstan/phpstan#6418 Closes phpstan/phpstan#6230 Closes phpstan/phpstan#5860
- Loading branch information
1 parent
089d4c6
commit 0dd3d0c
Showing
7 changed files
with
172 additions
and
0 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,20 @@ | ||
<?php | ||
|
||
namespace Bug5860; | ||
|
||
class Foo | ||
{ | ||
|
||
/** | ||
* @template T | ||
* @param T $t | ||
* @return T | ||
*/ | ||
function test($t) { | ||
if ($t === null) { | ||
return $t; | ||
} | ||
return $t; | ||
} | ||
|
||
} |
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,43 @@ | ||
<?php | ||
|
||
namespace Bug6230; | ||
|
||
class Foo | ||
{ | ||
|
||
/** | ||
* @param ?iterable<mixed> $it | ||
* @return ?iterable<mixed> | ||
*/ | ||
function test($it): ?iterable | ||
{ | ||
return $it; | ||
} | ||
|
||
} | ||
|
||
/** | ||
* @template T | ||
*/ | ||
class Example | ||
{ | ||
/** | ||
* @var ?iterable<T> | ||
*/ | ||
private $input; | ||
|
||
|
||
/** | ||
* @param iterable<T> $input | ||
*/ | ||
public function __construct(iterable $input) | ||
{ | ||
$this->input = $input; | ||
} | ||
|
||
/** @return ?iterable<T> */ | ||
public function get(): ?iterable | ||
{ | ||
return $this->input; | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
namespace Bug6418; | ||
|
||
class Foo | ||
{ | ||
|
||
/** | ||
* @template T | ||
* | ||
* @param T&\DateTimeInterface $p | ||
* @return T | ||
*/ | ||
function test($p) { | ||
return $p; | ||
} | ||
|
||
} |
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,34 @@ | ||
<?php | ||
|
||
namespace Bug6423; | ||
|
||
class Foo | ||
{ | ||
|
||
|
||
/** | ||
* @param null|list<mixed> $foos | ||
*/ | ||
function doFoo(?array $foos = null): void {} | ||
|
||
/** | ||
* @return list<string> | ||
*/ | ||
function doBar(): array | ||
{ | ||
return [ | ||
'hello', | ||
'world', | ||
]; | ||
} | ||
|
||
function doBaz() | ||
{ | ||
$this->doFoo([ | ||
'foo', | ||
'bar', | ||
...$this->doBar(), | ||
]); | ||
} | ||
|
||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace Bug6464; | ||
|
||
interface Foo | ||
{ | ||
/** @param \Generator<int, mixed, mixed, void> $g */ | ||
public function foo(\Generator $g): void; | ||
} | ||
|
||
class Bar | ||
{ | ||
|
||
function test(Foo $foo): void { | ||
$foo->foo((function(string $str) { | ||
yield $str; | ||
})('hello')); | ||
} | ||
|
||
} |