Skip to content

Commit d98fffa

Browse files
committed
more bool tests
1 parent d27fdc5 commit d98fffa

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

tests/PHPStan/Analyser/nsrt/bug-12393b.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ function doStrings($nonEmpty, $nonFalsy, $numeric, $literal, $lower, $upper) {
277277
}
278278
}
279279

280-
class FooBool
280+
class FooBoolInt
281281
{
282282

283283
public int $foo;
@@ -339,6 +339,37 @@ public function doBar(): void
339339
}
340340
}
341341

342+
class FooIntBool
343+
{
344+
345+
public bool $foo;
346+
347+
public function doFoo(int $b): void
348+
{
349+
$this->foo = $b;
350+
assertType('bool', $this->foo);
351+
352+
if ($b !== 0) {
353+
$this->foo = $b;
354+
assertType('true', $this->foo);
355+
}
356+
if ($b !== 1) {
357+
$this->foo = $b;
358+
assertType('bool', $this->foo);
359+
}
360+
}
361+
362+
public function doBar(): void
363+
{
364+
$this->foo = -1;
365+
assertType("true", $this->foo);
366+
$this->foo = 1;
367+
assertType("true", $this->foo);
368+
$this->foo = 0;
369+
assertType("false", $this->foo);
370+
}
371+
}
372+
342373
class FooIntRangeString
343374
{
344375

0 commit comments

Comments
 (0)