We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3338e26 commit 14ad549Copy full SHA for 14ad549
tests/PHPStan/Analyser/nsrt/pipe-operator.php
@@ -202,4 +202,25 @@ public function doArrayFilter(array $ints): void
202
})(1));
203
}
204
205
+ /**
206
+ * @return ($s is null ? null : int)
207
+ */
208
+ public function doConditional(string|null $s): int|null
209
+ {
210
+ if ($s === null) {
211
+ return null;
212
+ }
213
+
214
+ return strlen($s);
215
216
217
+ public function testConditional(): void
218
219
+ assertType('null', null |> $this->doConditional(...));
220
+ assertType('int', 'foo' |> $this->doConditional(...));
221
222
+ assertType('null', null |> fn($x) => $this->doConditional($x));
223
+ assertType('int', 'foo' |> fn($x) => $this->doConditional($x));
224
225
226
0 commit comments