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 | * @copyright Copyright 2016 Fwolf |
||
4 | * @license http://opensource.org/licenses/MIT MIT |
||
5 | */ |
||
6 | |||
7 | echo <<<TAG |
||
8 | Compare speed of array assign(initialize), used om base convert maps. |
||
9 | |||
10 | |||
11 | TAG; |
||
12 | |||
13 | |||
14 | $directAssign = function() { |
||
15 | $map = [ |
||
16 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', |
||
17 | 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', |
||
18 | 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', |
||
19 | 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', |
||
20 | 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', |
||
21 | ]; |
||
22 | |||
23 | $reverseMap = [ |
||
24 | '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, |
||
25 | '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9, |
||
26 | 'a' => 10, 'b' => 11, 'c' => 12, 'd' => 13, 'e' => 14, |
||
27 | 'f' => 15, 'g' => 16, 'h' => 17, 'i' => 18, 'j' => 19, |
||
28 | 'k' => 20, 'l' => 21, 'm' => 22, 'n' => 23, 'o' => 24, |
||
29 | 'p' => 25, 'q' => 26, 'r' => 27, 's' => 28, 't' => 29, |
||
30 | 'u' => 30, 'v' => 31, 'w' => 32, 'x' => 33, 'y' => 34, |
||
31 | 'z' => 35, |
||
32 | 'A' => 36, 'B' => 37, 'C' => 38, 'D' => 39, 'E' => 40, |
||
33 | 'F' => 41, 'G' => 42, 'H' => 43, 'I' => 44, 'J' => 45, |
||
34 | 'K' => 46, 'L' => 47, 'M' => 48, 'N' => 49, 'O' => 50, |
||
35 | 'P' => 51, 'Q' => 52, 'R' => 53, 'S' => 54, 'T' => 55, |
||
36 | 'U' => 56, 'V' => 57, 'W' => 58, 'X' => 59, 'Y' => 60, |
||
37 | 'Z' => 61, |
||
38 | ]; |
||
39 | |||
40 | return true || $map || $reverseMap; |
||
0 ignored issues
–
show
The expression
$reverseMap of type array<string,integer> is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
41 | }; |
||
42 | |||
43 | |||
44 | $arrayMerge = function () { |
||
45 | $map = array_merge( |
||
46 | ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], |
||
47 | ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'], |
||
48 | ['n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'], |
||
49 | ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M'], |
||
50 | ['N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] |
||
51 | ); |
||
52 | |||
53 | $reverseMap = array_merge( |
||
54 | ['0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4], |
||
55 | ['5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9], |
||
56 | ['a' => 10, 'b' => 11, 'c' => 12, 'd' => 13, 'e' => 14], |
||
57 | ['f' => 15, 'g' => 16, 'h' => 17, 'i' => 18, 'j' => 19], |
||
58 | ['k' => 20, 'l' => 21, 'm' => 22, 'n' => 23, 'o' => 24], |
||
59 | ['p' => 25, 'q' => 26, 'r' => 27, 's' => 28, 't' => 29], |
||
60 | ['u' => 30, 'v' => 31, 'w' => 32, 'x' => 33, 'y' => 34], |
||
61 | ['z' => 35], |
||
62 | ['A' => 36, 'B' => 37, 'C' => 38, 'D' => 39, 'E' => 40], |
||
63 | ['F' => 41, 'G' => 42, 'H' => 43, 'I' => 44, 'J' => 45], |
||
64 | ['K' => 46, 'L' => 47, 'M' => 48, 'N' => 49, 'O' => 50], |
||
65 | ['P' => 51, 'Q' => 52, 'R' => 53, 'S' => 54, 'T' => 55], |
||
66 | ['U' => 56, 'V' => 57, 'W' => 58, 'X' => 59, 'Y' => 60], |
||
67 | ['Z' => 61] |
||
68 | ); |
||
69 | |||
70 | return true || $map || $reverseMap; |
||
0 ignored issues
–
show
The expression
$map of type string[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() The expression
$reverseMap of type array<string,integer> is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
71 | }; |
||
72 | |||
73 | |||
74 | $arrayFlip = function () { |
||
75 | $map = array_merge( |
||
76 | ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], |
||
77 | ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'], |
||
78 | ['n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'], |
||
79 | ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M'], |
||
80 | ['N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] |
||
81 | ); |
||
82 | |||
83 | $reverseMap = array_flip($map); |
||
84 | |||
85 | return true || $map || $reverseMap; |
||
0 ignored issues
–
show
The expression
$map of type string[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() The expression
$reverseMap of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
86 | }; |
||
87 | |||
88 | |||
89 | $loopAssign = function() { |
||
90 | $dict = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
||
91 | |||
92 | $map = []; |
||
93 | $reverseMap = []; |
||
94 | for ($i = 0; $i < 62; $i++) { |
||
95 | $char = $dict{$i}; |
||
96 | $map[] = $char; |
||
97 | $reverseMap[$char] = $i; |
||
98 | } |
||
99 | |||
100 | return true || $map || $reverseMap; |
||
0 ignored issues
–
show
The expression
$map of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() The expression
$reverseMap of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
101 | }; |
||
102 | |||
103 | |||
104 | $maxLoop = 100000; |
||
105 | $time1 = $_SERVER["REQUEST_TIME_FLOAT"]; |
||
106 | |||
107 | for ($i = 0; $i < $maxLoop; $i++) { |
||
108 | $directAssign(); |
||
109 | } |
||
110 | $time2 = microtime(true); |
||
111 | |||
112 | for ($i = 0; $i < $maxLoop; $i++) { |
||
113 | $arrayMerge(); |
||
114 | } |
||
115 | $time3 = microtime(true); |
||
116 | |||
117 | for ($i = 0; $i < $maxLoop; $i++) { |
||
118 | $arrayFlip(); |
||
119 | } |
||
120 | $time4 = microtime(true); |
||
121 | |||
122 | for ($i = 0; $i < $maxLoop; $i++) { |
||
123 | $loopAssign(); |
||
124 | } |
||
125 | $time5 = microtime(true); |
||
126 | |||
127 | |||
128 | echo "Direct array assign: " . ($time2 - $time1) . PHP_EOL; |
||
129 | echo " Use array_merge(): " . ($time3 - $time2) . PHP_EOL; |
||
130 | echo " Use array_flip(): " . ($time4 - $time3) . PHP_EOL; |
||
131 | echo " Loop array assign: " . ($time5 - $time4) . PHP_EOL; |
||
132 | |||
133 | /** |
||
134 | * Example result: |
||
135 | |||
136 | Direct array assign: 0.94509100914001 |
||
137 | Use array_merge(): 1.7523620128632 |
||
138 | Use array_flip(): 1.3521640300751 |
||
139 | Loop array assign: 3.1361529827118 |
||
140 | |||
141 | */ |
||
142 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.