We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 02719b1 commit 156b1eaCopy full SHA for 156b1ea
tests/PHPStan/Analyser/nsrt/bug-10040.php
@@ -0,0 +1,34 @@
1
+<?php declare(strict_types = 1); // lint >= 8.0
2
+
3
+namespace Bug10040;
4
5
+use function PHPStan\Testing\assertType;
6
7
+class A
8
+{
9
+ public string|null $foo;
10
+}
11
12
+/**
13
+ * @phpstan-assert-if-true !null $a->foo
14
+ */
15
+function assertStringNotNull(A $a): bool
16
17
+ return true;
18
19
20
+$a1 = new A();
21
+if(assertStringNotNull($a1)){
22
+ assertType('string', $a1->foo);
23
24
25
+$a2 = new A();
26
+$stringIsNotNull = assertStringNotNull($a2);
27
+if($stringIsNotNull){
28
+ assertType('string', $a2->foo);
29
30
31
+$a3 = new A();
32
+if($stringIsNotNull = assertStringNotNull($a3)){
33
+ assertType('string', $a3->foo);
34
0 commit comments