File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -42,3 +42,36 @@ public static function doSomethingFor(X $x): void {
4242 }
4343 }
4444}
45+
46+ enum Y: string {
47+ case A = 'a ' ;
48+ case B = 'b ' ;
49+ case C = 'c ' ;
50+
51+ /** @param-out ($this is self::A ? int : null) $i */
52+ public function get (?int &$ i ): void {
53+ ($ this === self ::A) ? $ i =null : $ i =123 ;
54+ }
55+
56+ public function doSomething (): void {
57+ $ i = 0 ;
58+ if ($ this !== self ::A) {
59+ $ this ->get ($ i );
60+ assertType ('null ' , $ i ); // null
61+ } else {
62+ $ this ->get ($ i );
63+ assertType ('int ' , $ i ); // int
64+ }
65+ }
66+
67+ public static function doSomethingFor (Y $ x ): void {
68+ $ i = 0 ;
69+ if ($ x !== self ::A) {
70+ $ x ->get ($ i );
71+ assertType ('null ' , $ i ); // null
72+ } else {
73+ $ x ->get ($ i );
74+ assertType ('int ' , $ i ); // int
75+ }
76+ }
77+ }
You can’t perform that action at this time.
0 commit comments