| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Doctrine\Annotations\Metadata; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Doctrine\Annotations\Annotation\Target; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use function array_filter; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use function assert; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use function implode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @internal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | final class AnnotationTarget | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     public const TARGET_CLASS      = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     public const TARGET_METHOD     = 2; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     public const TARGET_PROPERTY   = 4; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     public const TARGET_ANNOTATION = 8; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     public const TARGET_ALL        = self::TARGET_CLASS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         | self::TARGET_METHOD | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         | self::TARGET_PROPERTY | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         | self::TARGET_ANNOTATION; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     private const LABELS = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         self::TARGET_CLASS      => 'CLASS', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         self::TARGET_METHOD     => 'METHOD', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         self::TARGET_PROPERTY   => 'PROPERTY', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         self::TARGET_ANNOTATION => 'ANNOTATION', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         self::TARGET_ALL        => 'ALL', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     /** @var int */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     private $target; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 | 336 |  |     public function __construct(int $target) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 | 336 |  |         assert($target >= 0 && $target <= self::TARGET_ALL, 'Target out of bounds.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 | 336 |  |         $this->target = $target; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 336 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     public static function class() : self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         return new self(self::TARGET_CLASS); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 49 | 1 |  |     public static function method() : self | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 51 | 1 |  |         return new self(self::TARGET_METHOD); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 331 |  |     public static function property() : self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 331 |  |         return new self(self::TARGET_PROPERTY); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 | 331 |  |     public static function annotation() : self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 331 |  |         return new self(self::TARGET_ANNOTATION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 | 297 |  |     public static function all() : self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 | 297 |  |         return new self(self::TARGET_ALL); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 214 |  |     public static function fromAnnotation(Target $annotation) : self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 | 214 |  |         return new self($annotation->targets); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 296 |  |     public function unwrap() : int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 296 |  |         return $this->target; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 | 5 |  |     public function targetsClass() : bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 | 5 |  |         return ($this->target & self::TARGET_CLASS) === self::TARGET_CLASS; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 | 5 |  |     public function targetsMethod() : bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 | 5 |  |         return ($this->target & self::TARGET_METHOD) === self::TARGET_METHOD; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 5 |  |     public function targetsProperty() : bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 | 5 |  |         return ($this->target & self::TARGET_PROPERTY) === self::TARGET_PROPERTY; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 | 5 |  |     public function targetsAnnotation() : bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 | 5 |  |         return ($this->target & self::TARGET_ANNOTATION) === self::TARGET_ANNOTATION; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 | 15 |  |     public function describe() : string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 | 15 |  |         if ($this->target === self::TARGET_ALL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 | 1 |  |             return self::LABELS[self::TARGET_ALL]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 | 14 |  |         return implode( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 | 14 |  |             ', ', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 | 14 |  |             array_filter( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 | 14 |  |                 self::LABELS, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |                 function (int $target) : bool { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 | 14 |  |                     return ($this->target & $target) === $target; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 | 14 |  |                 }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 | 14 |  |                 ARRAY_FILTER_USE_KEY | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 116 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 117 |  |  |  |