-
Notifications
You must be signed in to change notification settings - Fork 426
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#3608 Closes phpstan/phpstan#3669 Closes phpstan/phpstan#3920 Closes phpstan/phpstan#3261 Closes phpstan/phpstan#4289 Closes phpstan/phpstan#2568
- Loading branch information
1 parent
fe4c770
commit 3c43c54
Showing
11 changed files
with
186 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
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,13 @@ | ||
<?php | ||
|
||
namespace Bug2568; | ||
|
||
/** | ||
* @template T | ||
* | ||
* @param array<T, mixed> $arr | ||
* @return array<int, T> | ||
*/ | ||
function my_array_keys($arr) { | ||
return array_keys($arr); | ||
} |
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 // lint >= 7.4 | ||
|
||
namespace Bug3261; | ||
|
||
class A | ||
{ | ||
} | ||
|
||
class B extends A {} | ||
|
||
function (): void { | ||
/** @var A[] $a */ | ||
$a = []; | ||
|
||
array_filter( | ||
$a, | ||
fn (A $a) => $a instanceof B | ||
); | ||
|
||
}; |
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,29 @@ | ||
<?php | ||
|
||
namespace Bug3608; | ||
|
||
interface IHost | ||
{ | ||
/** @return IHost[] * */ | ||
public static function getArray(); | ||
} | ||
|
||
class MyHost implements IHost | ||
{ | ||
public static function getArray() | ||
{ | ||
return [new self()]; | ||
} | ||
} | ||
|
||
class HelloWorld | ||
{ | ||
/** | ||
* @param class-string<IHost> $name | ||
**/ | ||
public function getConfig(string $name): void | ||
{ | ||
call_user_func([$name, 'getArray']); | ||
|
||
} | ||
} |
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 Bug3920; | ||
|
||
class HelloWorld | ||
{ | ||
/** | ||
* @return class-string<Two> | ||
*/ | ||
public function sayHello(string $a) | ||
{ | ||
|
||
$arr = [ | ||
'a' => Two::class, | ||
'c' => Two::class, | ||
]; | ||
return $arr[$a]; | ||
} | ||
|
||
public function sayType(): void | ||
{ | ||
call_user_func([One::class, 'isType']); | ||
call_user_func([Two::class, 'isType']); | ||
$class = $this->sayHello('a'); | ||
$type = $class::isType(); | ||
$callable = [$class, 'isType']; | ||
call_user_func($callable); | ||
if (is_callable($callable)) { | ||
call_user_func($callable); | ||
} | ||
} | ||
} | ||
|
||
class One { | ||
public static function isType(): bool | ||
{ | ||
return true; | ||
} | ||
} | ||
class Two extends One { | ||
|
||
} | ||
class Three {} |
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,15 @@ | ||
<?php | ||
|
||
namespace Bug3669; | ||
|
||
function foo(): \Generator | ||
{ | ||
while ($bar = yield 'foo') { | ||
} | ||
} | ||
|
||
function bar($m): \Generator | ||
{ | ||
while ($bar = yield $m) { | ||
} | ||
} |
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,28 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug4289; | ||
|
||
class BaseClass | ||
{ | ||
protected array $fields = []; | ||
|
||
function populateFields(): void | ||
{ | ||
$this->fields = [ | ||
'foo' => 'bar', | ||
'some' => 'what', | ||
]; | ||
} | ||
} | ||
|
||
class ChildClass extends BaseClass | ||
{ | ||
public function populateFields(): void | ||
{ | ||
if (empty($this->fields)) { | ||
parent::populateFields(); | ||
|
||
unset($this->fields['foo']); | ||
} | ||
} | ||
} |