@@ -101,4 +101,72 @@ public function propertyWriteSucceeds(): void
101
101
Assert::assertCount (1 , $ this ->session );
102
102
Assert::assertTrue (isset ($ this ->session ->bar ));
103
103
}
104
+
105
+ /**
106
+ * @Then array access check returns true
107
+ */
108
+ public function arrayAccessCheckReturnsTrue (): void
109
+ {
110
+ Assert::assertTrue (isset ($ this ->session ['foo ' ]));
111
+ }
112
+
113
+ /**
114
+ * @Then array access check returns false
115
+ */
116
+ public function arrayAccessCheckReturnsFalse (): void
117
+ {
118
+ Assert::assertFalse (isset ($ this ->session ['foo ' ]));
119
+ }
120
+
121
+ /**
122
+ * @Then array access read returns data
123
+ */
124
+ public function arrayAccessReadReturnsData (): void
125
+ {
126
+ Assert::assertEquals ('bar ' , $ this ->session ['foo ' ]);
127
+ }
128
+
129
+ /**
130
+ * @Then array access read triggers error
131
+ */
132
+ public function arrayAccessReadTriggersNoticeError (): void
133
+ {
134
+ try {
135
+ $ errorThrown = false ;
136
+ $ bar = $ this ->session ['bar ' ];
137
+ // @phpstan-ignore-next-line
138
+ } catch (Throwable $ e ) {
139
+ $ errorThrown = true ;
140
+ } finally {
141
+ Assert::assertTrue ($ errorThrown );
142
+ }
143
+ }
144
+
145
+ /**
146
+ * @Then array access read returns null
147
+ */
148
+ public function arrayAccessReadReturnsNull (): void
149
+ {
150
+ $ bar = @$ this ->session ['foo ' ];
151
+ Assert::assertSame (null , $ bar );
152
+ }
153
+
154
+ /**
155
+ * @Then array access read with null coalesce returns null
156
+ */
157
+ public function arrayAccessReadWithNullCoalesceReturnsNull (): void
158
+ {
159
+ $ bar = $ this ->session ['foo ' ] ?? null ;
160
+ Assert::assertSame (null , $ bar );
161
+ }
162
+
163
+ /**
164
+ * @Then array access write succeeds
165
+ */
166
+ public function arrayAccessWriteSucceeds (): void
167
+ {
168
+ $ this ->session ['bar ' ] = 'baz ' ;
169
+ Assert::assertCount (1 , $ this ->session );
170
+ Assert::assertTrue (isset ($ this ->session ['bar ' ]));
171
+ }
104
172
}
0 commit comments