Skip to content

Commit 95186fe

Browse files
committed
test stringable in strict-types
1 parent 016d44a commit 95186fe

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,28 @@ public function doFoo(callable $foo): void {
163163
assertType('array', $this->foo); // could be non-empty-array
164164
}
165165
}
166+
167+
class StringableFoo {
168+
private string $foo;
169+
170+
// https://3v4l.org/DQSgA#v8.4.6
171+
public function doFoo(StringableFoo $foo): void {
172+
$this->foo = $foo;
173+
assertType('*NEVER*', $this->foo);
174+
}
175+
176+
public function doFoo2(NotStringable $foo): void {
177+
$this->foo = $foo;
178+
assertType('*NEVER*', $this->foo);
179+
}
180+
181+
// https://3v4l.org/2SPPj#v8.4.6
182+
public function doFoo3(\BcMath\Number $foo): void {
183+
$this->foo = $foo;
184+
assertType('*NEVER*', $this->foo);
185+
}
186+
187+
public function __toString(): string {
188+
return 'Foo';
189+
}
190+
}

0 commit comments

Comments
 (0)