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 | class CalendarMonthView extends CalendarAbstractWeekView |
||
0 ignored issues
–
show
|
|||
4 | { |
||
5 | |||
6 | // Attributes |
||
7 | |||
8 | private $monthClass; |
||
9 | |||
10 | // Abstract Functions Implemented |
||
11 | |||
12 | public function init() |
||
13 | { |
||
14 | parent::init(); |
||
15 | $this->containerClass = 'monthView'; |
||
16 | $this->innerClass = 'month'; |
||
17 | $this->viewTitle = 'return date(\'F Y\', $date);'; |
||
18 | $this->monthClass = 'return strtolower(date(\'F\', $monthDate));'; |
||
19 | } |
||
20 | |||
21 | public function needsMonth() |
||
22 | { |
||
23 | return true; |
||
24 | } |
||
25 | public function needsDay() |
||
26 | { |
||
27 | return false; |
||
28 | } |
||
29 | |||
30 | public function prevLinkParams(Calendar $calendar) |
||
31 | { |
||
32 | $date = mktime(0, 0, 0, $calendar->getMonth() - $this->number, 1, $calendar->getYear()); |
||
33 | return $this->getLinkParams($date); |
||
34 | } |
||
35 | |||
36 | public function nextLinkParams(Calendar $calendar) |
||
37 | { |
||
38 | $date = mktime(0, 0, 0, $calendar->getMonth() + $this->number, 1, $calendar->getYear()); |
||
39 | return $this->getLinkParams($date); |
||
40 | } |
||
41 | |||
42 | public function viewLinkParamsAndTitle(Calendar $calendar) |
||
43 | { |
||
44 | $month = $calendar->getMonth(); |
||
45 | if (! $month) { |
||
46 | $month = 1; |
||
47 | } |
||
48 | $year = $calendar->getYear(); |
||
49 | $date = mktime(0, 0, 0, $month, 1, $year); |
||
50 | $params = $this->getLinkParams($date); |
||
51 | $title = $this->getCustomisedTitle($month, $year); |
||
52 | return array($params, $title); |
||
53 | } |
||
54 | |||
55 | public function getLinkParams($date) |
||
56 | { |
||
57 | return array( |
||
58 | 'year' => date('Y', $date), |
||
59 | 'month' => date('n', $date) |
||
60 | ); |
||
61 | } |
||
62 | |||
63 | public function title() |
||
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 ![]() |
|||
64 | { |
||
65 | return $this->number == 1 ? 'month' : "$this->number months"; |
||
66 | } |
||
67 | |||
68 | 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 ![]() |
|||
69 | { |
||
70 | return $this->getCustomisedTitle($calendar->getMonth(), $calendar->getYear()); |
||
71 | } |
||
72 | |||
73 | public function Weeks(Calendar $calendar) |
||
74 | { |
||
75 | $year = $calendar->getYear(); |
||
76 | $month = $calendar->getMonth(); |
||
77 | |||
78 | $nowYear = date('Y'); |
||
79 | $nowMonth = date('n'); |
||
80 | |||
81 | for ($i = 0; $i < $this->number; $i++) { |
||
82 | $weeksGroup = $this->MonthWeeks($month, $year); |
||
83 | |||
84 | // 1) Single Values |
||
85 | |||
86 | $monthDate = mktime(0, 0, 0, $month, 1, $year); |
||
0 ignored issues
–
show
$monthDate 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 ![]() |
|||
87 | $values['ExtraInnerClass'] = eval($this->monthClass) . " year$year"; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$values was never initialized. Although not strictly required by PHP, it is generally a good practice to add $values = 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. ![]() It is generally not recommended to use
eval unless absolutely required.
On one hand, ![]() |
|||
88 | $values['IsNowYear'] = $year == $nowYear; |
||
0 ignored issues
–
show
The variable
$values 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
![]() |
|||
89 | $values['IsPastYear'] = $year < $nowYear; |
||
90 | $values['IsNow'] = $values['IsNowYear'] && $month == $nowMonth; |
||
91 | $values['IsPast'] = $values['IsPastYear'] || ($values['IsNowYear'] && $month < $nowMonth); |
||
92 | |||
93 | $weeksGroups[] = array($weeksGroup, $values); |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$weeksGroups was never initialized. Although not strictly required by PHP, it is generally a good practice to add $weeksGroups = 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. ![]() |
|||
94 | |||
95 | if (++$month > 12) { |
||
96 | $month = 1; |
||
97 | $year++; |
||
98 | } |
||
99 | } |
||
100 | |||
101 | return $weeksGroups; |
||
0 ignored issues
–
show
The variable
$weeksGroups 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
![]() |
|||
102 | } |
||
103 | |||
104 | // Private Functions |
||
105 | |||
106 | protected function MonthWeeks($month, $year) |
||
107 | { |
||
108 | $firstDate = mktime(0, 0, 0, $month, 1, $year); |
||
109 | $firstDateWeek = date('W', $firstDate); |
||
110 | $firstDateWeekYear = $year; |
||
111 | |||
112 | if ($month == 1 && $firstDateWeek >= 52) { |
||
113 | $firstDateWeekYear--; |
||
114 | } |
||
115 | |||
116 | $weekFirstDate = $this->getWeekStartDay($firstDateWeek, $firstDateWeekYear, true); |
||
117 | $nextWeekFirstDate = mktime(0, 0, 0, date('n', $weekFirstDate), date('j', $weekFirstDate) + 7, date('Y', $weekFirstDate)); |
||
118 | |||
119 | if (date('j', $nextWeekFirstDate) == 1) { |
||
120 | $weekFirstDate = $nextWeekFirstDate; |
||
121 | } |
||
122 | |||
123 | while (date('Y', $weekFirstDate) < $year || (date('Y', $weekFirstDate) == $year && date('n', $weekFirstDate) <= $month)) { |
||
124 | $weekMonday = $weekFirstDate; |
||
125 | View Code Duplication | while (date('N', $weekMonday) != 1) { |
|
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. ![]() |
|||
126 | $weekMonday = mktime(0, 0, 0, date('n', $weekMonday), date('j', $weekMonday) + 1, date('Y', $weekMonday)); |
||
127 | } |
||
128 | $week = date('W', $weekMonday); |
||
129 | $yearOfWeek = date('Y', $weekMonday); |
||
130 | if ($month == 1) { |
||
131 | if ($week == 1 && $yearOfWeek == $year - 1) { |
||
132 | $yearOfWeek++; |
||
133 | } elseif ($week >= 52 && $yearOfWeek == $year) { |
||
134 | $yearOfWeek--; |
||
135 | } |
||
136 | } elseif ($month == 12 && $week == 1) { |
||
137 | $yearOfWeek++; |
||
138 | } |
||
139 | |||
140 | $weeks[] = array('week' => $week, 'yearOfWeek' => $yearOfWeek, 'month' => $month, 'yearOfMonth' => $year); |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$weeks was never initialized. Although not strictly required by PHP, it is generally a good practice to add $weeks = 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. ![]() |
|||
141 | $weekFirstDate = mktime(0, 0, 0, date('n', $weekFirstDate), date('j', $weekFirstDate) + 7, date('Y', $weekFirstDate)); |
||
142 | } |
||
143 | |||
144 | return $weeks; |
||
0 ignored issues
–
show
The variable
$weeks 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
![]() |
|||
145 | } |
||
146 | |||
147 | // Other Functions |
||
148 | |||
149 | View Code Duplication | public function getCustomisedTitle($month, $year) |
|
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 ![]() This method seems to be duplicated in 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. ![]() |
|||
150 | { |
||
151 | $date = mktime(0, 0, 0, $month, 1, $year); |
||
0 ignored issues
–
show
$date 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 ![]() |
|||
152 | $result = eval($this->viewTitle); |
||
0 ignored issues
–
show
It is generally not recommended to use
eval unless absolutely required.
On one hand, ![]() |
|||
153 | if ($this->number > 1) { |
||
154 | $date = mktime(0, 0, 0, $month + $this->number - 1, 1, $year); |
||
0 ignored issues
–
show
$date 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 ![]() |
|||
155 | $result .= $this->viewTitleDelimiter . eval($this->viewTitle); |
||
0 ignored issues
–
show
It is generally not recommended to use
eval unless absolutely required.
On one hand, ![]() |
|||
156 | } |
||
157 | return $result; |
||
158 | } |
||
159 | } |
||
160 |
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.