Skip to content

Commit 70ee0a4

Browse files
committed
Fixed build
1 parent aa14780 commit 70ee0a4

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

tests/PHPStan/Rules/Variables/VariableCertaintyNullCoalesceRuleTest.php

+13-3
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,27 @@ public function testVariableCertaintyInNullCoalesce(): void
2828
'Variable $a on left side of ?? is always null.',
2929
13,
3030
],
31+
]);
32+
}
33+
34+
public function testVariableCertaintyInNullCoalesceAssign(): void
35+
{
36+
if (PHP_VERSION_ID < 70400) {
37+
$this->markTestSkipped('Test requires PHP 7.4.');
38+
}
39+
40+
$this->analyse([__DIR__ . '/data/variable-certainty-null-assign.php'], [
3141
[
3242
'Variable $scalar on left side of ??= always exists and is not nullable.',
33-
20,
43+
6,
3444
],
3545
[
3646
'Variable $doesNotExist on left side of ??= is never defined.',
37-
22,
47+
8,
3848
],
3949
[
4050
'Variable $a on left side of ??= is always null.',
41-
27,
51+
13,
4252
],
4353
]);
4454
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
function (): void {
4+
$scalar = 3;
5+
6+
echo $scalar ??= 4;
7+
8+
echo $doesNotExist ??= 0;
9+
};
10+
11+
function (?string $a): void {
12+
if (!is_string($a)) {
13+
echo $a ??= 'foo';
14+
}
15+
};

tests/PHPStan/Rules/Variables/data/variable-certainty-null.php

-13
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,3 @@ function (?string $a): void {
1414
}
1515
};
1616

17-
function (): void {
18-
$scalar = 3;
19-
20-
echo $scalar ??= 4;
21-
22-
echo $doesNotExist ??= 0;
23-
};
24-
25-
function (?string $a): void {
26-
if (!is_string($a)) {
27-
echo $a ??= 'foo';
28-
}
29-
};

0 commit comments

Comments
 (0)