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 | abstract class CalendarAbstractTimeView extends CalendarAbstractView |
||
0 ignored issues
–
show
|
|||
4 | { |
||
5 | |||
6 | // Attributes |
||
7 | |||
8 | private $timePeriod; |
||
9 | private $subPeriodsLength; |
||
10 | private $subPeriodsRemoved = array(); |
||
11 | |||
12 | protected $timeTitle; |
||
13 | protected $dayTitleClass; |
||
14 | protected $dayTitle; |
||
15 | protected $timeClass; |
||
16 | protected $time; |
||
17 | protected $dayClass; |
||
18 | |||
19 | // Abstract Functions Implemented |
||
20 | |||
21 | public function init() |
||
22 | { |
||
23 | $this->timePeriod = new CalendarTimePeriod(new CalendarTime(), new CalendarTime(23, 59, 59)); |
||
24 | $this->subPeriodsLength = new CalendarTime(1); |
||
25 | |||
26 | $this->dayTitleClass = 'return strtolower(date(\'l\', $date));'; |
||
27 | $this->dayTitle = 'return date(\'l jS F Y\', $date);'; |
||
28 | $this->timeClass = 'return \'hour\' . date(\'H\', $subPeriodStartDateTime) . \' minute\' . date(\'i\', $subPeriodStartDateTime) . \' second\' . date(\'s\', $subPeriodStartDateTime);'; |
||
29 | $this->time = 'return date(\'H:i\', $subPeriodStartDateTime);'; |
||
30 | $this->dayClass = 'return strtolower(date(\'l\', $subPeriodStart));'; |
||
31 | } |
||
32 | |||
33 | public function needsMonth() |
||
34 | { |
||
35 | return true; |
||
36 | } |
||
37 | public function needsDay() |
||
38 | { |
||
39 | return true; |
||
40 | } |
||
41 | |||
42 | public function Calendars(Calendar $calendar) |
||
43 | { |
||
44 | $datesGroups = $this->Dates($calendar); |
||
45 | |||
46 | foreach ($datesGroups as $datesGroup) { |
||
47 | $calendars[] = $this->Calendar($datesGroup, $calendar); |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$calendars was never initialized. Although not strictly required by PHP, it is generally a good practice to add $calendars = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
48 | } |
||
49 | |||
50 | return new ArrayList($calendars); |
||
0 ignored issues
–
show
The variable
$calendars does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
51 | } |
||
52 | |||
53 | public function viewLinkParamsAndTitle(Calendar $calendar) |
||
54 | { |
||
55 | $day = $calendar->getDay(); |
||
56 | if (! $day) { |
||
57 | $day = 1; |
||
58 | } |
||
59 | $month = $calendar->getMonth(); |
||
60 | if (! $month) { |
||
61 | $month = 1; |
||
62 | } |
||
63 | $year = $calendar->getYear(); |
||
64 | $date = mktime(0, 0, 0, $month, $day, $year); |
||
65 | $params = $this->getLinkParams($date); |
||
66 | $title = $this->getCustomisedTitle($day, $month, $year); |
||
67 | return array($params, $title); |
||
68 | } |
||
69 | |||
70 | public function getLinkParams($date) |
||
71 | { |
||
72 | return array( |
||
73 | 'year' => date('Y', $date), |
||
74 | 'month' => date('n', $date), |
||
75 | 'day' => date('j', $date) |
||
76 | ); |
||
77 | } |
||
78 | |||
79 | public function DateTitle(Calendar $calendar) |
||
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a ![]() |
|||
80 | { |
||
81 | return $this->getCustomisedTitle($calendar->getDay(), $calendar->getMonth(), $calendar->getYear()); |
||
82 | } |
||
83 | |||
84 | // Functions |
||
85 | |||
86 | public function setTimePeriod(CalendarTimePeriod $timePeriod) |
||
87 | { |
||
88 | $this->timePeriod = $timePeriod; |
||
89 | } |
||
90 | public function setSubPeriodsLength(CalendarTime $subPeriodsLength) |
||
91 | { |
||
92 | $this->subPeriodsLength = $subPeriodsLength; |
||
93 | } |
||
94 | |||
95 | public function removeSubPeriods($subPeriods) |
||
96 | { |
||
97 | if (! is_array($subPeriods)) { |
||
98 | $subPeriods = array($subPeriods); |
||
99 | } |
||
100 | foreach ($subPeriods as $subPeriod) { |
||
101 | if (is_a($subPeriod, 'CalendarTimePeriod')) { |
||
102 | $this->subPeriodsRemoved[] = $subPeriod; |
||
103 | } else { |
||
104 | user_error('CalendarAbstractTimeView::removeSubPeriods() : you cannot remove a period which class is not \'CalendarTimePeriod\'', E_USER_ERROR); |
||
105 | } |
||
106 | } |
||
107 | } |
||
108 | |||
109 | public function getSubPeriods() |
||
110 | { |
||
111 | $startSubPeriodTime = $this->timePeriod->getStartTime(); |
||
112 | $endTime = $this->timePeriod->getEndTime(); |
||
113 | |||
114 | while ($startSubPeriodTime < $endTime) { |
||
115 | $endSubPeriodTime = $this->getEndSubPeriodTime($startSubPeriodTime); |
||
116 | $subPeriods[] = new CalendarTimePeriod($startSubPeriodTime, $endSubPeriodTime); |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$subPeriods was never initialized. Although not strictly required by PHP, it is generally a good practice to add $subPeriods = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
117 | $startSubPeriodTime = $endSubPeriodTime; |
||
118 | } |
||
119 | |||
120 | return $subPeriods; |
||
0 ignored issues
–
show
The variable
$subPeriods does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
121 | } |
||
122 | |||
123 | public function setTimeTitle($timeTitle) |
||
124 | { |
||
125 | $this->timeTitle = $timeTitle; |
||
126 | } |
||
127 | public function setDayTitleClass($dayTitleClass) |
||
128 | { |
||
129 | $this->dayTitleClass = $dayTitleClass; |
||
130 | } |
||
131 | public function setDayTitle($dayTitle) |
||
132 | { |
||
133 | $this->dayTitle = $dayTitle; |
||
134 | } |
||
135 | public function setTimeClass($timeClass) |
||
136 | { |
||
137 | $this->timeClass = $timeClass; |
||
138 | } |
||
139 | public function setTime($time) |
||
140 | { |
||
141 | $this->time = $time; |
||
142 | } |
||
143 | public function setDayClass($dayClass) |
||
144 | { |
||
145 | $this->dayClass = $dayClass; |
||
146 | } |
||
147 | |||
148 | // Private Functions |
||
149 | |||
150 | private function getEndSubPeriodTime(CalendarTime $startSubPeriodTime) |
||
151 | { |
||
152 | $endSubPeriodTime = $startSubPeriodTime->add($this->subPeriodsLength); |
||
153 | |||
154 | if ($endSubPeriodTime < $startSubPeriodTime) { |
||
155 | $endSubPeriodTime = clone $this->timePeriod->getEndTime(); |
||
156 | } |
||
157 | |||
158 | return $endSubPeriodTime; |
||
159 | } |
||
160 | |||
161 | // Abstract Functions |
||
162 | |||
163 | abstract public function Dates(Calendar $calendar); |
||
0 ignored issues
–
show
For interfaces and abstract methods it is generally a good practice to add a
@return annotation even if it is just @return void or @return null , so that implementors know what to do in the overridden method.
For interface and abstract methods, it is impossible to infer the return type
from the immediate code. In these cases, it is generally advisible to explicitly
annotate these methods with a ![]() |
|||
164 | |||
165 | abstract public function getCustomisedTitle($day, $month, $year); |
||
0 ignored issues
–
show
For interfaces and abstract methods it is generally a good practice to add a
@return annotation even if it is just @return void or @return null , so that implementors know what to do in the overridden method.
For interface and abstract methods, it is impossible to infer the return type
from the immediate code. In these cases, it is generally advisible to explicitly
annotate these methods with a ![]() |
|||
166 | |||
167 | // Template Functions |
||
168 | |||
169 | private function Calendar($dates, Calendar $currentCalendar) |
||
170 | { |
||
171 | |||
172 | // 1) Single Values |
||
173 | |||
174 | $calendar['InnerClass'] = $this->innerClass; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$calendar was never initialized. Although not strictly required by PHP, it is generally a good practice to add $calendar = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
175 | $calendar['TimeTitle'] = $this->timeTitle; |
||
176 | |||
177 | // 2) Days Values |
||
178 | |||
179 | View Code Duplication | foreach ($dates as $date) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
180 | $dayTitleClass = eval($this->dayTitleClass); |
||
0 ignored issues
–
show
It is generally not recommended to use
eval unless absolutely required.
On one hand, ![]() |
|||
181 | $dayTitle = eval($this->dayTitle); |
||
0 ignored issues
–
show
It is generally not recommended to use
eval unless absolutely required.
On one hand, ![]() |
|||
182 | $days[] = new ArrayData(array('DayTitleClass' => $dayTitleClass, 'DayTitle' => $dayTitle)); |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$days was never initialized. Although not strictly required by PHP, it is generally a good practice to add $days = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
183 | } |
||
184 | |||
185 | $calendar['Days'] = new ArrayList($days); |
||
0 ignored issues
–
show
The variable
$days does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
186 | |||
187 | // 3) Periods Values |
||
188 | |||
189 | $subPeriods = $this->getSubPeriods(); |
||
190 | |||
191 | $todayNow = mktime(); |
||
192 | |||
193 | foreach ($subPeriods as $subPeriod) { |
||
194 | $period = array(); |
||
195 | |||
196 | $subPeriodStartTime = $subPeriod->getStartTime(); |
||
197 | $subPeriodEndTime = $subPeriod->getEndTime(); |
||
198 | |||
199 | $subPeriodStartTimeHours = $subPeriodStartTime->getHours(); |
||
200 | $subPeriodEndTimeHours = $subPeriodEndTime->getHours(); |
||
201 | |||
202 | $subPeriodStartTimeMinutes = $subPeriodStartTime->getMinutes(); |
||
203 | $subPeriodEndTimeMinutes = $subPeriodEndTime->getMinutes(); |
||
204 | |||
205 | $subPeriodStartTimeSeconds = $subPeriodStartTime->getSeconds(); |
||
206 | $subPeriodEndTimeSeconds = $subPeriodEndTime->getSeconds(); |
||
207 | |||
208 | $subPeriodStartDateTime = mktime($subPeriodStartTimeHours, $subPeriodStartTimeMinutes, $subPeriodStartTimeSeconds, 0, 0, 0); |
||
0 ignored issues
–
show
$subPeriodStartDateTime is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
209 | $subPeriodEndDateTime = mktime($subPeriodEndTimeHours, $subPeriodEndTimeMinutes, $subPeriodEndTimeSeconds, 0, 0, 0); |
||
0 ignored issues
–
show
$subPeriodEndDateTime is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
210 | |||
211 | // 1) Single Values |
||
212 | |||
213 | $period['TimeClass'] = eval($this->timeClass); |
||
0 ignored issues
–
show
It is generally not recommended to use
eval unless absolutely required.
On one hand, ![]() |
|||
214 | $period['Time'] = eval($this->time); |
||
0 ignored issues
–
show
It is generally not recommended to use
eval unless absolutely required.
On one hand, ![]() |
|||
215 | |||
216 | // 2) Days Values |
||
217 | |||
218 | $days = array(); |
||
219 | |||
220 | foreach ($dates as $date) { |
||
221 | $day = date('j', $date); |
||
222 | $month = date('n', $date); |
||
223 | $year = date('Y', $date); |
||
224 | |||
225 | $subPeriodStart = mktime($subPeriodStartTimeHours, $subPeriodStartTimeMinutes, $subPeriodStartTimeSeconds, $month, $day, $year); |
||
226 | $subPeriodEnd = mktime($subPeriodEndTimeHours, $subPeriodEndTimeMinutes, $subPeriodEndTimeSeconds, $month, $day, $year); |
||
227 | |||
228 | $subPeriodParams = array(); |
||
229 | |||
230 | $subPeriodParams['IsTodayNow'] = $subPeriodStart <= $todayNow && $todayNow <= $subPeriodEnd; |
||
231 | $subPeriodParams['IsToday'] = $day == date('j') && $month == date('n') && $year == date('Y'); |
||
232 | $subPeriodParams['IsPast'] = $subPeriodStart < $todayNow; |
||
233 | $subPeriodParams['DayClass'] = eval($this->dayClass); |
||
0 ignored issues
–
show
It is generally not recommended to use
eval unless absolutely required.
On one hand, ![]() |
|||
234 | |||
235 | $this->extend('updateSubPeriodParams', $subPeriodStart, $subPeriodEnd, $subPeriodParams, $currentCalendar); |
||
236 | |||
237 | $days[] = new ArrayData($subPeriodParams); |
||
238 | } |
||
239 | |||
240 | $period['Days'] = new ArrayList($days); |
||
241 | |||
242 | $periods[] = new ArrayData($period); |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$periods was never initialized. Although not strictly required by PHP, it is generally a good practice to add $periods = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
243 | } |
||
244 | |||
245 | $calendar['Periods'] = new ArrayList($periods); |
||
0 ignored issues
–
show
The variable
$periods does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
246 | |||
247 | return new ArrayData($calendar); |
||
248 | } |
||
249 | } |
||
250 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.