Skip to content

Commit 2003cda

Browse files
committed
Integration test for coalesce
1 parent 36748fc commit 2003cda

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

tests/PHPStan/Levels/LevelsIntegrationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function dataTopics(): array
3232
['missingReturn'],
3333
['arrayAccess'],
3434
['typehints'],
35+
['coalesce'],
3536
];
3637
}
3738

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"message": "Undefined variable: $bar",
4+
"line": 6,
5+
"ignorable": true
6+
}
7+
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{
3+
"message": "Variable $foo on left side of ?? is never defined.",
4+
"line": 4,
5+
"ignorable": true
6+
},
7+
{
8+
"message": "Property ReflectionClass<object>::$name (class-string<object>) on left side of ?? is not nullable.",
9+
"line": 10,
10+
"ignorable": true
11+
}
12+
]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"message": "Access to an undefined property ReflectionClass::$nonexistent.",
4+
"line": 11,
5+
"ignorable": true
6+
}
7+
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
function (): void {
4+
echo $foo ?? 'foo';
5+
6+
echo $bar->bar ?? 'foo';
7+
};
8+
9+
function (\ReflectionClass $ref): void {
10+
echo $ref->name ?? 'foo';
11+
echo $ref->nonexistent ?? 'bar';
12+
};

0 commit comments

Comments
 (0)