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 | namespace ValueObjects\Geography; |
||
4 | |||
5 | use ValueObjects\StringLiteral\StringLiteral; |
||
6 | use ValueObjects\Util\Util; |
||
7 | use ValueObjects\ValueObjectInterface; |
||
8 | |||
9 | class Street implements ValueObjectInterface |
||
10 | { |
||
11 | /** @var StringLiteral */ |
||
12 | protected $name; |
||
13 | |||
14 | /** @var StringLiteral */ |
||
15 | protected $number; |
||
16 | |||
17 | /** @var StringLiteral Building, floor and unit */ |
||
18 | protected $elements; |
||
19 | |||
20 | /** |
||
21 | * @var StringLiteral __toString() format |
||
22 | * Use properties corresponding placeholders: %name%, %number%, %elements% |
||
23 | */ |
||
24 | protected $format; |
||
25 | |||
26 | /** |
||
27 | * Returns a new Street from native PHP string name and number. |
||
28 | * |
||
29 | * @param string $name |
||
0 ignored issues
–
show
|
|||
30 | * @param string $number |
||
0 ignored issues
–
show
There is no parameter named
$number . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. ![]() |
|||
31 | * @param string $elements |
||
0 ignored issues
–
show
There is no parameter named
$elements . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. ![]() |
|||
32 | * @return Street |
||
33 | * @throws \BadFunctionCallException |
||
34 | */ |
||
35 | 2 | public static function fromNative() |
|
36 | { |
||
37 | 2 | $args = func_get_args(); |
|
38 | |||
39 | 2 | if (\count($args) < 2) { |
|
40 | 1 | throw new \BadMethodCallException('You must provide from 2 to 4 arguments: 1) street name, 2) street number, 3) elements, 4) format (optional)'); |
|
41 | } |
||
42 | |||
43 | 1 | $nameString = $args[0]; |
|
44 | 1 | $numberString = $args[1]; |
|
45 | 1 | $elementsString = isset($args[2]) ? $args[2] : null; |
|
46 | 1 | $formatString = isset($args[3]) ? $args[3] : null; |
|
47 | |||
48 | 1 | $name = new StringLiteral($nameString); |
|
49 | 1 | $number = new StringLiteral($numberString); |
|
50 | 1 | $elements = $elementsString ? new StringLiteral($elementsString) : null; |
|
51 | 1 | $format = $formatString ? new StringLiteral($formatString) : null; |
|
52 | |||
53 | 1 | return new static($name, $number, $elements, $format); |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * Returns a new Street object |
||
58 | * |
||
59 | * @param StringLiteral $name |
||
60 | * @param StringLiteral $number |
||
61 | */ |
||
62 | 18 | public function __construct(StringLiteral $name, StringLiteral $number, StringLiteral $elements = null, StringLiteral $format = null) |
|
63 | { |
||
64 | 18 | $this->name = $name; |
|
65 | 18 | $this->number = $number; |
|
66 | |||
67 | 18 | if ($elements === null) { |
|
68 | 12 | $elements = new StringLiteral(''); |
|
69 | 12 | } |
|
70 | 18 | $this->elements = $elements; |
|
71 | |||
72 | 18 | if ($format === null) { |
|
73 | 13 | $format = new StringLiteral('%number% %name%'); |
|
74 | 13 | } |
|
75 | 18 | $this->format = $format; |
|
76 | 18 | } |
|
77 | |||
78 | /** |
||
79 | * Tells whether two Street objects are equal |
||
80 | * @param ValueObjectInterface $street |
||
81 | * @return bool |
||
82 | */ |
||
83 | 5 | public function sameValueAs(ValueObjectInterface $street) |
|
84 | { |
||
85 | 5 | if (false === Util::classEquals($this, $street)) { |
|
86 | 1 | return false; |
|
87 | } |
||
88 | |||
89 | 5 | return $this->getName()->sameValueAs($street->getName()) && |
|
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
ValueObjects\ValueObjectInterface as the method getName() does only exist in the following implementations of said interface: ValueObjects\DateTime\Month , ValueObjects\DateTime\TimeZone , ValueObjects\DateTime\WeekDay , ValueObjects\Enum\Enum , ValueObjects\Geography\Address , ValueObjects\Geography\Continent , ValueObjects\Geography\Country , ValueObjects\Geography\CountryCode , ValueObjects\Geography\DistanceFormula , ValueObjects\Geography\DistanceUnit , ValueObjects\Geography\Ellipsoid , ValueObjects\Geography\Street , ValueObjects\Money\CurrencyCode , ValueObjects\Number\RoundingMode , ValueObjects\Person\Gender , ValueObjects\Web\IPAddressVersion .
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
90 | 5 | $this->getNumber()->sameValueAs($street->getNumber()) && |
|
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
ValueObjects\ValueObjectInterface as the method getNumber() does only exist in the following implementations of said interface: ValueObjects\Geography\Street .
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
91 | 5 | $this->getElements()->sameValueAs($street->getElements()) |
|
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
ValueObjects\ValueObjectInterface as the method getElements() does only exist in the following implementations of said interface: ValueObjects\Geography\Street .
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
92 | 5 | ; |
|
93 | } |
||
94 | |||
95 | /** |
||
96 | * Returns street name |
||
97 | * |
||
98 | * @return StringLiteral |
||
99 | */ |
||
100 | 8 | public function getName() |
|
101 | { |
||
102 | 8 | return clone $this->name; |
|
103 | } |
||
104 | |||
105 | /** |
||
106 | * Returns street number |
||
107 | * |
||
108 | * @return StringLiteral |
||
109 | */ |
||
110 | 8 | public function getNumber() |
|
111 | { |
||
112 | 8 | return clone $this->number; |
|
113 | } |
||
114 | |||
115 | /** |
||
116 | * Returns street elements |
||
117 | * @return StringLiteral |
||
118 | */ |
||
119 | 8 | public function getElements() |
|
120 | { |
||
121 | 8 | return clone $this->elements; |
|
122 | } |
||
123 | |||
124 | /** |
||
125 | * Returns a string representation of the StringLiteral in the format defined in the constructor |
||
126 | * |
||
127 | * @return string |
||
128 | */ |
||
129 | 2 | public function __toString() |
|
130 | { |
||
131 | $replacements = array( |
||
132 | 2 | "%name%" => $this->getName(), |
|
133 | 2 | "%number%" => $this->getNumber(), |
|
134 | 2 | "%elements%" => $this->getElements() |
|
135 | 2 | ); |
|
136 | |||
137 | 2 | $streetString = str_replace(array_keys($replacements), array_values($replacements), $this->format); |
|
138 | |||
139 | 2 | return $streetString; |
|
140 | } |
||
141 | } |
||
142 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.