-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SplObjectStorage's ArrayAccess will never return null
- Loading branch information
1 parent
cc9a674
commit 6062437
Showing
3 changed files
with
43 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,31 @@ | ||
<?php | ||
|
||
namespace Bug4436; | ||
|
||
use function PHPStan\Analyser\assertType; | ||
|
||
class Bar | ||
{ | ||
} | ||
|
||
class Foo | ||
{ | ||
/** @var \SplObjectStorage<Bar, string> */ | ||
private \SplObjectStorage $storage; | ||
|
||
public function __construct() | ||
{ | ||
$this->storage = new \SplObjectStorage(); | ||
} | ||
|
||
public function add(Bar $bar, string $value): void | ||
{ | ||
$this->storage[$bar] = $value; | ||
} | ||
|
||
public function get(Bar $bar): string | ||
{ | ||
assertType('string', $this->storage[$bar]); | ||
return $this->storage[$bar]; | ||
} | ||
} |