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