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: /**
13: * @var BetterReflectionAttribute
14: */
15: private $betterReflectionAttribute;
16: public function __construct(BetterReflectionAttribute $betterReflectionAttribute)
17: {
18: $this->betterReflectionAttribute = $betterReflectionAttribute;
19: }
20:
21: public function getName(): string
22: {
23: return $this->betterReflectionAttribute->getName();
24: }
25:
26: public function getTarget(): int
27: {
28: return $this->betterReflectionAttribute->getTarget();
29: }
30:
31: public function isRepeated(): bool
32: {
33: return $this->betterReflectionAttribute->isRepeated();
34: }
35:
36: /**
37: * @return array<int|string, mixed>
38: */
39: public function getArguments(): array
40: {
41: return $this->betterReflectionAttribute->getArguments();
42: }
43:
44: /** @return array<int|string, Expr> */
45: public function getArgumentsExpressions(): array
46: {
47: return $this->betterReflectionAttribute->getArgumentsExpressions();
48: }
49:
50: public function newInstance(): object
51: {
52: $class = $this->getName();
53:
54: return new $class(...$this->getArguments());
55: }
56:
57: public function __toString(): string
58: {
59: return $this->betterReflectionAttribute->__toString();
60: }
61: }
62: