-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ConstantArrayTypeBuilder - allow setting union offset and keep array …
…shape
- Loading branch information
1 parent
d808819
commit 1517bf8
Showing
7 changed files
with
75 additions
and
42 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
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
41 changes: 41 additions & 0 deletions
41
tests/PHPStan/Analyser/data/constant-array-set-multi-type.php
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,41 @@ | ||
<?php | ||
|
||
namespace ConstantArrayTypeSetMultiType; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class Foo | ||
{ | ||
|
||
public function doFoo(): void | ||
{ | ||
$a = []; | ||
$b = 'foo'; | ||
if (rand(0, 1)) { | ||
$b = 'bar'; | ||
} elseif (rand(0, 1)) { | ||
$b = 'baz'; | ||
} elseif (rand(0, 1)) { | ||
$b = 'lorem'; | ||
} | ||
|
||
$a[$b] = 'test'; | ||
assertType("array{bar: 'test'}|array{baz: 'test'}|array{foo: 'test'}|array{lorem: 'test'}", $a); | ||
} | ||
|
||
public function doFoo2(): void | ||
{ | ||
$b = 'foo'; | ||
if (rand(0, 1)) { | ||
$b = 'bar'; | ||
} elseif (rand(0, 1)) { | ||
$b = 'baz'; | ||
} elseif (rand(0, 1)) { | ||
$b = 'lorem'; | ||
} | ||
|
||
$c = [$b => 'test']; | ||
assertType("array{bar: 'test'}|array{baz: 'test'}|array{foo: 'test'}|array{lorem: 'test'}", $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