@@ -223,17 +223,17 @@ |
||
223 | 223 | |
224 | 224 | $properties = []; |
225 | 225 | |
226 | - foreach( $class->getProperties() as $property ) { |
|
227 | - $properties[$property->getName()] = $property; |
|
228 | - } |
|
226 | + foreach( $class->getProperties() as $property ) { |
|
227 | + $properties[$property->getName()] = $property; |
|
228 | + } |
|
229 | 229 | |
230 | - if( $parent = $class->getParentClass() ) { |
|
231 | - $parent_props = static::getClassProperties($parent); |
|
232 | - if(count($parent_props) > 0) |
|
233 | - $properties = array_merge($parent_props, $properties); |
|
234 | - } |
|
230 | + if( $parent = $class->getParentClass() ) { |
|
231 | + $parent_props = static::getClassProperties($parent); |
|
232 | + if(count($parent_props) > 0) |
|
233 | + $properties = array_merge($parent_props, $properties); |
|
234 | + } |
|
235 | 235 | |
236 | - return $properties; |
|
236 | + return $properties; |
|
237 | 237 | |
238 | 238 | } |
239 | 239 |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | foreach( $arr as $k => $v ) { |
50 | 50 | $item .= sprintf("%s[%s] => %s\n", str_repeat("\t", static::$depth), $k, static::dump($v, false)); |
51 | 51 | } |
52 | - $item .= str_repeat("\t", static::$depth - 1). "}"; |
|
52 | + $item .= str_repeat("\t", static::$depth - 1)."}"; |
|
53 | 53 | |
54 | 54 | static::$depth--; |
55 | 55 | |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | |
75 | 75 | static::$depth++; |
76 | 76 | |
77 | - $item = get_class($obj). " {\n"; |
|
77 | + $item = get_class($obj)." {\n"; |
|
78 | 78 | |
79 | 79 | $item .= static::dumpObjectProperties($obj); |
80 | 80 | |
81 | - $item .= str_repeat("\t", static::$depth - 1). "}"; |
|
81 | + $item .= str_repeat("\t", static::$depth - 1)."}"; |
|
82 | 82 | |
83 | 83 | static::$depth--; |
84 | 84 | |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | |
166 | 166 | $item = " {\n"; |
167 | 167 | foreach( $meta as $k => $v ) { |
168 | - $item .= sprintf("%s%s: %s\n", str_repeat("\t", static::$depth), str_pad(ucwords(str_replace('_', ' ', $k)), $width) , static::dump($v, false)); |
|
168 | + $item .= sprintf("%s%s: %s\n", str_repeat("\t", static::$depth), str_pad(ucwords(str_replace('_', ' ', $k)), $width), static::dump($v, false)); |
|
169 | 169 | } |
170 | - $item .= str_repeat("\t", static::$depth - 1). "}"; |
|
170 | + $item .= str_repeat("\t", static::$depth - 1)."}"; |
|
171 | 171 | |
172 | 172 | static::$depth--; |
173 | 173 | |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | $line = ''; |
185 | 185 | |
186 | 186 | if( isset($frame['class']) ) |
187 | - $line .= $frame['class']. $frame['type']; |
|
187 | + $line .= $frame['class'].$frame['type']; |
|
188 | 188 | |
189 | - $line .= $frame['function']. '()'; |
|
189 | + $line .= $frame['function'].'()'; |
|
190 | 190 | |
191 | 191 | if( isset($frame['file']) ) { |
192 | - $line .= ' ['. $frame['file']; |
|
192 | + $line .= ' ['.$frame['file']; |
|
193 | 193 | if( isset($frame['line']) ) |
194 | - $line .= ':'. $frame['line']; |
|
194 | + $line .= ':'.$frame['line']; |
|
195 | 195 | $line .= ']'; |
196 | 196 | } |
197 | 197 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | |
230 | 230 | if( $parent = $class->getParentClass() ) { |
231 | 231 | $parent_props = static::getClassProperties($parent); |
232 | - if(count($parent_props) > 0) |
|
232 | + if( count($parent_props) > 0 ) |
|
233 | 233 | $properties = array_merge($parent_props, $properties); |
234 | 234 | } |
235 | 235 |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | */ |
41 | 41 | protected function parseArgs( $argv = null ) { |
42 | 42 | $argv = $argv ? $argv : $_SERVER['argv']; array_shift($argv); $o = []; |
43 | - for ($i = 0, $j = count($argv); $i < $j; $i++) { $a = $argv[$i]; |
|
44 | - if (substr($a, 0, 2) == '--') { $eq = strpos($a, '='); |
|
45 | - if ($eq !== false) { $o[substr($a, 2, $eq - 2)] = substr($a, $eq + 1); } |
|
43 | + for( $i = 0, $j = count($argv); $i < $j; $i++ ) { $a = $argv[$i]; |
|
44 | + if( substr($a, 0, 2) == '--' ) { $eq = strpos($a, '='); |
|
45 | + if( $eq !== false ) { $o[substr($a, 2, $eq - 2)] = substr($a, $eq + 1); } |
|
46 | 46 | else { $k = substr($a, 2); |
47 | - if ($i + 1 < $j && $argv[$i + 1][0] !== '-') { $o[$k] = $argv[$i + 1]; $i++; } |
|
48 | - else if (!isset($o[$k])) { $o[$k] = true; } } } |
|
49 | - else if (substr($a, 0, 1) == '-') { |
|
50 | - if (substr($a, 2, 1) == '=') { $o[substr($a, 1, 1)] = substr($a, 3); } |
|
47 | + if( $i + 1 < $j && $argv[$i + 1][0] !== '-' ) { $o[$k] = $argv[$i + 1]; $i++; } |
|
48 | + else if( !isset($o[$k]) ) { $o[$k] = true; } } } |
|
49 | + else if( substr($a, 0, 1) == '-' ) { |
|
50 | + if( substr($a, 2, 1) == '=' ) { $o[substr($a, 1, 1)] = substr($a, 3); } |
|
51 | 51 | else { |
52 | - foreach (str_split(substr($a, 1)) as $k) { if (!isset($o[$k])) { $o[$k] = true; } } |
|
53 | - if ($i + 1 < $j && $argv[$i + 1][0] !== '-') { $o[$k] = $argv[$i + 1]; $i++; } } } |
|
52 | + foreach( str_split(substr($a, 1)) as $k ) { if( !isset($o[$k]) ) { $o[$k] = true; } } |
|
53 | + if( $i + 1 < $j && $argv[$i + 1][0] !== '-' ) { $o[$k] = $argv[$i + 1]; $i++; } } } |
|
54 | 54 | else { $o[] = $a; } } |
55 | 55 | return $o; |
56 | 56 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return string |
61 | 61 | */ |
62 | 62 | protected function getLockFile() { |
63 | - return rtrim(static::LOCK_DIR, '/'). '/'. strtolower(str_replace('\\', '-', get_class($this))); |
|
63 | + return rtrim(static::LOCK_DIR, '/').'/'.strtolower(str_replace('\\', '-', get_class($this))); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | protected function isLocked() { |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | // if it does then check the process is actually still running |
72 | 72 | if( $locked ) { |
73 | 73 | $pid = file_get_contents($lock); |
74 | - $locked = exec(static::PS_EXEC. $pid) != ''; |
|
74 | + $locked = exec(static::PS_EXEC.$pid) != ''; |
|
75 | 75 | // no such process so remove the lock file |
76 | 76 | if( !$locked ) |
77 | 77 | $this->unlock(); |
@@ -46,12 +46,12 @@ |
||
46 | 46 | else { $k = substr($a, 2); |
47 | 47 | if ($i + 1 < $j && $argv[$i + 1][0] !== '-') { $o[$k] = $argv[$i + 1]; $i++; } |
48 | 48 | else if (!isset($o[$k])) { $o[$k] = true; } } } |
49 | - else if (substr($a, 0, 1) == '-') { |
|
49 | + else if (substr($a, 0, 1) == '-') { |
|
50 | 50 | if (substr($a, 2, 1) == '=') { $o[substr($a, 1, 1)] = substr($a, 3); } |
51 | 51 | else { |
52 | 52 | foreach (str_split(substr($a, 1)) as $k) { if (!isset($o[$k])) { $o[$k] = true; } } |
53 | 53 | if ($i + 1 < $j && $argv[$i + 1][0] !== '-') { $o[$k] = $argv[$i + 1]; $i++; } } } |
54 | - else { $o[] = $a; } } |
|
54 | + else { $o[] = $a; } } |
|
55 | 55 | return $o; |
56 | 56 | } |
57 | 57 |
@@ -3,7 +3,7 @@ |
||
3 | 3 | use yolk\Yolk; |
4 | 4 | |
5 | 5 | defined('YOLK_START_TIME') || define('YOLK_START_TIME', microtime(true)); |
6 | -defined('YOLK_START_MEM') || define('YOLK_START_MEM', memory_get_usage()); |
|
6 | +defined('YOLK_START_MEM') || define('YOLK_START_MEM', memory_get_usage()); |
|
7 | 7 | |
8 | 8 | if( !function_exists('d') ) { |
9 | 9 | function d() { |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | ]; |
30 | 30 | |
31 | 31 | $err = [ |
32 | - 'name' => '\\'. get_class($error), |
|
32 | + 'name' => '\\'.get_class($error), |
|
33 | 33 | 'code' => $error->getCode(), |
34 | 34 | 'message' => $error->getMessage(), |
35 | 35 | 'file' => $error->getFile(), |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | <?php if( isset($item['line']) ) { ?> <strong>Line:</strong> <code><?=$item['line'] ?></code><?php } ?> |
165 | 165 | </p> |
166 | 166 | <?php } ?> |
167 | - <p><strong>Function: </strong><code><?=isset($item['class']) ? $item['class']. $item['type'] : ''?><?=$item['function']. '()'; ?></code></p> |
|
167 | + <p><strong>Function: </strong><code><?=isset($item['class']) ? $item['class'].$item['type'] : ''?><?=$item['function'].'()'; ?></code></p> |
|
168 | 168 | </li> |
169 | 169 | <?php } ?> |
170 | 170 | </ol> |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | } |
55 | 55 | // debug web app |
56 | 56 | elseif( Yolk::isDebug() ) { |
57 | - require __DIR__. '/error.debug.php'; |
|
57 | + require __DIR__.'/error.debug.php'; |
|
58 | 58 | } |
59 | 59 | // production web app |
60 | 60 | else { |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | |
73 | 73 | // fatal errors will already have been error_log()'d |
74 | 74 | if( !static::isFatal($error) ) { |
75 | - $location = $error->getFile(). ':'. $error->getLine(); |
|
75 | + $location = $error->getFile().':'.$error->getLine(); |
|
76 | 76 | // type hinting error - make sure we give the correct location |
77 | 77 | if( ($error instanceof \InvalidArgumentException) && ($error->getPrevious() instanceof \ErrorException) ) |
78 | - $location = $error->getPrevious()->getFile(). ':'. $error->getPrevious()->getLine(); |
|
79 | - error_log(get_class($error). ': '. $error->getMessage(). " [{$location}]"); |
|
78 | + $location = $error->getPrevious()->getFile().':'.$error->getPrevious()->getLine(); |
|
79 | + error_log(get_class($error).': '.$error->getMessage()." [{$location}]"); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | |
32 | 32 | // if the error was a type hint failure then throw an InvalidArgumentException instead |
33 | 33 | elseif( preg_match('/^Argument (\d+) passed to ([\w\\\\]+)::(\w+)\(\) must be an instance of ([\w\\\\]+), ([\w\\\\]+) given, called in ([\w\s\.\/_-]+) on line (\d+)/', $message, $m) ) |
34 | - throw new \InvalidArgumentException("Argument {$m[1]} to {$m[2]}::{$m[3]}() should be an instance of {$m[4]}, {$m[5]} given", $severity, new \ErrorException($message, 0, $severity, $m[6], $m[7])); |
|
34 | + throw new \InvalidArgumentException("argument {$m[1]} to {$m[2]}::{$m[3]}() should be an instance of {$m[4]}, {$m[5]} given", $severity, new \ErrorException($message, 0, $severity, $m[6], $m[7])); |
|
35 | 35 | |
36 | 36 | // convert the error to an exception |
37 | 37 | throw new \ErrorException($message, 0, $severity, $file, $line); |
@@ -216,7 +216,7 @@ |
||
216 | 216 | return call_user_func( |
217 | 217 | static::$exception_handler, |
218 | 218 | $error, |
219 | - static::$error_page ?: __DIR__. '/exceptions/error.php' |
|
219 | + static::$error_page ?: __DIR__.'/exceptions/error.php' |
|
220 | 220 | ); |
221 | 221 | } |
222 | 222 |
@@ -160,7 +160,7 @@ |
||
160 | 160 | * @param \Closure $callable |
161 | 161 | * @return void |
162 | 162 | */ |
163 | - public static function run( Callable $callable ) { |
|
163 | + public static function run( callable $callable ) { |
|
164 | 164 | |
165 | 165 | try { |
166 | 166 |
@@ -218,7 +218,7 @@ |
||
218 | 218 | if( $lhs < $rhs ) { |
219 | 219 | return -1 * $sort_order; |
220 | 220 | } |
221 | - else if ($lhs > $rhs) { |
|
221 | + else if( $lhs > $rhs ) { |
|
222 | 222 | return 1 * $sort_order; |
223 | 223 | } |
224 | 224 |
@@ -95,24 +95,24 @@ discard block |
||
95 | 95 | public static function pluralise( $string ) { |
96 | 96 | |
97 | 97 | // save some time in the case that singular and plural are the same |
98 | - if ( in_array( mb_strtolower( $string ), self::$uncountable ) ) |
|
98 | + if( in_array(mb_strtolower($string), self::$uncountable) ) |
|
99 | 99 | return $string; |
100 | 100 | |
101 | 101 | |
102 | 102 | // check for irregular singular forms |
103 | - foreach ( self::$irregular as $pattern => $result ) |
|
103 | + foreach( self::$irregular as $pattern => $result ) |
|
104 | 104 | { |
105 | - $pattern = '/' . $pattern . '$/iu'; |
|
105 | + $pattern = '/'.$pattern.'$/iu'; |
|
106 | 106 | |
107 | - if ( preg_match( $pattern, $string ) ) |
|
108 | - return preg_replace( $pattern, $result, $string); |
|
107 | + if( preg_match($pattern, $string) ) |
|
108 | + return preg_replace($pattern, $result, $string); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // check for matches using regular expressions |
112 | - foreach ( self::$plural as $pattern => $result ) |
|
112 | + foreach( self::$plural as $pattern => $result ) |
|
113 | 113 | { |
114 | - if ( preg_match( $pattern, $string ) ) |
|
115 | - return preg_replace( $pattern, $result, $string ); |
|
114 | + if( preg_match($pattern, $string) ) |
|
115 | + return preg_replace($pattern, $result, $string); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | return $string; |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | public static function singularise( $string ) { |
124 | 124 | |
125 | 125 | // save some time in the case that singular and plural are the same |
126 | - if ( in_array(mb_strtolower($string), self::$uncountable) ) |
|
126 | + if( in_array(mb_strtolower($string), self::$uncountable) ) |
|
127 | 127 | return $string; |
128 | 128 | |
129 | 129 | // check for irregular plural forms |
130 | 130 | foreach( self::$irregular as $result => $pattern ) { |
131 | - $pattern = '/' . $pattern . '$/iu'; |
|
131 | + $pattern = '/'.$pattern.'$/iu'; |
|
132 | 132 | if( preg_match($pattern, $string) ) |
133 | 133 | return preg_replace($pattern, $result, $string); |
134 | 134 | } |
@@ -100,8 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | |
102 | 102 | // check for irregular singular forms |
103 | - foreach ( self::$irregular as $pattern => $result ) |
|
104 | - { |
|
103 | + foreach ( self::$irregular as $pattern => $result ) { |
|
105 | 104 | $pattern = '/' . $pattern . '$/iu'; |
106 | 105 | |
107 | 106 | if ( preg_match( $pattern, $string ) ) |
@@ -109,8 +108,7 @@ discard block |
||
109 | 108 | } |
110 | 109 | |
111 | 110 | // check for matches using regular expressions |
112 | - foreach ( self::$plural as $pattern => $result ) |
|
113 | - { |
|
111 | + foreach ( self::$plural as $pattern => $result ) { |
|
114 | 112 | if ( preg_match( $pattern, $string ) ) |
115 | 113 | return preg_replace( $pattern, $result, $string ); |
116 | 114 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | $parts = is_string($url) ? \parse_url(urldecode($url)) : $url; |
33 | 33 | |
34 | - $select = function( $k ) use ( $parts, $defaults ) { |
|
34 | + $select = function( $k ) use ($parts, $defaults) { |
|
35 | 35 | if( isset($parts[$k]) ) |
36 | 36 | return $parts[$k]; |
37 | 37 | elseif( isset($defaults[$k]) ) |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public static function randomString( $length, $allowed = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ) { |
79 | 79 | $out = ''; |
80 | 80 | $max = strlen($allowed) - 1; |
81 | - for ($i = 0; $i < $length; $i++) { |
|
81 | + for( $i = 0; $i < $length; $i++ ) { |
|
82 | 82 | $out .= $allowed[mt_rand(0, $max)]; |
83 | 83 | } |
84 | 84 | return $out; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public static function uncamelise( $str ) { |
91 | 91 | return mb_strtolower( |
92 | 92 | preg_replace( |
93 | - '/^A-Z^a-z^0-9]+/', '_', |
|
93 | + '/^A-Z^a-z^0-9]+/', '_', |
|
94 | 94 | preg_replace('/([a-z\d])([A-Z])/u', '$1_$2', |
95 | 95 | preg_replace('/([A-Z+])([A-Z][a-z])/u', '$1_$2', $str) |
96 | 96 | ) |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @return string the number cast as a string with the ordinal suffixed. |
203 | 203 | */ |
204 | 204 | public static function ordinal( $n ) { |
205 | - $ends = array('th','st','nd','rd','th','th','th','th','th','th'); |
|
205 | + $ends = array('th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th'); |
|
206 | 206 | // if tens digit is 1, 2 or 3 then use th instead of usual ordinal |
207 | 207 | if( ($n % 100) >= 11 && ($n % 100) <= 13 ) |
208 | 208 | return "{$n}th"; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); |
225 | 225 | $pow = min($pow, count($units) - 1); |
226 | 226 | $bytes /= (1 << (10 * $pow)); |
227 | - return round($bytes, $precision). ' '. $units[$pow]; |
|
227 | + return round($bytes, $precision).' '.$units[$pow]; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $str = static::stripControlChars($str); |
253 | 253 | |
254 | 254 | // fix and decode entities (handles missing ; terminator) |
255 | - $str = str_replace(array('&','<','>'), array('&amp;','&lt;','&gt;'), $str); |
|
255 | + $str = str_replace(array('&', '<', '>'), array('&amp;', '&lt;', '&gt;'), $str); |
|
256 | 256 | $str = preg_replace('/(&#*\w+)\s+;/u', '$1;', $str); |
257 | 257 | $str = preg_replace('/(&#x*[0-9A-F]+);*/iu', '$1;', $str); |
258 | 258 | $str = html_entity_decode($str, ENT_COMPAT, $charset); |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $old = $str; |
288 | 288 | $str = preg_replace('#</*(?:applet|b(?:ase|gsound|link)|body|embed|frame(?:set)?|head|html|i(?:frame|layer)|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*+>#iu', '', $str); |
289 | 289 | } |
290 | - while ($old !== $str); |
|
290 | + while( $old !== $str ); |
|
291 | 291 | |
292 | 292 | return $str; |
293 | 293 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | // 00-08, 11, 12, 14-31, 127 |
311 | 311 | $str = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/Su', '', $str, -1, $count); |
312 | 312 | } |
313 | - while ($count); |
|
313 | + while( $count ); |
|
314 | 314 | |
315 | 315 | return $str; |
316 | 316 |