-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix array intersection between HasOffsetType and HasOffsetValueType
- Loading branch information
1 parent
aa05a7d
commit 07d6405
Showing
6 changed files
with
79 additions
and
2 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,23 @@ | ||
<?php | ||
|
||
namespace Bug11518Types; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
/** | ||
* @param mixed[] $a | ||
* @return array{thing: mixed} | ||
* */ | ||
function blah(array $a): array | ||
{ | ||
if (!array_key_exists('thing', $a)) { | ||
$a['thing'] = 'bla'; | ||
assertType('hasOffsetValue(\'thing\', \'bla\')&non-empty-array', $a); | ||
} else { | ||
assertType('array&hasOffset(\'thing\')', $a); | ||
} | ||
|
||
assertType('array&hasOffsetValue(\'thing\', mixed)', $a); | ||
|
||
return $a; | ||
} |
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 Bug11518; | ||
|
||
/** | ||
* @param mixed[] $a | ||
* @return array{thing: mixed} | ||
* */ | ||
function blah(array $a): array | ||
{ | ||
if (!array_key_exists('thing', $a)) { | ||
$a['thing'] = 'bla'; | ||
} | ||
|
||
return $a; | ||
} |
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