forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bug-7381.php
47 lines (41 loc) · 759 Bytes
/
bug-7381.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php declare(strict_types = 1);
namespace Bug7381;
/**
* @template T of array<string, mixed>
*/
trait AttributeTrait
{
/**
* @template K of key-of<T>
* @param K $key
* @return T[K]|null
*/
public function getAttribute(string $key)
{
return $this->getAttributes()[$key] ?? null;
}
}
/**
* @phpstan-type Attrs array{foo?: string}
*/
class Foo {
/** @use AttributeTrait<Attrs> */
use AttributeTrait;
/** @return Attrs */
public function getAttributes(): array
{
return [];
}
}
/**
* @phpstan-type Attrs array{foo?: string, bar?: string}
*/
class Bar {
/** @use AttributeTrait<Attrs> */
use AttributeTrait;
/** @return Attrs */
public function getAttributes(): array
{
return [];
}
}