@@ -21,5 +21,56 @@ public function testTwoLines(array $arr): void
2121 array_unshift ($ arr , $ popped );
2222 assertType ('non-empty-list<int> ' , $ arr );
2323 }
24+ }
25+
26+ class Bar
27+ {
28+ /** @var array<int> */
29+ public array $ arr = [];
30+
31+ public function test (): void
32+ {
33+ if (count ($ this ->arr ) === 0 ) {
34+ throw new \Exception ();
35+ }
36+ assertType ('non-empty-array<int> ' , $ this ->arr );
37+ array_unshift ($ this ->arr , array_pop ($ this ->arr ));
38+ assertType ('non-empty-array<int> ' , $ this ->arr );
39+ }
40+
41+ public function testArrayPush (): void
42+ {
43+ if (count ($ this ->arr ) === 0 ) {
44+ throw new \Exception ();
45+ }
46+ array_push ($ this ->arr , array_pop ($ this ->arr ));
47+ assertType ('non-empty-array<int> ' , $ this ->arr );
48+ }
2449
50+ public function testArrayUnshiftWithArrayShift (): void
51+ {
52+ if (count ($ this ->arr ) === 0 ) {
53+ throw new \Exception ();
54+ }
55+ array_unshift ($ this ->arr , array_shift ($ this ->arr ));
56+ assertType ('non-empty-array<int> ' , $ this ->arr );
57+ }
58+
59+ public function testArrayPushWithArrayShift (): void
60+ {
61+ if (count ($ this ->arr ) === 0 ) {
62+ throw new \Exception ();
63+ }
64+ array_push ($ this ->arr , array_shift ($ this ->arr ));
65+ assertType ('non-empty-array<int> ' , $ this ->arr );
66+ }
67+
68+ public function testArraySplice (): void
69+ {
70+ if (count ($ this ->arr ) === 0 ) {
71+ throw new \Exception ();
72+ }
73+ array_splice ($ this ->arr , 0 , 0 , [array_pop ($ this ->arr )]);
74+ assertType ('non-empty-array<(int<0, max>|string), int> ' , $ this ->arr );
75+ }
2576}
0 commit comments