File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -57,3 +57,24 @@ function main3(mixed $c): void{
5757
5858 assertType ("array{date: DateTime, id: 1, name: 'ruud'|'staabm'} " , $ c );
5959}
60+
61+ /** @param array{date: DateTime} $c */
62+ function main4 (mixed $ c ): void {
63+ assertType ('array{date: DateTime} ' , $ c );
64+ $ c ['id ' ]=1 ;
65+ $ c ['name ' ] = 'staabm ' ;
66+ assertType ("array{date: DateTime, id: 1, name: 'staabm'} " , $ c );
67+
68+ $ x = (function () use (&$ c ) {
69+ assertType ("array{date: DateTime, id: 1, name: 'staabm'} " , $ c );
70+ if (rand (0 ,1 )) {
71+ $ c ['name ' ] = 'ruud ' ;
72+ assertType ("array{date: DateTime, id: 1, name: 'ruud'} " , $ c );
73+ return 'y ' ;
74+ }
75+ assertType ("array{date: DateTime, id: 1, name: 'staabm'} " , $ c );
76+ return 'x ' ;
77+ })();
78+
79+ assertType ("array{date: DateTime, id: 1, name: 'ruud'|'staabm'} " , $ c );
80+ }
You can’t perform that action at this time.
0 commit comments