-
Notifications
You must be signed in to change notification settings - Fork 430
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#2434 Closes phpstan/phpstan#2220 Closes phpstan/phpstan#1871 Closes phpstan/phpstan#1707 Closes phpstan/phpstan#1664 Closes phpstan/phpstan#1661 Closes phpstan/phpstan#1656 Closes phpstan/phpstan#1613 Closes phpstan/phpstan#2682
- Loading branch information
1 parent
a0fc384
commit cb04a6e
Showing
16 changed files
with
256 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Bug1871; | ||
|
||
interface I {} | ||
|
||
class A implements I {} | ||
|
||
function(): void { | ||
$objects = [ | ||
new A() | ||
]; | ||
|
||
foreach($objects as $object) { | ||
var_dump(is_subclass_of($object, '\C')); | ||
} | ||
}; |
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,17 @@ | ||
<?php | ||
|
||
namespace Bug1664; | ||
|
||
class A | ||
{ | ||
public function a() | ||
{ | ||
$responses = [ | ||
'foo', | ||
42, | ||
'bar', | ||
]; | ||
|
||
return $responses[array_rand($responses)]; | ||
} | ||
} |
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,14 @@ | ||
<?php | ||
|
||
namespace Bug1613; | ||
|
||
class TestClass | ||
{ | ||
public function test(string $index) | ||
{ | ||
$array = [ | ||
"123" => "test" | ||
]; | ||
return array_key_exists($index, $array); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace Bug1707; | ||
|
||
class Test | ||
{ | ||
public function foo(): void | ||
{ | ||
$values = ['a' => 1, 'b' => 2]; | ||
$keys = ['a', 'b', 'c', 'd']; | ||
|
||
foreach ($keys as $key) { | ||
if(array_key_exists($key, $values)){ | ||
unset($values[$key]); | ||
} | ||
|
||
if(0 === \count($values)) { | ||
break; | ||
} | ||
} | ||
|
||
} | ||
} |
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 Bug2220; | ||
|
||
class HelloWorld | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $privateModule; | ||
|
||
public function sayHello(): void | ||
{ | ||
$resource = $this->getResource(); | ||
|
||
if ($resource === "{$this->privateModule}:abcdef") { | ||
$this->abc(); | ||
} elseif ($resource === "{$this->privateModule}:xyz") { | ||
$this->abc(); | ||
} | ||
} | ||
|
||
private function abc(): void {} | ||
|
||
private function getResource(): string { return 'string'; } | ||
} |
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,24 @@ | ||
<?php | ||
|
||
namespace Bug2434; | ||
|
||
function foo(int $param): void | ||
{ | ||
//do something | ||
} | ||
|
||
function fooWithoutVoid(int $param) | ||
{ | ||
|
||
} | ||
|
||
function (): void { | ||
register_shutdown_function('Bug2434\\foo', 1); | ||
register_shutdown_function('Bug2434\\fooWithoutVoid', 1); | ||
|
||
$parameter = new \stdClass(); | ||
|
||
$shutdown = static function (\stdClass $parameter): void {}; | ||
|
||
register_shutdown_function($shutdown, $parameter); | ||
}; |
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,16 @@ | ||
<?php | ||
|
||
namespace Bug1656; | ||
|
||
class HelloWorld | ||
{ | ||
public function test(): void | ||
{ | ||
return; | ||
} | ||
|
||
public function testVoidResult(): void | ||
{ | ||
true or $this->test(); | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
|
||
namespace Bug1661; | ||
|
||
interface I1 { | ||
public function someMethod(); | ||
} | ||
|
||
interface I2 { | ||
public function someOtherMethod(); | ||
} | ||
|
||
class Foo { | ||
/** | ||
* @return I1&static | ||
*/ | ||
public function bar() { | ||
if ($this instanceof I1) { | ||
return $this; | ||
} | ||
|
||
throw new \Exception('bad'); | ||
} | ||
|
||
/** | ||
* @return I2&static | ||
*/ | ||
public function bat() { | ||
if ($this instanceof I2) { | ||
return $this; | ||
} | ||
|
||
throw new \Exception('bad'); | ||
} | ||
} | ||
|
||
function (): void { | ||
$a = (new Foo)->bar(); | ||
$b = $a->bat(); | ||
$b->someMethod(); | ||
$b->someOtherMethod(); | ||
}; |
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 Bug2682; | ||
|
||
class HelloWorld | ||
{ | ||
public function sayHello(): void | ||
{ | ||
function(array $array) { | ||
function(): string { | ||
return 'abc'; | ||
}; | ||
}; | ||
} | ||
} |