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\InterfaceDefinition |
||
| 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\FunctionDefinitionList; |
||
| 25 | use AppserverIo\Doppelgaenger\Entities\Lists\TypedListList; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * This class acts as a DTO-like (we are not immutable due to protected visibility) |
||
| 29 | * entity for describing interface definitions |
||
| 30 | * |
||
| 31 | * @author Bernhard Wick <[email protected]> |
||
| 32 | * @copyright 2015 TechDivision GmbH - <[email protected]> |
||
| 33 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
||
| 34 | * @link https://github.com/appserver-io/doppelgaenger |
||
| 35 | * @link http://www.appserver.io/ |
||
| 36 | */ |
||
| 37 | class InterfaceDefinition extends AbstractStructureDefinition |
||
| 38 | { |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @const string TYPE The structure type |
||
| 42 | */ |
||
| 43 | const TYPE = 'interface'; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * The parent interfaces (if any) |
||
| 47 | * |
||
| 48 | * @var string $extends |
||
| 49 | */ |
||
| 50 | protected $extends; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Possible constants the interface defines |
||
| 54 | * |
||
| 55 | * @var array $constants |
||
| 56 | */ |
||
| 57 | protected $constants; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Default constructor |
||
| 61 | * |
||
| 62 | * TODO The constructor does not use all members |
||
|
0 ignored issues
–
show
Coding Style
Best Practice
introduced
by
Loading history...
|
|||
| 63 | * |
||
| 64 | * @param string $docBlock DocBlock header of the interface |
||
| 65 | * @param string $name $name Interface name |
||
| 66 | * @param string $namespace The namespace the definition resides in |
||
| 67 | * @param array $extends The parent interfaces (if any) |
||
| 68 | * @param array $constants Possible constants the interface defines |
||
| 69 | * @param AssertionList|null $invariantConditions Invariant conditions |
||
| 70 | * @param AssertionList|null $ancestralInvariants Ancestral invariants |
||
| 71 | * @param FunctionDefinitionList|null $functionDefinitions List of functions defined within the interface |
||
| 72 | */ |
||
| 73 | public function __construct( |
||
| 74 | $docBlock = '', |
||
| 75 | $name = '', |
||
| 76 | $namespace = '', |
||
| 77 | $extends = array(), |
||
| 78 | $constants = array(), |
||
| 79 | $invariantConditions = null, |
||
| 80 | $ancestralInvariants = null, |
||
| 81 | $functionDefinitions = null |
||
| 82 | ) { |
||
| 83 | $this->docBlock = $docBlock; |
||
| 84 | $this->name = $name; |
||
| 85 | $this->namespace = $namespace; |
||
| 86 | $this->extends = $extends; |
||
|
0 ignored issues
–
show
It seems like
$extends of type array is incompatible with the declared type string 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...
|
|||
| 87 | $this->constants = $constants; |
||
| 88 | $this->invariantConditions = is_null($invariantConditions) ? new AssertionList() : $invariantConditions; |
||
| 89 | $this->ancestralInvariants = is_null($ancestralInvariants) ? new TypedListList() : $ancestralInvariants; |
||
|
0 ignored issues
–
show
It seems like
is_null($ancestralInvari... : $ancestralInvariants can also be of type object<AppserverIo\Doppe...es\Lists\AssertionList>. However, the property $ancestralInvariants is declared as type object<AppserverIo\Doppe...es\Lists\TypedListList>. Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
Loading history...
|
|||
| 90 | $this->functionDefinitions = is_null( |
||
| 91 | $functionDefinitions |
||
| 92 | ) ? new FunctionDefinitionList() : $functionDefinitions; |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Getter method for attribute $constants |
||
| 97 | * |
||
| 98 | * @return array |
||
| 99 | */ |
||
| 100 | public function getConstants() |
||
| 101 | { |
||
| 102 | return $this->constants; |
||
| 103 | } |
||
| 104 | |||
| 105 | /** |
||
| 106 | * Will return a list of all dependencies eg. parent class, interfaces and traits. |
||
| 107 | * |
||
| 108 | * @return array |
||
| 109 | */ |
||
| 110 | public function getDependencies() |
||
| 111 | { |
||
| 112 | // Get our interfaces |
||
| 113 | $result = $this->extends; |
||
| 114 | |||
| 115 | // We got an error that this is nor array, weird but build up a final frontier here |
||
| 116 | if (!is_array($result)) { |
||
| 117 | $result = array($result); |
||
| 118 | } |
||
| 119 | |||
| 120 | return $result; |
||
| 121 | } |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Getter method for attribute $extends |
||
| 125 | * |
||
| 126 | * @return string |
||
| 127 | */ |
||
| 128 | public function getExtends() |
||
| 129 | { |
||
| 130 | return $this->extends; |
||
| 131 | } |
||
| 132 | |||
| 133 | /** |
||
| 134 | * Setter method for attribute $ancestralInvariants |
||
| 135 | * |
||
| 136 | * @param \AppserverIo\Doppelgaenger\Entities\Lists\AssertionList $ancestralInvariants Inherited invariant assertions |
||
| 137 | * |
||
| 138 | * @return null |
||
| 139 | */ |
||
| 140 | public function setAncestralInvariants(AssertionList $ancestralInvariants) |
||
| 141 | { |
||
| 142 | $this->ancestralInvariants = $ancestralInvariants; |
||
|
0 ignored issues
–
show
It seems like
$ancestralInvariants of type object<AppserverIo\Doppe...es\Lists\AssertionList> is incompatible with the declared type object<AppserverIo\Doppe...es\Lists\TypedListList> 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...
|
|||
| 143 | } |
||
| 144 | |||
| 145 | /** |
||
| 146 | * Setter method for the $constants property |
||
| 147 | * |
||
| 148 | * @param array $constants Constants the class defines |
||
| 149 | * |
||
| 150 | * @return null |
||
| 151 | */ |
||
| 152 | public function setConstants($constants) |
||
| 153 | { |
||
| 154 | $this->constants = $constants; |
||
| 155 | } |
||
| 156 | |||
| 157 | /** |
||
| 158 | * Setter method for the $extends property |
||
| 159 | * |
||
| 160 | * @param string $extends Potential parent class |
||
| 161 | * |
||
| 162 | * @return null |
||
| 163 | */ |
||
| 164 | public function setExtends($extends) |
||
| 165 | { |
||
| 166 | $this->extends = $extends; |
||
| 167 | } |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Setter method for attribute $invariantConditions |
||
| 171 | * |
||
| 172 | * @param \AppserverIo\Doppelgaenger\Entities\Lists\AssertionList $invariantConditions List of invariant assertions |
||
| 173 | * |
||
| 174 | * @return null |
||
| 175 | */ |
||
| 176 | public function setInvariantConditions(AssertionList $invariantConditions) |
||
| 177 | { |
||
| 178 | $this->invariantConditions = $invariantConditions; |
||
| 179 | } |
||
| 180 | } |
||
| 181 |