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\DateTime; |
||
4 | |||
5 | use ValueObjects\Util\Util; |
||
6 | use ValueObjects\ValueObjectInterface; |
||
7 | |||
8 | class DateTime implements ValueObjectInterface |
||
9 | { |
||
10 | /** @var Date */ |
||
11 | protected $date; |
||
12 | |||
13 | /** @var Time */ |
||
14 | protected $time; |
||
15 | |||
16 | /** |
||
17 | * Returns a new DateTime object from native values |
||
18 | * |
||
19 | * @param int $year |
||
0 ignored issues
–
show
|
|||
20 | * @param string $month |
||
0 ignored issues
–
show
There is no parameter named
$month . 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. ![]() |
|||
21 | * @param int $day |
||
0 ignored issues
–
show
There is no parameter named
$day . 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. ![]() |
|||
22 | * @param int $hour |
||
0 ignored issues
–
show
There is no parameter named
$hour . 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. ![]() |
|||
23 | * @param int $minute |
||
0 ignored issues
–
show
There is no parameter named
$minute . 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. ![]() |
|||
24 | * @param int $second |
||
0 ignored issues
–
show
There is no parameter named
$second . 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. ![]() |
|||
25 | * @return DateTime |
||
26 | */ |
||
27 | 2 | public static function fromNative() |
|
28 | { |
||
29 | 2 | $args = func_get_args(); |
|
30 | |||
31 | 2 | $date = Date::fromNative($args[0], $args[1], $args[2]); |
|
32 | 2 | $time = Time::fromNative($args[3], $args[4], $args[5]); |
|
33 | |||
34 | 2 | return new static($date, $time); |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * Returns a new DateTime from a native PHP \DateTime |
||
39 | * |
||
40 | * @param \DateTime $date_time |
||
41 | * @return DateTime |
||
42 | */ |
||
43 | 2 | public static function fromNativeDateTime(\DateTime $date_time) |
|
44 | { |
||
45 | 2 | $date = Date::fromNativeDateTime($date_time); |
|
46 | 2 | $time = Time::fromNativeDateTime($date_time); |
|
47 | |||
48 | 2 | return new static($date, $time); |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Returns current DateTime |
||
53 | * |
||
54 | * @return DateTime |
||
55 | */ |
||
56 | 2 | public static function now() |
|
57 | { |
||
58 | 2 | $dateTime = new static(Date::now(), Time::now()); |
|
59 | |||
60 | 2 | return $dateTime; |
|
61 | } |
||
62 | |||
63 | /** |
||
64 | * Returns a new DateTime object |
||
65 | * |
||
66 | * @param Date $date |
||
67 | * @param Time $time |
||
68 | */ |
||
69 | 18 | public function __construct(Date $date, Time $time = null) |
|
70 | { |
||
71 | 18 | $this->date = $date; |
|
72 | |||
73 | 18 | if (null === $time) { |
|
74 | 1 | $time = Time::zero(); |
|
75 | 1 | } |
|
76 | |||
77 | 18 | $this->time = $time; |
|
78 | 18 | } |
|
79 | |||
80 | /** |
||
81 | * Tells whether two DateTime are equal by comparing their values |
||
82 | * |
||
83 | * @param ValueObjectInterface $date_time |
||
84 | * @return bool |
||
85 | */ |
||
86 | 8 | public function sameValueAs(ValueObjectInterface $date_time) |
|
87 | { |
||
88 | 8 | if (false === Util::classEquals($this, $date_time)) { |
|
89 | 1 | return false; |
|
90 | } |
||
91 | |||
92 | 8 | return $this->getDate()->sameValueAs($date_time->getDate()) && $this->getTime()->sameValueAs($date_time->getTime()); |
|
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
ValueObjects\ValueObjectInterface as the method getDate() does only exist in the following implementations of said interface: ValueObjects\DateTime\DateTime .
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.
![]() It seems like you code against a concrete implementation and not the interface
ValueObjects\ValueObjectInterface as the method getTime() does only exist in the following implementations of said interface: ValueObjects\DateTime\DateTime .
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.
![]() |
|||
93 | } |
||
94 | |||
95 | /** |
||
96 | * Returns date from current DateTime |
||
97 | * |
||
98 | * @return Date |
||
99 | */ |
||
100 | 15 | public function getDate() |
|
101 | { |
||
102 | 15 | return clone $this->date; |
|
103 | } |
||
104 | |||
105 | /** |
||
106 | * Returns time from current DateTime |
||
107 | * |
||
108 | * @return Time |
||
109 | */ |
||
110 | 16 | public function getTime() |
|
111 | { |
||
112 | 16 | return clone $this->time; |
|
113 | } |
||
114 | |||
115 | /** |
||
116 | * Returns a native PHP \DateTime version of the current DateTime. |
||
117 | * |
||
118 | * @return \DateTime |
||
119 | */ |
||
120 | 1 | public function toNativeDateTime() |
|
121 | { |
||
122 | 1 | $year = $this->getDate()->getYear()->toNative(); |
|
123 | 1 | $month = $this->getDate()->getMonth()->getNumericValue(); |
|
124 | 1 | $day = $this->getDate()->getDay()->toNative(); |
|
125 | 1 | $hour = $this->getTime()->getHour()->toNative(); |
|
126 | 1 | $minute = $this->getTime()->getMinute()->toNative(); |
|
127 | 1 | $second = $this->getTime()->getSecond()->toNative(); |
|
128 | |||
129 | 1 | $dateTime = new \DateTime(); |
|
130 | 1 | $dateTime->setDate($year, $month, $day); |
|
131 | 1 | $dateTime->setTime($hour, $minute, $second); |
|
132 | |||
133 | 1 | return $dateTime; |
|
134 | } |
||
135 | |||
136 | /** |
||
137 | * Returns DateTime as string in format "Y-n-j G:i:s" |
||
138 | * |
||
139 | * @return string |
||
140 | */ |
||
141 | 4 | public function __toString() |
|
142 | { |
||
143 | 4 | return \sprintf('%s %s', $this->getDate(), $this->getTime()); |
|
144 | } |
||
145 | } |
||
146 |
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.