File tree 4 files changed +86
-2
lines changed
4 files changed +86
-2
lines changed Original file line number Diff line number Diff line change @@ -538,9 +538,9 @@ public function specifyTypesInCondition(
538
538
(
539
539
$ expr instanceof Expr \Isset_
540
540
&& count ($ expr ->vars ) > 0
541
- && $ context ->truthy ()
541
+ && $ context ->true ()
542
542
)
543
- || ($ expr instanceof Expr \Empty_ && $ context ->falsey ())
543
+ || ($ expr instanceof Expr \Empty_ && $ context ->false ())
544
544
) {
545
545
$ vars = [];
546
546
if ($ expr instanceof Expr \Isset_) {
Original file line number Diff line number Diff line change @@ -10209,6 +10209,16 @@ public function dataCount(): array
10209
10209
return $ this ->gatherAssertTypes (__DIR__ . '/data/count-type.php ' );
10210
10210
}
10211
10211
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
+
10212
10222
public function dataBug3985 (): array
10213
10223
{
10214
10224
return $ this ->gatherAssertTypes (__DIR__ . '/data/bug-3985.php ' );
@@ -10298,6 +10308,8 @@ public function dataBug3985(): array
10298
10308
* @dataProvider dataBug1924
10299
10309
* @dataProvider dataExtraIntTypes
10300
10310
* @dataProvider dataCount
10311
+ * @dataProvider dataBug2816
10312
+ * @dataProvider dataBug2816Two
10301
10313
* @dataProvider dataBug3985
10302
10314
* @param string $assertType
10303
10315
* @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