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#4689 Closes phpstan/phpstan#7578 Closes phpstan/phpstan#6260
- Loading branch information
1 parent
6652811
commit af65434
Showing
5 changed files
with
107 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Bug4689; | ||
|
||
abstract class KeywordList | ||
{ | ||
} | ||
|
||
abstract class AbstractPlatform | ||
{ | ||
/** | ||
* @return KeywordList | ||
*/ | ||
final public function getReservedKeywordsList() | ||
{ | ||
$class = $this->getReservedKeywordsClass(); | ||
$keywords = new $class(); | ||
if (! $keywords instanceof KeywordList) { | ||
throw new \Exception(); | ||
} | ||
|
||
return $keywords; | ||
} | ||
|
||
/** | ||
* @throws \Exception If not supported on this platform. | ||
* | ||
* @psalm-return class-string<KeywordList> | ||
*/ | ||
protected function getReservedKeywordsClass(): string | ||
{ | ||
throw new \Exception(); | ||
} | ||
} |
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,14 @@ | ||
<?php // lint >= 8.0 | ||
|
||
namespace Bug6260; | ||
|
||
class Foo{ | ||
public function __construct( | ||
/** @var non-empty-array<mixed> */ | ||
private array $array | ||
){ | ||
if(count($array) === 0){ | ||
throw new \InvalidArgumentException(); | ||
} | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
namespace Bug7578; | ||
|
||
class HelloWorld | ||
{ | ||
/** | ||
* @param non-empty-array<mixed> $array | ||
*/ | ||
public function foo(array $array): void | ||
{ | ||
if ([] === $array) { | ||
throw new \InvalidArgumentException(); | ||
} | ||
} | ||
|
||
/** | ||
* @param non-empty-array<mixed> $array | ||
*/ | ||
public function foo2(array $array): void | ||
{ | ||
if (0 === count($array)) { | ||
throw new \InvalidArgumentException(); | ||
} | ||
} | ||
} |