File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -484,3 +484,53 @@ public function doFoo(array $arr): void
484
484
}
485
485
486
486
}
487
+
488
+ class FooArray
489
+ {
490
+ public array $ foo ;
491
+
492
+ /**
493
+ * @param non-empty-array $arr
494
+ */
495
+ public function doFoo (array $ arr ): void
496
+ {
497
+ $ this ->foo = $ arr ;
498
+ assertType ('non-empty-array ' , $ this ->foo );
499
+
500
+ if (array_key_exists ('foo ' , $ arr )) {
501
+ $ this ->foo = $ arr ;
502
+ assertType ("non-empty-array&hasOffset('foo') " , $ this ->foo );
503
+ }
504
+
505
+ if (array_key_exists ('foo ' , $ arr ) && $ arr ['foo ' ] === 'bar ' ) {
506
+ $ this ->foo = $ arr ;
507
+ assertType ("non-empty-array&hasOffsetValue('foo', 'bar') " , $ this ->foo );
508
+ }
509
+ }
510
+
511
+ }
512
+
513
+ class FooList
514
+ {
515
+ public array $ foo ;
516
+
517
+ /**
518
+ * @param non-empty-list $list
519
+ */
520
+ public function doFoo (array $ list ): void
521
+ {
522
+ $ this ->foo = $ list ;
523
+ assertType ('non-empty-list ' , $ this ->foo );
524
+
525
+ if (array_key_exists (3 , $ list )) {
526
+ $ this ->foo = $ list ;
527
+ assertType ("non-empty-list&hasOffset(3) " , $ this ->foo );
528
+ }
529
+
530
+ if (array_key_exists (3 , $ list ) && is_string ($ list [3 ])) {
531
+ $ this ->foo = $ list ;
532
+ assertType ("non-empty-list&hasOffsetValue(3, string) " , $ this ->foo );
533
+ }
534
+ }
535
+
536
+ }
You can’t perform that action at this time.
0 commit comments