@@ -160,6 +160,6 @@ |
||
160 | 160 | */ |
161 | 161 | public function testWithNull($filter) |
162 | 162 | { |
163 | - $this->assertRender('-', '{{ null|' . $filter . '("//")|default("-") }}'); |
|
163 | + $this->assertRender('-', '{{ null|'.$filter.'("//")|default("-") }}'); |
|
164 | 164 | } |
165 | 165 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | return null; |
44 | 44 | } |
45 | 45 | |
46 | - return '<p>' . preg_replace(['~\n(\s*)\n\s*~', '~(?<!</p>)\n\s*~'], ["</p>\n\$1<p>", "<br>\n"], trim($value)) . |
|
46 | + return '<p>'.preg_replace(['~\n(\s*)\n\s*~', '~(?<!</p>)\n\s*~'], ["</p>\n\$1<p>", "<br>\n"], trim($value)). |
|
47 | 47 | '</p>'; |
48 | 48 | } |
49 | 49 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | $pos = stripos($value, $break); |
83 | - return $pos === false ? $value : substr($value, 0, $pos) . $replace; |
|
83 | + return $pos === false ? $value : substr($value, 0, $pos).$replace; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | return null; |
98 | 98 | } |
99 | 99 | |
100 | - return strlen($value) <= $length ? $value : substr($value, 0, $length - strip_tags($replace)) . $replace; |
|
100 | + return strlen($value) <= $length ? $value : substr($value, 0, $length - strip_tags($replace)).$replace; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | ? '~(?:(https?)://([^\s<>]+)|(?<!\w@)\b(www\.[^\s<>]+?\.[^\s<>]+))(?<![\.,:;\?!\'"\|])~i' |
116 | 116 | : '~(?:(https?)://([^\s<>]+)|(?<!\w@)\b([^\s<>@]+?\.[^\s<>]+)(?<![\.,:]))~i'; |
117 | 117 | |
118 | - return preg_replace_callback($regexp, function ($match) use ($protocol, &$links, $attr) { |
|
118 | + return preg_replace_callback($regexp, function($match) use ($protocol, &$links, $attr) { |
|
119 | 119 | if ($match[1]) $protocol = $match[1]; |
120 | 120 | $link = $match[2] ?: $match[3]; |
121 | 121 | |
122 | - return '<' . array_push($links, '<a' . $attr . ' href="' . $protocol . '://' . $link . '">' |
|
123 | - . rtrim($link, '/') . '</a>') . '>'; |
|
122 | + return '<'.array_push($links, '<a'.$attr.' href="'.$protocol.'://'.$link.'">' |
|
123 | + . rtrim($link, '/').'</a>').'>'; |
|
124 | 124 | }, $text); |
125 | 125 | } |
126 | 126 | |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | { |
136 | 136 | $regexp = '~([^\s<>]+?@[^\s<>]+?\.[^\s<>]+)(?<![\.,:;\?!\'"\|])~'; |
137 | 137 | |
138 | - return preg_replace_callback($regexp, function ($match) use (&$links, $attr) { |
|
139 | - return '<' . array_push($links, '<a' . $attr . ' href="mailto:' . $match[1] . '">' . $match[1] . '</a>') |
|
138 | + return preg_replace_callback($regexp, function($match) use (&$links, $attr) { |
|
139 | + return '<'.array_push($links, '<a'.$attr.' href="mailto:'.$match[1].'">'.$match[1].'</a>') |
|
140 | 140 | . '>'; |
141 | 141 | }, $text); |
142 | 142 | } |
@@ -154,16 +154,16 @@ discard block |
||
154 | 154 | protected function linkifyOther($protocol, $text, array &$links, $attr, $mode) |
155 | 155 | { |
156 | 156 | if (strpos($protocol, ':') === false) { |
157 | - $protocol .= in_array($protocol, ['ftp', 'tftp', 'ssh', 'scp']) ? '://' : ':'; |
|
157 | + $protocol .= in_array($protocol, ['ftp', 'tftp', 'ssh', 'scp']) ? '://' : ':'; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | $regexp = $mode != 'all' |
161 | - ? '~' . preg_quote($protocol, '~') . '([^\s<>]+)(?<![\.,:;\?!\'"\|])~i' |
|
161 | + ? '~'.preg_quote($protocol, '~').'([^\s<>]+)(?<![\.,:;\?!\'"\|])~i' |
|
162 | 162 | : '~([^\s<>]+)(?<![\.,:])~i'; |
163 | 163 | |
164 | - return preg_replace_callback($regexp, function ($match) use ($protocol, &$links, $attr) { |
|
165 | - return '<' . array_push($links, '<a' . $attr . ' href="' . $protocol . $match[1] . '">' . $match[1] |
|
166 | - . '</a>') . '>'; |
|
164 | + return preg_replace_callback($regexp, function($match) use ($protocol, &$links, $attr) { |
|
165 | + return '<'.array_push($links, '<a'.$attr.' href="'.$protocol.$match[1].'">'.$match[1] |
|
166 | + . '</a>').'>'; |
|
167 | 167 | }, $text); |
168 | 168 | } |
169 | 169 | |
@@ -185,14 +185,14 @@ discard block |
||
185 | 185 | // Link attributes |
186 | 186 | $attr = ''; |
187 | 187 | foreach ($attributes as $key => $val) { |
188 | - $attr .= ' ' . $key . '="' . htmlentities($val) . '"'; |
|
188 | + $attr .= ' '.$key.'="'.htmlentities($val).'"'; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | $links = []; |
192 | 192 | |
193 | 193 | // Extract existing links and tags |
194 | - $text = preg_replace_callback('~(<a .*?>.*?</a>|<.*?>)~i', function ($match) use (&$links) { |
|
195 | - return '<' . array_push($links, $match[1]) . '>'; |
|
194 | + $text = preg_replace_callback('~(<a .*?>.*?</a>|<.*?>)~i', function($match) use (&$links) { |
|
195 | + return '<'.array_push($links, $match[1]).'>'; |
|
196 | 196 | }, $value); |
197 | 197 | |
198 | 198 | // Extract text links for each protocol |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | } |
207 | 207 | |
208 | 208 | // Insert all link |
209 | - return preg_replace_callback('/<(\d+)>/', function ($match) use (&$links) { |
|
209 | + return preg_replace_callback('/<(\d+)>/', function($match) use (&$links) { |
|
210 | 210 | return $links[$match[1] - 1]; |
211 | 211 | }, $text); |
212 | 212 | } |
@@ -116,7 +116,9 @@ |
||
116 | 116 | : '~(?:(https?)://([^\s<>]+)|(?<!\w@)\b([^\s<>@]+?\.[^\s<>]+)(?<![\.,:]))~i'; |
117 | 117 | |
118 | 118 | return preg_replace_callback($regexp, function ($match) use ($protocol, &$links, $attr) { |
119 | - if ($match[1]) $protocol = $match[1]; |
|
119 | + if ($match[1]) { |
|
120 | + $protocol = $match[1]; |
|
121 | + } |
|
120 | 122 | $link = $match[2] ?: $match[3]; |
121 | 123 | |
122 | 124 | return '<' . array_push($links, '<a' . $attr . ' href="' . $protocol . '://' . $link . '">' |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * Callback for Twig to get all the filters. |
33 | 33 | * |
34 | - * @return \Twig_Filter[] |
|
34 | + * @return \Twig_SimpleFilter[] |
|
35 | 35 | */ |
36 | 36 | public function getFilters() |
37 | 37 | { |
@@ -211,6 +211,7 @@ discard block |
||
211 | 211 | * Split duration into seconds, minutes, hours, days, weeks and years. |
212 | 212 | * |
213 | 213 | * @param int $seconds |
214 | + * @param integer $max |
|
214 | 215 | * @return array |
215 | 216 | */ |
216 | 217 | protected function splitDuration($seconds, $max) |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if ( |
113 | 113 | (is_int($datetype) && $datetype !== \IntlDateFormatter::NONE) || |
114 | 114 | (is_int($timetype) && $timetype !== \IntlDateFormatter::NONE) |
115 | - ){ |
|
115 | + ) { |
|
116 | 116 | $pattern = \IntlDateFormatter::create( |
117 | 117 | \Locale::getDefault(), |
118 | 118 | is_int($datetype) ? $datetype : \IntlDateFormatter::NONE, |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | if (is_string($datetype)) { |
128 | - $pattern = trim($datetype . ' ' . $pattern); |
|
128 | + $pattern = trim($datetype.' '.$pattern); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | if (is_string($timetype)) { |
132 | - $pattern = trim($pattern . ' ' . $timetype); |
|
132 | + $pattern = trim($pattern.' '.$timetype); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | return preg_replace('/\byy?\b/', 'yyyy', $pattern); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param string $calendar 'gregorian' or 'traditional' |
181 | 181 | * @return string |
182 | 182 | */ |
183 | - public function localTime($date, $format='short', $calendar='gregorian') |
|
183 | + public function localTime($date, $format = 'short', $calendar = 'gregorian') |
|
184 | 184 | { |
185 | 185 | return $this->formatLocal($date, false, $format, $calendar); |
186 | 186 | } |
@@ -270,27 +270,27 @@ discard block |
||
270 | 270 | |
271 | 271 | $duration = ''; |
272 | 272 | if (isset($years) && isset($units[5])) { |
273 | - $duration .= $seperator . $years . $units[5]; |
|
273 | + $duration .= $seperator.$years.$units[5]; |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | if (isset($weeks) && isset($units[4])) { |
277 | - $duration .= $seperator . $weeks . $units[4]; |
|
277 | + $duration .= $seperator.$weeks.$units[4]; |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | if (isset($days) && isset($units[3])) { |
281 | - $duration .= $seperator . $days . $units[3]; |
|
281 | + $duration .= $seperator.$days.$units[3]; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | if (isset($hours) && isset($units[2])) { |
285 | - $duration .= $seperator . $hours . $units[2]; |
|
285 | + $duration .= $seperator.$hours.$units[2]; |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | if (isset($minutes) && isset($units[1])) { |
289 | - $duration .= $seperator . $minutes . $units[1]; |
|
289 | + $duration .= $seperator.$minutes.$units[1]; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | if (isset($seconds) && isset($units[0])) { |
293 | - $duration .= $seperator . $seconds . $units[0]; |
|
293 | + $duration .= $seperator.$seconds.$units[0]; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | return trim($duration, $seperator); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function product($array) |
54 | 54 | { |
55 | - return isset($array) ? array_product((array)$array) : null; |
|
55 | + return isset($array) ? array_product((array)$array) : null; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function values($array) |
65 | 65 | { |
66 | - return isset($array) ? array_values((array)$array) : null; |
|
66 | + return isset($array) ? array_values((array)$array) : null; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -99,7 +99,7 @@ |
||
99 | 99 | $value = $key; |
100 | 100 | } |
101 | 101 | |
102 | - $str .= ' ' . $key . '="' . addcslashes($value, '"') . '"'; |
|
102 | + $str .= ' '.$key.'="'.addcslashes($value, '"').'"'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return trim($str); |
@@ -160,6 +160,6 @@ |
||
160 | 160 | */ |
161 | 161 | public function testWithNull($filter) |
162 | 162 | { |
163 | - $this->assertRender('-', '{{ null|' . $filter . '("//")|default("-") }}'); |
|
163 | + $this->assertRender('-', '{{ null|'.$filter.'("//")|default("-") }}'); |
|
164 | 164 | } |
165 | 165 | } |
@@ -160,6 +160,6 @@ |
||
160 | 160 | */ |
161 | 161 | public function testWithNull($filter) |
162 | 162 | { |
163 | - $this->assertRender('-', '{{ null|' . $filter . '("//")|default("-") }}'); |
|
163 | + $this->assertRender('-', '{{ null|'.$filter.'("//")|default("-") }}'); |
|
164 | 164 | } |
165 | 165 | } |
@@ -160,6 +160,6 @@ |
||
160 | 160 | */ |
161 | 161 | public function testWithNull($filter) |
162 | 162 | { |
163 | - $this->assertRender('-', '{{ null|' . $filter . '("//")|default("-") }}'); |
|
163 | + $this->assertRender('-', '{{ null|'.$filter.'("//")|default("-") }}'); |
|
164 | 164 | } |
165 | 165 | } |