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\ClassDefinition |
||
| 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\Entities\Lists\AssertionList; |
||
| 24 | use AppserverIo\Doppelgaenger\Entities\Lists\AttributeDefinitionList; |
||
| 25 | use AppserverIo\Doppelgaenger\Entities\Lists\FunctionDefinitionList; |
||
| 26 | use AppserverIo\Doppelgaenger\Entities\Lists\IntroductionList; |
||
| 27 | use AppserverIo\Doppelgaenger\Entities\Lists\TypedListList; |
||
| 28 | use AppserverIo\Doppelgaenger\Interfaces\PropertiedStructureInterface; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * This class acts as a DTO-like (we are not immutable due to protected visibility) |
||
| 32 | * entity for describing class definitions |
||
| 33 | * |
||
| 34 | * @author Bernhard Wick <[email protected]> |
||
| 35 | * @copyright 2015 TechDivision GmbH - <[email protected]> |
||
| 36 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
||
| 37 | * @link https://github.com/appserver-io/doppelgaenger |
||
| 38 | * @link http://www.appserver.io/ |
||
| 39 | */ |
||
| 40 | class ClassDefinition extends AbstractStructureDefinition implements PropertiedStructureInterface |
||
| 41 | { |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @const string TYPE The structure type |
||
| 45 | */ |
||
| 46 | const TYPE = 'class'; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * List of introductions which are used to extend the class's characteristics |
||
| 50 | * |
||
| 51 | * @var \AppserverIo\Doppelgaenger\Entities\Lists\IntroductionList $introductions |
||
| 52 | */ |
||
| 53 | protected $introductions; |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Is this a final class |
||
| 57 | * |
||
| 58 | * @var boolean $isFinal |
||
| 59 | */ |
||
| 60 | protected $isFinal; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Is this class abstract |
||
| 64 | * |
||
| 65 | * @var boolean $isAbstract |
||
| 66 | */ |
||
| 67 | protected $isAbstract; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Name of the parent class (if any) |
||
| 71 | * |
||
| 72 | * @var array $extends |
||
| 73 | */ |
||
| 74 | protected $extends; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Array of interface names this class implements |
||
| 78 | * |
||
| 79 | * @var array $implements |
||
| 80 | */ |
||
| 81 | protected $implements; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Class constants |
||
| 85 | * |
||
| 86 | * @var array $constants |
||
| 87 | */ |
||
| 88 | protected $constants; |
||
| 89 | |||
| 90 | /** |
||
| 91 | * List of defined attributes |
||
| 92 | * |
||
| 93 | * @var \AppserverIo\Doppelgaenger\Entities\Lists\AttributeDefinitionList $attributeDefinitions |
||
| 94 | */ |
||
| 95 | protected $attributeDefinitions; |
||
| 96 | |||
| 97 | /** |
||
| 98 | * List of directly defined invariant conditions |
||
| 99 | * |
||
| 100 | * @var \AppserverIo\Doppelgaenger\Entities\Lists\AssertionList $invariantConditions |
||
| 101 | */ |
||
| 102 | protected $invariantConditions; |
||
| 103 | |||
| 104 | /** |
||
| 105 | * List of lists of any ancestral invariants |
||
| 106 | * |
||
| 107 | * @var \AppserverIo\Doppelgaenger\Entities\Lists\AssertionList $ancestralInvariants |
||
| 108 | */ |
||
| 109 | protected $ancestralInvariants; |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Default constructor |
||
| 113 | * |
||
| 114 | * @param string $path File path to the class definition |
||
| 115 | * @param string $namespace The namespace the class belongs to |
||
| 116 | * @param string $docBlock The initial class docblock header |
||
| 117 | * @param null $introductions List of introductions defined in the docblock |
||
| 118 | * @param bool $isFinal Is this a final class |
||
| 119 | * @param bool $isAbstract Is this class abstract |
||
| 120 | * @param string $name Name of the class |
||
| 121 | * @param string $extends Name of the parent class (if any) |
||
| 122 | * @param array $implements Array of interface names this class implements |
||
| 123 | * @param array $constants Class constants |
||
| 124 | * @param null $attributeDefinitions List of defined attributes |
||
| 125 | * @param null $invariantConditions List of directly defined invariant conditions |
||
| 126 | * @param null $ancestralInvariants List of lists of any ancestral invariants |
||
| 127 | * @param null $functionDefinitions List of methods this class defines |
||
| 128 | */ |
||
| 129 | public function __construct( |
||
| 130 | $path = '', |
||
| 131 | $namespace = '', |
||
| 132 | $docBlock = '', |
||
| 133 | $introductions = null, |
||
| 134 | $isFinal = false, |
||
| 135 | $isAbstract = false, |
||
| 136 | $name = '', |
||
| 137 | $extends = '', |
||
| 138 | $implements = array(), |
||
| 139 | $constants = array(), |
||
| 140 | $attributeDefinitions = null, |
||
| 141 | $invariantConditions = null, |
||
| 142 | $ancestralInvariants = null, |
||
| 143 | $functionDefinitions = null |
||
| 144 | ) { |
||
| 145 | $this->path = $path; |
||
| 146 | $this->namespace = $namespace; |
||
| 147 | $this->docBlock = $docBlock; |
||
| 148 | $this->introductions = is_null($introductions) ? new IntroductionList() : $introductions; |
||
| 149 | $this->isFinal = $isFinal; |
||
| 150 | $this->isAbstract = $isAbstract; |
||
| 151 | $this->name = $name; |
||
| 152 | $this->extends = $extends; |
||
|
0 ignored issues
–
show
|
|||
| 153 | $this->implements = $implements; |
||
| 154 | $this->constants = $constants; |
||
| 155 | $this->attributeDefinitions = is_null( |
||
| 156 | $attributeDefinitions |
||
| 157 | ) ? new AttributeDefinitionList() : $attributeDefinitions; |
||
| 158 | $this->invariantConditions = is_null($invariantConditions) ? new AssertionList() : $invariantConditions; |
||
| 159 | $this->ancestralInvariants = is_null($ancestralInvariants) ? new TypedListList() : $ancestralInvariants; |
||
|
0 ignored issues
–
show
It seems like
is_null($ancestralInvari... : $ancestralInvariants of type object<AppserverIo\Doppe...es\Lists\TypedListList> is incompatible with the declared type object<AppserverIo\Doppe...es\Lists\AssertionList> of property $ancestralInvariants.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 160 | $this->functionDefinitions = is_null( |
||
| 161 | $functionDefinitions |
||
| 162 | ) ? new FunctionDefinitionList() : $functionDefinitions; |
||
| 163 | } |
||
| 164 | |||
| 165 | /** |
||
| 166 | * Will flatten all conditions available at the time of the call. |
||
| 167 | * That means this method will check which conditions make sense in an inheritance context and will drop the |
||
| 168 | * others. |
||
| 169 | * |
||
| 170 | * @return bool |
||
| 171 | */ |
||
| 172 | public function flattenConditions() |
||
| 173 | { |
||
| 174 | // As our lists only supports unique entries anyway, the only thing left is to check if the condition's |
||
| 175 | // assertions can be fulfilled (would be possible as direct assertions), and flatten the contained |
||
| 176 | // function definitions as well |
||
| 177 | $ancestralConditionIterator = $this->ancestralInvariants->getIterator(); |
||
| 178 | foreach ($ancestralConditionIterator as $conditionList) { |
||
| 179 | // iterate all condition lists |
||
| 180 | $conditionListIterator = $conditionList->getIterator(); |
||
| 181 | foreach ($conditionListIterator as $assertion) { |
||
| 182 | } |
||
| 183 | } |
||
| 184 | |||
| 185 | // No flatten all the function definitions we got |
||
| 186 | $functionDefinitionIterator = $this->functionDefinitions->getIterator(); |
||
| 187 | foreach ($functionDefinitionIterator as $functionDefinition) { |
||
| 188 | // iterate over all function definitions |
||
| 189 | $functionDefinition->flattenConditions(); |
||
| 190 | } |
||
| 191 | |||
| 192 | return false; |
||
| 193 | } |
||
| 194 | |||
| 195 | /** |
||
| 196 | * Getter method for attribute $ancestralInvariants |
||
| 197 | * |
||
| 198 | * @return null|TypedListList |
||
| 199 | */ |
||
| 200 | public function getAncestralInvariants() |
||
| 201 | { |
||
| 202 | return $this->ancestralInvariants; |
||
| 203 | } |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Getter method for attribute $attributeDefinitions |
||
| 207 | * |
||
| 208 | * @return null|AttributeDefinitionList |
||
| 209 | */ |
||
| 210 | public function getAttributeDefinitions() |
||
| 211 | { |
||
| 212 | return $this->attributeDefinitions; |
||
| 213 | } |
||
| 214 | |||
| 215 | /** |
||
| 216 | * Getter method for attribute $constants |
||
| 217 | * |
||
| 218 | * @return array |
||
| 219 | */ |
||
| 220 | public function getConstants() |
||
| 221 | { |
||
| 222 | return $this->constants; |
||
| 223 | } |
||
| 224 | |||
| 225 | /** |
||
| 226 | * Will return a list of all dependencies eg. parent class, interfaces and traits. |
||
| 227 | * |
||
| 228 | * @return array |
||
| 229 | */ |
||
| 230 | public function getDependencies() |
||
| 231 | { |
||
| 232 | // Get our interfaces |
||
| 233 | $result = $this->implements; |
||
| 234 | |||
| 235 | // We got an error that this is nor array, weird but build up a final frontier here |
||
| 236 | if (!is_array($result)) { |
||
| 237 | $result = array($result); |
||
| 238 | } |
||
| 239 | |||
| 240 | // Add our parent class (if any) |
||
| 241 | if (!empty($this->extends)) { |
||
| 242 | $result[] = $this->extends; |
||
| 243 | } |
||
| 244 | |||
| 245 | return $result; |
||
| 246 | } |
||
| 247 | |||
| 248 | /** |
||
| 249 | * Getter method for attribute $extends |
||
| 250 | * |
||
| 251 | * @return string |
||
| 252 | */ |
||
| 253 | public function getExtends() |
||
| 254 | { |
||
| 255 | return $this->extends; |
||
| 256 | } |
||
| 257 | |||
| 258 | /** |
||
| 259 | * Getter method for attribute $implements |
||
| 260 | * |
||
| 261 | * @return array |
||
| 262 | */ |
||
| 263 | public function getImplements() |
||
| 264 | { |
||
| 265 | return $this->implements; |
||
| 266 | } |
||
| 267 | |||
| 268 | /** |
||
| 269 | * Getter method for attribute $introductions |
||
| 270 | * |
||
| 271 | * @return null|\AppserverIo\Doppelgaenger\Entities\Lists\IntroductionList |
||
| 272 | */ |
||
| 273 | public function getIntroductions() |
||
| 274 | { |
||
| 275 | return $this->introductions; |
||
| 276 | } |
||
| 277 | |||
| 278 | /** |
||
| 279 | * Getter method for attribute $invariantConditions |
||
| 280 | * |
||
| 281 | * @return null|AssertionList |
||
| 282 | */ |
||
| 283 | public function getInvariantConditions() |
||
| 284 | { |
||
| 285 | return $this->invariantConditions; |
||
| 286 | } |
||
| 287 | |||
| 288 | /** |
||
| 289 | * Getter method for attribute $isAbstract |
||
| 290 | * |
||
| 291 | * @return bool |
||
| 292 | */ |
||
| 293 | public function isAbstract() |
||
| 294 | { |
||
| 295 | return $this->isAbstract; |
||
| 296 | } |
||
| 297 | |||
| 298 | /** |
||
| 299 | * Getter method for attribute $isFinal |
||
| 300 | * |
||
| 301 | * @return bool |
||
| 302 | */ |
||
| 303 | public function isFinal() |
||
| 304 | { |
||
| 305 | return $this->isFinal; |
||
| 306 | } |
||
| 307 | |||
| 308 | /** |
||
| 309 | * Setter method for attribute $ancestralInvariants |
||
| 310 | * |
||
| 311 | * @param \AppserverIo\Doppelgaenger\Entities\Lists\AssertionList $ancestralInvariants Inherited invariant assertions |
||
| 312 | * |
||
| 313 | * @return null |
||
| 314 | */ |
||
| 315 | public function setAncestralInvariants(AssertionList $ancestralInvariants) |
||
| 316 | { |
||
| 317 | $this->ancestralInvariants = $ancestralInvariants; |
||
| 318 | } |
||
| 319 | |||
| 320 | /** |
||
| 321 | * Setter method for attribute $attributeDefinitions |
||
| 322 | * |
||
| 323 | * @param \AppserverIo\Doppelgaenger\Entities\Lists\AttributeDefinitionList $attributeDefinitions List of attribute definitions |
||
| 324 | * |
||
| 325 | * @return null |
||
| 326 | */ |
||
| 327 | public function setAttributeDefinitions(AttributeDefinitionList $attributeDefinitions) |
||
| 328 | { |
||
| 329 | $this->attributeDefinitions = $attributeDefinitions; |
||
| 330 | } |
||
| 331 | |||
| 332 | /** |
||
| 333 | * Setter method for the $constants property |
||
| 334 | * |
||
| 335 | * @param array $constants Constants the class defines |
||
| 336 | * |
||
| 337 | * @return null |
||
| 338 | */ |
||
| 339 | public function setConstants($constants) |
||
| 340 | { |
||
| 341 | $this->constants = $constants; |
||
| 342 | } |
||
| 343 | |||
| 344 | /** |
||
| 345 | * Setter method for the $extends property |
||
| 346 | * |
||
| 347 | * @param string $extends Potential parent class |
||
| 348 | * |
||
| 349 | * @return null |
||
| 350 | */ |
||
| 351 | public function setExtends($extends) |
||
| 352 | { |
||
| 353 | $this->extends = $extends; |
||
|
0 ignored issues
–
show
It seems like
$extends of type string is incompatible with the declared type array of property $extends.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 354 | } |
||
| 355 | |||
| 356 | /** |
||
| 357 | * Getter method for the $implements property |
||
| 358 | * |
||
| 359 | * @param array $implements Array of interfaces the class implements |
||
| 360 | * |
||
| 361 | * @return null |
||
| 362 | */ |
||
| 363 | public function setImplements($implements) |
||
| 364 | { |
||
| 365 | $this->implements = $implements; |
||
| 366 | } |
||
| 367 | |||
| 368 | /** |
||
| 369 | * Setter method for attribute $introductions |
||
| 370 | * |
||
| 371 | * @param \AppserverIo\Doppelgaenger\Entities\Lists\IntroductionList $introductions List of introductions |
||
| 372 | * |
||
| 373 | * @return null |
||
| 374 | */ |
||
| 375 | public function setIntroductions(IntroductionList $introductions) |
||
| 376 | { |
||
| 377 | $this->introductions = $introductions; |
||
| 378 | } |
||
| 379 | |||
| 380 | /** |
||
| 381 | * Setter method for attribute $invariantConditions |
||
| 382 | * |
||
| 383 | * @param \AppserverIo\Doppelgaenger\Entities\Lists\AssertionList $invariantConditions List of invariant assertions |
||
| 384 | * |
||
| 385 | * @return null |
||
| 386 | */ |
||
| 387 | public function setInvariantConditions(AssertionList $invariantConditions) |
||
| 388 | { |
||
| 389 | $this->invariantConditions = $invariantConditions; |
||
| 390 | } |
||
| 391 | |||
| 392 | /** |
||
| 393 | * Setter method for the $isAbstract property |
||
| 394 | * |
||
| 395 | * @param boolean $isAbstract If the class is abstract |
||
| 396 | * |
||
| 397 | * @return null |
||
| 398 | */ |
||
| 399 | public function setIsAbstract($isAbstract) |
||
| 400 | { |
||
| 401 | $this->isAbstract = $isAbstract; |
||
| 402 | } |
||
| 403 | |||
| 404 | /** |
||
| 405 | * Setter method for the $isFinal property |
||
| 406 | * |
||
| 407 | * @param boolean $isFinal If the class is defined final |
||
| 408 | * |
||
| 409 | * @return null |
||
| 410 | */ |
||
| 411 | public function setIsFinal($isFinal) |
||
| 412 | { |
||
| 413 | $this->isFinal = $isFinal; |
||
| 414 | } |
||
| 415 | } |
||
| 416 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..