File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -538,9 +538,9 @@ public function specifyTypesInCondition(
538538 (
539539 $ expr instanceof Expr \Isset_
540540 && count ($ expr ->vars ) > 0
541- && $ context ->truthy ()
541+ && $ context ->true ()
542542 )
543- || ($ expr instanceof Expr \Empty_ && $ context ->falsey ())
543+ || ($ expr instanceof Expr \Empty_ && $ context ->false ())
544544 ) {
545545 $ vars = [];
546546 if ($ expr instanceof Expr \Isset_) {
Original file line number Diff line number Diff line change @@ -10209,6 +10209,16 @@ public function dataCount(): array
1020910209 return $ this ->gatherAssertTypes (__DIR__ . '/data/count-type.php ' );
1021010210 }
1021110211
10212+ public function dataBug2816 (): array
10213+ {
10214+ return $ this ->gatherAssertTypes (__DIR__ . '/data/bug-2816.php ' );
10215+ }
10216+
10217+ public function dataBug2816Two (): array
10218+ {
10219+ return $ this ->gatherAssertTypes (__DIR__ . '/data/bug-2816-2.php ' );
10220+ }
10221+
1021210222 public function dataBug3985 (): array
1021310223 {
1021410224 return $ this ->gatherAssertTypes (__DIR__ . '/data/bug-3985.php ' );
@@ -10298,6 +10308,8 @@ public function dataBug3985(): array
1029810308 * @dataProvider dataBug1924
1029910309 * @dataProvider dataExtraIntTypes
1030010310 * @dataProvider dataCount
10311+ * @dataProvider dataBug2816
10312+ * @dataProvider dataBug2816Two
1030110313 * @dataProvider dataBug3985
1030210314 * @param string $assertType
1030310315 * @param string $file
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug2816 ;
4+
5+ use PHPStan \TrinaryLogic ;
6+ use function PHPStan \Analyser \assertType ;
7+ use function PHPStan \Analyser \assertVariableCertainty ;
8+
9+ if (isset ($ _GET ['x ' ])) {
10+ $ a = 1 ;
11+ }
12+
13+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ a );
14+ assertType ('mixed ' , $ a );
15+
16+ if (isset ($ a )) {
17+ echo "hello " ;
18+ assertVariableCertainty (TrinaryLogic::createYes (), $ a );
19+ assertType ('mixed~null ' , $ a );
20+ } else {
21+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ a );
22+ }
23+
24+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ a );
25+ assertType ('mixed ' , $ a );
26+
27+ if (isset ($ a )) {
28+ echo "hello2 " ;
29+ assertVariableCertainty (TrinaryLogic::createYes (), $ a );
30+ assertType ('mixed~null ' , $ a );
31+ } else {
32+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ a );
33+ }
34+
35+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ a );
36+ assertType ('mixed ' , $ a );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug2816 ;
4+
5+ use PHPStan \TrinaryLogic ;
6+ use function PHPStan \Analyser \assertType ;
7+ use function PHPStan \Analyser \assertVariableCertainty ;
8+
9+ if (isset ($ _GET ['x ' ])) {
10+ $ a = 1 ;
11+ }
12+
13+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ a );
14+ assertType ('mixed ' , $ a );
15+
16+ if (isset ($ a ) === true ) {
17+ echo "hello " ;
18+ assertVariableCertainty (TrinaryLogic::createYes (), $ a );
19+ assertType ('mixed~null ' , $ a );
20+ } else {
21+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ a );
22+ }
23+
24+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ a );
25+ assertType ('mixed ' , $ a );
26+
27+ if (isset ($ a ) === true ) {
28+ echo "hello2 " ;
29+ assertVariableCertainty (TrinaryLogic::createYes (), $ a );
30+ assertType ('mixed~null ' , $ a );
31+ } else {
32+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ a );
33+ }
34+
35+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ a );
36+ assertType ('mixed ' , $ a );
You can’t perform that action at this time.
0 commit comments