Skip to content

Commit 6cfb1e1

Browse files
committed
Dependent variables - more failing test cases
1 parent 1ad0b99 commit 6cfb1e1

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

tests/PHPStan/Analyser/data/dependent-variable-certainty.php

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,55 @@ function (): void {
258258
}
259259
};
260260

261-
/*function (bool $b, bool $c): void {
261+
/*function (): void {
262+
$from = null;
263+
$to = null;
264+
if (rand(0, 1)) {
265+
$from = new \stdClass();
266+
$to = new \stdClass();
267+
}
268+
269+
if (rand(0, 1)) {
270+
$from = new \stdClass();
271+
$to = new \stdClass();
272+
}
273+
274+
if ($from !== null) {
275+
assertType('stdClass', $to);
276+
}
277+
};
278+
279+
function (bool $b): void {
280+
$from = null;
281+
$to = null;
282+
if ($b) {
283+
$from = new \stdClass();
284+
$to = new \stdClass();
285+
}
286+
287+
if ($from !== null) {
288+
assertType('true', $b);
289+
assertType('stdClass', $from);
290+
assertType('stdClass', $to);
291+
}
292+
};
293+
294+
function (bool $b): void {
295+
$from = null;
296+
$to = null;
297+
if ($b) {
298+
$from = new \stdClass();
299+
$to = new \stdClass();
300+
}
301+
302+
if ($b) {
303+
assertType('true', $b);
304+
assertType('stdClass', $from);
305+
assertType('stdClass', $to);
306+
}
307+
};
308+
309+
function (bool $b, bool $c): void {
262310
if ($b) {
263311
if ($c) {
264312
$foo = 'bla';

0 commit comments

Comments
 (0)