Skip to content

Commit f73eb93

Browse files
pawell67claude
andcommitted
Assert Ondrej's expectations for #12680 in a separate test
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent c6d2009 commit f73eb93

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug12680;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
/**
8+
* @template TKey of array-key
9+
* @template TValue
10+
*/
11+
class Collection
12+
{
13+
14+
/** @return static<array-key, mixed> */
15+
public function pluck(): static
16+
{
17+
return new static(); // @phpstan-ignore new.static
18+
}
19+
20+
/** @return self<array-key, mixed> */
21+
public function pluckSelf(): static // @phpstan-ignore return.type
22+
{
23+
return new static(); // @phpstan-ignore new.static
24+
}
25+
26+
/** @return TValue */
27+
public function first() // @phpstan-ignore missingType.return
28+
{
29+
}
30+
31+
}
32+
33+
function (Collection $c): void {
34+
assertType('mixed', $c->pluck()->first());
35+
assertType('mixed', $c->pluckSelf()->first());
36+
assertType('mixed', (new Collection())->pluck()->first());
37+
assertType('mixed', (new Collection())->pluckSelf()->first());
38+
};

0 commit comments

Comments
 (0)