1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | namespace PHPStan\BetterReflection\Reflection\Adapter; |
6: | |
7: | use PhpParser\Node\Expr; |
8: | use PHPStan\BetterReflection\Reflection\ReflectionAttribute as BetterReflectionAttribute; |
9: | |
10: | final class FakeReflectionAttribute |
11: | { |
12: | private BetterReflectionAttribute $betterReflectionAttribute; |
13: | public function __construct(BetterReflectionAttribute $betterReflectionAttribute) |
14: | { |
15: | $this->betterReflectionAttribute = $betterReflectionAttribute; |
16: | } |
17: | |
18: | public function getName(): string |
19: | { |
20: | return $this->betterReflectionAttribute->getName(); |
21: | } |
22: | |
23: | public function getTarget(): int |
24: | { |
25: | return $this->betterReflectionAttribute->getTarget(); |
26: | } |
27: | |
28: | public function isRepeated(): bool |
29: | { |
30: | return $this->betterReflectionAttribute->isRepeated(); |
31: | } |
32: | |
33: | |
34: | |
35: | |
36: | public function getArguments(): array |
37: | { |
38: | return $this->betterReflectionAttribute->getArguments(); |
39: | } |
40: | |
41: | |
42: | public function getArgumentsExpressions(): array |
43: | { |
44: | return $this->betterReflectionAttribute->getArgumentsExpressions(); |
45: | } |
46: | |
47: | public function newInstance(): object |
48: | { |
49: | $class = $this->getName(); |
50: | |
51: | return new $class(...$this->getArguments()); |
52: | } |
53: | |
54: | public function __toString(): string |
55: | { |
56: | return $this->betterReflectionAttribute->__toString(); |
57: | } |
58: | } |
59: | |