appserver-io /
doppelgaenger
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * \AppserverIo\Doppelgaenger\Entities\Definitions\AttributeDefinition |
||
| 5 | * |
||
| 6 | * NOTICE OF LICENSE |
||
| 7 | * |
||
| 8 | * This source file is subject to the Open Software License (OSL 3.0) |
||
| 9 | * that is available through the world-wide-web at this URL: |
||
| 10 | * http://opensource.org/licenses/osl-3.0.php |
||
| 11 | * |
||
| 12 | * PHP version 5 |
||
| 13 | * |
||
| 14 | * @author Bernhard Wick <[email protected]> |
||
| 15 | * @copyright 2015 TechDivision GmbH - <[email protected]> |
||
| 16 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
||
| 17 | * @link https://github.com/appserver-io/doppelgaenger |
||
| 18 | * @link http://www.appserver.io/ |
||
| 19 | */ |
||
| 20 | |||
| 21 | namespace AppserverIo\Doppelgaenger\Entities\Definitions; |
||
| 22 | |||
| 23 | use AppserverIo\Doppelgaenger\Interfaces\DefinitionInterface; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Provides a definition of class and trait attributes |
||
| 27 | * |
||
| 28 | * @author Bernhard Wick <[email protected]> |
||
| 29 | * @copyright 2015 TechDivision GmbH - <[email protected]> |
||
| 30 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
||
| 31 | * @link https://github.com/appserver-io/doppelgaenger |
||
| 32 | * @link http://www.appserver.io/ |
||
| 33 | */ |
||
| 34 | class AttributeDefinition implements DefinitionInterface |
||
| 35 | { |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Default value (if any) |
||
| 39 | * |
||
| 40 | * @var mixed $defaultValue |
||
| 41 | */ |
||
| 42 | protected $defaultValue; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Is this attribute part of the invariant? |
||
| 46 | * |
||
| 47 | * @var boolean $inInvariant |
||
| 48 | */ |
||
| 49 | protected $inInvariant; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Is this attribute static? |
||
| 53 | * |
||
| 54 | * @var boolean $isStatic |
||
| 55 | */ |
||
| 56 | protected $isStatic; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Name of the class attribute |
||
| 60 | * |
||
| 61 | * @var string $name |
||
| 62 | */ |
||
| 63 | protected $name; |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Line of the class attribute's definition |
||
| 67 | * |
||
| 68 | * @var string $line |
||
| 69 | */ |
||
| 70 | protected $line; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Name of the structure containing this attribute |
||
| 74 | * |
||
| 75 | * @var string $structureName |
||
| 76 | */ |
||
| 77 | protected $structureName; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * Visibility of the attribute |
||
| 81 | * |
||
| 82 | * @var string $visibility |
||
| 83 | */ |
||
| 84 | protected $visibility; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Default constructor |
||
| 88 | */ |
||
| 89 | public function __construct() |
||
| 90 | { |
||
| 91 | $this->visibility = 'public'; |
||
| 92 | $this->isStatic = false; |
||
| 93 | $this->name = ''; |
||
| 94 | $this->line = 0; |
||
|
0 ignored issues
–
show
|
|||
| 95 | $this->defaultValue = null; |
||
| 96 | $this->inInvariant = false; |
||
| 97 | $this->structureName = ''; |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Getter method for the $defaultValue property |
||
| 102 | * |
||
| 103 | * @return string |
||
| 104 | */ |
||
| 105 | public function getDefaultValue() |
||
| 106 | { |
||
| 107 | return $this->defaultValue; |
||
| 108 | } |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Getter method for the $name property |
||
| 112 | * |
||
| 113 | * @return string |
||
| 114 | */ |
||
| 115 | public function getName() |
||
| 116 | { |
||
| 117 | return $this->name; |
||
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Getter method for the $line property |
||
| 122 | * |
||
| 123 | * @return string |
||
| 124 | */ |
||
| 125 | public function getLine() |
||
| 126 | { |
||
| 127 | return $this->line; |
||
| 128 | } |
||
| 129 | |||
| 130 | /** |
||
| 131 | * Will return a string representation of this assertion |
||
| 132 | * |
||
| 133 | * @return string |
||
| 134 | */ |
||
| 135 | public function getString() |
||
| 136 | { |
||
| 137 | $stringParts = array(); |
||
| 138 | |||
| 139 | // Set the visibility |
||
| 140 | $stringParts[] = $this->visibility; |
||
| 141 | |||
| 142 | // If we are static, we have to tell so |
||
| 143 | if ($this->isStatic === true) { |
||
| 144 | $stringParts[] = 'static'; |
||
| 145 | } |
||
| 146 | |||
| 147 | // Add the name |
||
| 148 | $stringParts[] = $this->name; |
||
| 149 | |||
| 150 | // Add any default value we might get |
||
| 151 | if ($this->defaultValue !== null) { |
||
| 152 | $stringParts[] = '= ' . $this->defaultValue; |
||
| 153 | } |
||
| 154 | |||
| 155 | // And don't forget the trailing semicolon |
||
| 156 | return implode(' ', $stringParts) . ';'; |
||
| 157 | } |
||
| 158 | |||
| 159 | /** |
||
| 160 | * Getter method for the $structureName property |
||
| 161 | * |
||
| 162 | * @return string |
||
| 163 | */ |
||
| 164 | public function getStructureName() |
||
| 165 | { |
||
| 166 | return $this->structureName; |
||
| 167 | } |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Getter method for the $visibility property |
||
| 171 | * |
||
| 172 | * @return string |
||
| 173 | */ |
||
| 174 | public function getVisibility() |
||
| 175 | { |
||
| 176 | return $this->visibility; |
||
| 177 | } |
||
| 178 | |||
| 179 | /** |
||
| 180 | * If the attribute is mentioned in an invariant |
||
| 181 | * |
||
| 182 | * @return boolean |
||
| 183 | */ |
||
| 184 | public function inInvariant() |
||
| 185 | { |
||
| 186 | return $this->inInvariant; |
||
| 187 | } |
||
| 188 | |||
| 189 | /** |
||
| 190 | * If the attribute is declared static |
||
| 191 | * |
||
| 192 | * @return boolean |
||
| 193 | */ |
||
| 194 | public function isStatic() |
||
| 195 | { |
||
| 196 | return $this->isStatic; |
||
| 197 | } |
||
| 198 | |||
| 199 | /** |
||
| 200 | * Setter method for the $defaultValue property |
||
| 201 | * |
||
| 202 | * @param mixed $defaultValue Default value of the attribute |
||
| 203 | * |
||
| 204 | * @return null |
||
| 205 | */ |
||
| 206 | public function setDefaultValue($defaultValue) |
||
| 207 | { |
||
| 208 | $this->defaultValue = $defaultValue; |
||
| 209 | } |
||
| 210 | |||
| 211 | /** |
||
| 212 | * Setter method for the $inInvariant property |
||
| 213 | * |
||
| 214 | * @param boolean $inInvariant If the attribute is mentioned in an invariant clause |
||
| 215 | * |
||
| 216 | * @return null |
||
| 217 | */ |
||
| 218 | public function setInInvariant($inInvariant) |
||
| 219 | { |
||
| 220 | $this->inInvariant = $inInvariant; |
||
| 221 | } |
||
| 222 | |||
| 223 | /** |
||
| 224 | * Setter method for the $isStatic property |
||
| 225 | * |
||
| 226 | * @param boolean $isStatic If the attribute is declared static |
||
| 227 | * |
||
| 228 | * @return null |
||
| 229 | */ |
||
| 230 | public function setIsStatic($isStatic) |
||
| 231 | { |
||
| 232 | $this->isStatic = $isStatic; |
||
| 233 | } |
||
| 234 | |||
| 235 | /** |
||
| 236 | * Setter method for the $name property |
||
| 237 | * |
||
| 238 | * @param string $name Name of the attribute |
||
| 239 | * |
||
| 240 | * @return null |
||
| 241 | */ |
||
| 242 | public function setName($name) |
||
| 243 | { |
||
| 244 | $this->name = $name; |
||
| 245 | } |
||
| 246 | |||
| 247 | /** |
||
| 248 | * Setter method for the $line property |
||
| 249 | * |
||
| 250 | * @param string $line Line of the attribute's definition |
||
| 251 | * |
||
| 252 | * @return null |
||
| 253 | */ |
||
| 254 | public function setLine($line) |
||
| 255 | { |
||
| 256 | $this->line = $line; |
||
| 257 | } |
||
| 258 | |||
| 259 | /** |
||
| 260 | * Setter method for the $structureName property |
||
| 261 | * |
||
| 262 | * @param string $structureName Name of the containing structure |
||
| 263 | * |
||
| 264 | * @return null |
||
| 265 | */ |
||
| 266 | public function setStructureName($structureName) |
||
| 267 | { |
||
| 268 | $this->structureName = $structureName; |
||
| 269 | } |
||
| 270 | |||
| 271 | /** |
||
| 272 | * Setter method for the $visibility property |
||
| 273 | * |
||
| 274 | * @param string $visibility Visibility of the attribute |
||
| 275 | * |
||
| 276 | * @return null |
||
| 277 | */ |
||
| 278 | public function setVisibility($visibility) |
||
| 279 | { |
||
| 280 | $this->visibility = $visibility; |
||
| 281 | } |
||
| 282 | } |
||
| 283 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.