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 | if (!function_exists('get_user_timezone')) { |
||
4 | function get_user_timezone() |
||
0 ignored issues
–
show
|
|||
5 | { |
||
6 | return 'UTC'; |
||
7 | } |
||
8 | } |
||
9 | |||
10 | if (!function_exists('get_request_ip')) { |
||
11 | function get_request_ip() |
||
0 ignored issues
–
show
function get_request_ip() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$ ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() 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 ![]() get_request_ip uses the super-global variable $_SERVER which is generally not recommended.
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: // Bad
class Router
{
public function generate($path)
{
return $_SERVER['HOST'].$path;
}
}
// Better
class Router
{
private $host;
public function __construct($host)
{
$this->host = $host;
}
public function generate($path)
{
return $this->host.$path;
}
}
class Controller
{
public function myAction(Request $request)
{
// Instead of
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
// Better (assuming you use the Symfony2 request)
$page = $request->query->get('page', 1);
}
}
![]() |
|||
12 | { |
||
13 | if (isset($_SERVER['X_FORWARDED_FOR'])) { |
||
14 | return $_SERVER['X_FORWARDED_FOR']; |
||
15 | } elseif (isset($_SERVER['CLIENT_IP'])) { |
||
16 | return $_SERVER['CLIENT_IP']; |
||
17 | } |
||
18 | |||
19 | return $_SERVER['REMOTE_ADDR']; |
||
20 | } |
||
21 | } |
||
22 | |||
23 | |||
24 | if (!function_exists('to_name_value')) { |
||
25 | function to_name_value($array, $keys = null) |
||
0 ignored issues
–
show
function to_name_value() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$ ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() |
|||
26 | { |
||
27 | $data = []; |
||
28 | foreach ($array as $name => $value) { |
||
29 | $row = ['name' => $name, 'value' => $value]; |
||
30 | if (isset($keys)) $row = array_merge($row, $keys); |
||
31 | array_push($data, $row); |
||
32 | } |
||
33 | |||
34 | return $data; |
||
35 | } |
||
36 | } |
||
37 | |||
38 | if (!function_exists('sorting_by_key')) { |
||
39 | /** |
||
40 | * Sorting callable helper |
||
41 | * |
||
42 | * @param string $key |
||
43 | * @param string $order |
||
44 | * |
||
45 | * @return Closure |
||
46 | */ |
||
47 | function sorting_by_key($key, $order = 'ASC') |
||
0 ignored issues
–
show
function sorting_by_key() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$ ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() |
|||
48 | { |
||
49 | return function ($a, $b) use ($key, $order) { |
||
50 | if ($a[$key] === $b[$key]) { |
||
51 | return 0; |
||
52 | } |
||
53 | |||
54 | $value = $a[$key] < $b[$key] ? -1 : 1; |
||
55 | if ($order === 'DESC') { |
||
56 | $value *= -1; |
||
57 | } |
||
58 | |||
59 | return $value; |
||
60 | }; |
||
61 | } |
||
62 | } |
||
63 | |||
64 | if (!function_exists('get_columns_flat_at')) { |
||
65 | /** |
||
66 | * Get all the columns name in the given level |
||
67 | * |
||
68 | * @param array $columns |
||
69 | * @param int $level |
||
70 | * |
||
71 | * @return array |
||
72 | */ |
||
73 | function get_columns_flat_at(array $columns, $level = 0) |
||
0 ignored issues
–
show
function get_columns_flat_at() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$ ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() |
|||
74 | { |
||
75 | $names = []; |
||
76 | |||
77 | foreach ($columns as $column) { |
||
78 | $parts = explode('.', $column); |
||
79 | |||
80 | if (isset($parts[$level])) { |
||
81 | $names[] = $parts[$level]; |
||
82 | } |
||
83 | } |
||
84 | |||
85 | return $names; |
||
86 | } |
||
87 | } |
||
88 | |||
89 | if (!function_exists('get_csv_flat_columns')) { |
||
90 | /** |
||
91 | * Gets a CSV flat columns list from the given array |
||
92 | * |
||
93 | * @param array $columns |
||
94 | * @param null $prefix |
||
95 | * |
||
96 | * @return string |
||
97 | */ |
||
98 | function get_csv_flat_columns(array $columns, $prefix = null) |
||
0 ignored issues
–
show
function get_csv_flat_columns() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$ ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() |
|||
99 | { |
||
100 | $flatColumns = []; |
||
101 | $prefix = $prefix === null ? '' : $prefix . '.'; |
||
102 | |||
103 | foreach ($columns as $key => $value) { |
||
104 | if (is_array($value)) { |
||
105 | $value = get_csv_flat_columns($value, $prefix . $key); |
||
106 | } else { |
||
107 | $value = $prefix . $key; |
||
108 | } |
||
109 | |||
110 | $flatColumns[] = $value; |
||
111 | } |
||
112 | |||
113 | return implode(',', $flatColumns); |
||
114 | } |
||
115 | } |
||
116 | |||
117 | if (!function_exists('get_array_flat_columns')) { |
||
118 | /** |
||
119 | * Gets an array flat columns list from the given array |
||
120 | * |
||
121 | * @param $columns |
||
122 | * |
||
123 | * @return array |
||
124 | */ |
||
125 | function get_array_flat_columns($columns) |
||
0 ignored issues
–
show
function get_array_flat_columns() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$ ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() |
|||
126 | { |
||
127 | // TODO: make sure array is passed??? |
||
128 | return explode(',', get_csv_flat_columns($columns ?: [])); |
||
129 | } |
||
130 | } |
||
131 | if (!function_exists('get_unflat_columns')) { |
||
132 | /** |
||
133 | * Gets the unflat version of flat (dot-notated) column list |
||
134 | * |
||
135 | * @param string|array $columns |
||
136 | * |
||
137 | * @return array |
||
138 | */ |
||
139 | function get_unflat_columns($columns) |
||
0 ignored issues
–
show
function get_unflat_columns() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$ ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() |
|||
140 | { |
||
141 | $names = []; |
||
142 | |||
143 | if (!is_array($columns)) { |
||
144 | $columns = explode(',', $columns); |
||
145 | } |
||
146 | |||
147 | foreach ($columns as $column) { |
||
148 | $parts = explode('.', $column, 2); |
||
149 | |||
150 | if (isset($parts[0])) { |
||
151 | View Code Duplication | if (!isset($names[$parts[0]])) { |
|
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. ![]() |
|||
152 | $names[$parts[0]] = null; |
||
153 | } |
||
154 | |||
155 | if (isset($parts[1])) { |
||
156 | View Code Duplication | if ($names[$parts[0]] === null) { |
|
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. ![]() |
|||
157 | $names[$parts[0]] = []; |
||
158 | } |
||
159 | |||
160 | $child = get_unflat_columns($parts[1]); |
||
161 | $names[$parts[0]][key($child)] = current($child); |
||
162 | }; |
||
163 | } |
||
164 | } |
||
165 | |||
166 | return $names; |
||
167 | } |
||
168 | } |
||
169 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.