-
Notifications
You must be signed in to change notification settings - Fork 476
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#10580 Closes phpstan/phpstan#11939 Closes phpstan/phpstan#10338 Closes phpstan/phpstan#12048 Closes phpstan/phpstan#3107
- Loading branch information
1 parent
a2d5bb1
commit 3ff4184
Showing
9 changed files
with
188 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
function (): void { | ||
$content = file_get_contents(''); | ||
if ($content == '') { | ||
die; | ||
} | ||
|
||
assertType('string', $content); | ||
}; |
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,23 @@ | ||
<?php | ||
|
||
namespace Bug3107; | ||
|
||
class Holder | ||
{ | ||
/** @var string */ | ||
public $val; | ||
} | ||
|
||
/** @param mixed $mixed */ | ||
function test($mixed): void | ||
{ | ||
$holder = new Holder(); | ||
$holder->val = $mixed; | ||
|
||
$a = []; | ||
$a[$holder->val] = 1; | ||
take($a); | ||
} | ||
|
||
/** @param array<string, int> $a */ | ||
function take($a): void {} |
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,36 @@ | ||
<?php // lint >= 8.0 | ||
|
||
namespace Bug10580; | ||
|
||
interface FooI { | ||
/** @return $this */ | ||
public function fooThisInterface(): FooI; | ||
/** @return $this */ | ||
public function fooThisClass(): FooI; | ||
/** @return $this */ | ||
public function fooThisSelf(): self; | ||
/** @return $this */ | ||
public function fooThisStatic(): static; | ||
} | ||
|
||
final class FooA implements FooI | ||
{ | ||
public function fooThisInterface(): FooI { return new FooA(); } | ||
public function fooThisClass(): FooA { return new FooA(); } | ||
public function fooThisSelf(): self { return new FooA(); } | ||
public function fooThisStatic(): static { return new FooA(); } | ||
} | ||
|
||
final class FooB implements FooI | ||
{ | ||
/** @return $this */ | ||
public function fooThisInterface(): FooI { return new FooB(); } | ||
/** @return $this */ | ||
public function fooThisClass(): FooB { return new FooB(); } | ||
/** @return $this */ | ||
public function fooThisSelf(): self { return new FooB(); } | ||
/** @return $this */ | ||
public function fooThisStatic(): static { return new FooB(); } | ||
/** @return $this */ | ||
public function fooThis(): static { return new FooB(); } | ||
} |
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,36 @@ | ||
<?php // lint >= 8.1 | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bug11939; | ||
|
||
enum What | ||
{ | ||
case This; | ||
case That; | ||
|
||
/** | ||
* @return ($this is self::This ? 'here' : 'there') | ||
*/ | ||
public function where(): string | ||
{ | ||
return match ($this) { | ||
self::This => 'here', | ||
self::That => 'there' | ||
}; | ||
} | ||
} | ||
|
||
class Where | ||
{ | ||
/** | ||
* @return ($what is What::This ? 'here' : 'there') | ||
*/ | ||
public function __invoke(What $what): string | ||
{ | ||
return match ($what) { | ||
What::This => 'here', | ||
What::That => 'there' | ||
}; | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
namespace Bug12048; | ||
|
||
class HelloWorld | ||
{ | ||
/** @phpstan-pure */ | ||
public function sayHello(string $s): string | ||
{ | ||
$a = md5( $s ); | ||
$a .= hash( 'md5', $s ); | ||
$a .= hash_hmac( 'sha1', $s, 'b' ); | ||
|
||
$a .= hash( 'sha256', $s ); | ||
$a .= hash_hmac( 'sha256', $s, 'b' ); | ||
|
||
return $a; | ||
} | ||
} |