| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * This file is part of phpDocumentor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * @copyright 2010-2018 Mike van Riel<[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @license   http://www.opensource.org/licenses/mit-license.php MIT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * @link      http://phpdoc.org | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | namespace phpDocumentor\Reflection\Php; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use phpDocumentor\Reflection\DocBlock; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use phpDocumentor\Reflection\Element; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use phpDocumentor\Reflection\Fqsen; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use phpDocumentor\Reflection\Location; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * Descriptor representing a property. | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 24 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  | final class Property implements Element | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |      * @var Fqsen | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |     private $fqsen; | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |      * @var DocBlock|null | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |     private $docBlock; | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |     /** @var string[] $types */ | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |     private $types = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |     /** @var null|string $default */ | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |     private $default = null; | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |     /** @var bool $static */ | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |     private $static = false; | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |     /** @var null|Visibility $visibility */ | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |     private $visibility = null; | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |      * @var Location | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |     private $location; | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |      * @param Visibility|null $visibility when null is provided a default 'public' is set. | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |      * @param DocBlock|null $docBlock | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |      * @param null|string $default | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |      * @param Location|null $location | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 5 |  |     public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         Fqsen $fqsen, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         ?Visibility $visibility = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         ?DocBlock $docBlock = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         ?string $default = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         bool $static = false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         ?Location $location = null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 | 5 |  |         if ($location === null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 5 |  |             $location = new Location(-1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 | 5 |  |         $this->fqsen = $fqsen; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 5 |  |         $this->visibility = $visibility; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 5 |  |         $this->docBlock = $docBlock; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 5 |  |         $this->default = $default; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 5 |  |         $this->static = $static; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 5 |  |         $this->location = $location; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 | 5 |  |         if ($this->visibility === null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 1 |  |             $this->visibility = new Visibility('public'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 82 | 5 |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |      * returns the default value of this property. | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 | 1 |  |     public function getDefault(): ?string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 1 |  |         return $this->default; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 90 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |      * Returns true when this method is static. Otherwise returns false. | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 | 1 |  |     public function isStatic(): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 | 1 |  |         return $this->static; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 98 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |      * Returns the types of this property. | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |      * @return string[] | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 | 1 |  |     public function getTypes(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 | 1 |  |         return $this->types; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 108 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |      * Add a type to this property | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 | 1 |  |     public function addType(string $type): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 | 1 |  |         $this->types[] = $type; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 116 | 1 |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  |      * Return visibility of the property. | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 | 1 |  |     public function getVisibility(): ?Visibility | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 | 1 |  |         return $this->visibility; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 124 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 126 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 127 |  |  |      * Returns the Fqsen of the element. | 
            
                                                                        
                            
            
                                    
            
            
                | 128 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 | 1 |  |     public function getFqsen(): Fqsen | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 | 1 |  |         return $this->fqsen; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 132 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 134 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  |      * Returns the name of the element. | 
            
                                                                        
                            
            
                                    
            
            
                | 136 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 | 1 |  |     public function getName(): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 | 1 |  |         return $this->fqsen->getName(); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 140 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |      * Returns the DocBlock of this property. | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 | 1 |  |     public function getDocBlock(): ?DocBlock | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 | 1 |  |         return $this->docBlock; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 148 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     public function getLocation(): Location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         return $this->location; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 153 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 154 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 155 |  |  |  |