@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | function array_get_value($key, array $array, $default = null) |
| 32 | 32 | { |
| 33 | - return array_key_exists($key, $array) ? $array[ $key ] : $default; |
|
| 33 | + return array_key_exists($key, $array) ? $array[$key] : $default; |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | foreach ($keys as $item) { |
| 59 | 59 | if (array_key_exists($item, $array)) { |
| 60 | - $return[ $item ] = $array[ $item ]; |
|
| 60 | + $return[$item] = $array[$item]; |
|
| 61 | 61 | } elseif (is_array($default) && array_key_exists($item, $default)) { |
| 62 | - $return[ $item ] = $default[ $item ]; |
|
| 62 | + $return[$item] = $default[$item]; |
|
| 63 | 63 | } elseif ( ! empty($default)) { |
| 64 | - $return[ $item ] = $default; |
|
| 64 | + $return[$item] = $default; |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | $combine_array = []; |
| 89 | 89 | |
| 90 | 90 | foreach ($keys as $index => $key) { |
| 91 | - $combine_array[ $key ][] = $values[ $index ]; |
|
| 91 | + $combine_array[$key][] = $values[$index]; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | array_walk( |
| 95 | 95 | $combine_array, |
| 96 | - function (&$value) { |
|
| 96 | + function(&$value) { |
|
| 97 | 97 | $value = (count($value) == 1) ? array_pop($value) : $value; |
| 98 | 98 | } |
| 99 | 99 | ); |
@@ -122,18 +122,18 @@ discard block |
||
| 122 | 122 | if ($flip) { |
| 123 | 123 | array_walk_recursive( |
| 124 | 124 | $array, |
| 125 | - function ($value, $key) use (&$group_array) { |
|
| 126 | - if ( ! isset($group_array[ $value ]) || ! is_array($group_array[ $value ])) { |
|
| 127 | - $group_array[ $value ] = []; |
|
| 125 | + function($value, $key) use (&$group_array) { |
|
| 126 | + if ( ! isset($group_array[$value]) || ! is_array($group_array[$value])) { |
|
| 127 | + $group_array[$value] = []; |
|
| 128 | 128 | } |
| 129 | - $group_array[ $value ][] = $key; |
|
| 129 | + $group_array[$value][] = $key; |
|
| 130 | 130 | } |
| 131 | 131 | ); |
| 132 | 132 | } else { |
| 133 | 133 | array_walk_recursive( |
| 134 | 134 | $array, |
| 135 | - function ($value, $key) use (&$group_array) { |
|
| 136 | - $group_array[ $key ][] = $value; |
|
| 135 | + function($value, $key) use (&$group_array) { |
|
| 136 | + $group_array[$key][] = $value; |
|
| 137 | 137 | } |
| 138 | 138 | ); |
| 139 | 139 | } |
@@ -173,14 +173,14 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | if ( ! is_array($value)) { |
| 175 | 175 | if ($key != $value) { |
| 176 | - $result[ $key ] = $value; |
|
| 176 | + $result[$key] = $value; |
|
| 177 | 177 | $count++; |
| 178 | 178 | } |
| 179 | 179 | } else { |
| 180 | 180 | $sub = array_filter_recursive($value, $value, $limit); |
| 181 | 181 | if (count($sub) > 0) { |
| 182 | 182 | if ($key != $value) { |
| 183 | - $result[ $key ] = $sub; |
|
| 183 | + $result[$key] = $sub; |
|
| 184 | 184 | $count += count($sub); |
| 185 | 185 | } |
| 186 | 186 | } |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | if (is_array($value)) { |
| 276 | 276 | $flat_array = array_merge($flat_array, array_flatten($value)); |
| 277 | 277 | } else { |
| 278 | - $flat_array[ $key ] = $value; |
|
| 278 | + $flat_array[$key] = $value; |
|
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | 281 | |
@@ -314,10 +314,10 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | $prices = []; |
| 316 | 316 | for ($i = 0; $i < count($ranges); $i++) { |
| 317 | - if ($ranges[ $i ] == $max) { |
|
| 317 | + if ($ranges[$i] == $max) { |
|
| 318 | 318 | break; |
| 319 | 319 | } else { |
| 320 | - $prices[ $ranges[ $i ] ] = ($ranges[ $i + 1 ] == 0) ? $ranges[ $i ] * 2 : $ranges[ $i + 1 ]; |
|
| 320 | + $prices[$ranges[$i]] = ($ranges[$i + 1] == 0) ? $ranges[$i] * 2 : $ranges[$i + 1]; |
|
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | |
| 346 | 346 | $date_range = []; |
| 347 | 347 | for ($i = 0; $i < $days; $i++) { |
| 348 | - $date_range[ $i ] = $start_date + ($i * 24 * 60 * 60); |
|
| 348 | + $date_range[$i] = $start_date + ($i * 24 * 60 * 60); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | return $date_range; |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | $years = []; |
| 373 | 373 | |
| 374 | 374 | foreach (range($min, $max, $step) as $year) { |
| 375 | - $years[ $year ] = $year; |
|
| 375 | + $years[$year] = $year; |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | return $years; |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | foreach ($string as $key => $val) { |
| 484 | - $string[ $key ] = str_strip_slashes($val); |
|
| 484 | + $string[$key] = str_strip_slashes($val); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | return $string; |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | { |
| 621 | 621 | preg_match('/(.+)' . $separator . '([0-9]+)$/', $string, $match); |
| 622 | 622 | |
| 623 | - return isset($match[ 2 ]) ? $match[ 1 ] . $separator . ($match[ 2 ] + 1) : $string . $separator . $first; |
|
| 623 | + return isset($match[2]) ? $match[1] . $separator . ($match[2] + 1) : $string . $separator . $first; |
|
| 624 | 624 | } |
| 625 | 625 | } |
| 626 | 626 | |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | |
| 649 | 649 | $args = func_get_args(); |
| 650 | 650 | |
| 651 | - return $args[ ($i++ % count($args)) ]; |
|
| 651 | + return $args[($i++ % count($args))]; |
|
| 652 | 652 | } |
| 653 | 653 | } |
| 654 | 654 | |
@@ -784,8 +784,8 @@ discard block |
||
| 784 | 784 | function str_entities_to_ascii($string, $all = true) |
| 785 | 785 | { |
| 786 | 786 | if (preg_match_all('/\&#(\d+)\;/', $string, $matches)) { |
| 787 | - for ($i = 0, $s = count($matches[ 0 ]); $i < $s; $i++) { |
|
| 788 | - $digits = $matches[ 1 ][ $i ]; |
|
| 787 | + for ($i = 0, $s = count($matches[0]); $i < $s; $i++) { |
|
| 788 | + $digits = $matches[1][$i]; |
|
| 789 | 789 | $out = ''; |
| 790 | 790 | |
| 791 | 791 | if ($digits < 128) { |
@@ -799,7 +799,7 @@ discard block |
||
| 799 | 799 | . chr(128 + ($digits % 64)); |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | - $string = str_replace($matches[ 0 ][ $i ], $out, $string); |
|
| 802 | + $string = str_replace($matches[0][$i], $out, $string); |
|
| 803 | 803 | } |
| 804 | 804 | } |
| 805 | 805 | |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | { |
| 833 | 833 | $out = ''; |
| 834 | 834 | for ($i = 0, $s = strlen($string) - 1, $count = 1, $temp = []; $i <= $s; $i++) { |
| 835 | - $ordinal = ord($string[ $i ]); |
|
| 835 | + $ordinal = ord($string[$i]); |
|
| 836 | 836 | |
| 837 | 837 | if ($ordinal < 128) { |
| 838 | 838 | /* |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | $count = 1; |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | - $out .= $string[ $i ]; |
|
| 847 | + $out .= $string[$i]; |
|
| 848 | 848 | } else { |
| 849 | 849 | if (count($temp) === 0) { |
| 850 | 850 | $count = ($ordinal < 224) ? 2 : 3; |
@@ -854,8 +854,8 @@ discard block |
||
| 854 | 854 | |
| 855 | 855 | if (count($temp) === $count) { |
| 856 | 856 | $number = ($count === 3) |
| 857 | - ? (($temp[ 0 ] % 16) * 4096) + (($temp[ 1 ] % 64) * 64) + ($temp[ 2 ] % 64) |
|
| 858 | - : (($temp[ 0 ] % 32) * 64) + ($temp[ 1 ] % 64); |
|
| 857 | + ? (($temp[0] % 16) * 4096) + (($temp[1] % 64) * 64) + ($temp[2] % 64) |
|
| 858 | + : (($temp[0] % 32) * 64) + ($temp[1] % 64); |
|
| 859 | 859 | |
| 860 | 860 | $out .= '&#' . $number . ';'; |
| 861 | 861 | $count = 1; |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | if ($diff->$key) { |
| 296 | 296 | $value = $diff->$key . ' ' . $value . ($diff->$key > 1 && language()->getDefaultLocale() === 'en' ? 's' : ''); |
| 297 | 297 | } else { |
| 298 | - unset($string[ $key ]); |
|
| 298 | + unset($string[$key]); |
|
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | |
@@ -328,8 +328,8 @@ discard block |
||
| 328 | 328 | function dates_between($start_date, $end_date, $format = 'Y-m-d') |
| 329 | 329 | { |
| 330 | 330 | $day = 60 * 60 * 24; |
| 331 | - $start_date = (! is_numeric($start_date) ? strtotime($start_date) : $start_date); |
|
| 332 | - $end_date = (! is_numeric($end_date) ? strtotime($end_date) : $end_date); |
|
| 331 | + $start_date = ( ! is_numeric($start_date) ? strtotime($start_date) : $start_date); |
|
| 332 | + $end_date = ( ! is_numeric($end_date) ? strtotime($end_date) : $end_date); |
|
| 333 | 333 | |
| 334 | 334 | $days_diff = round( |
| 335 | 335 | ($end_date - $start_date) / $day |
@@ -385,9 +385,9 @@ discard block |
||
| 385 | 385 | $time_12 = date("h:i a", strtotime($hours)); |
| 386 | 386 | $time_24 = $hours; |
| 387 | 387 | if ($mode == 12) { |
| 388 | - $time[ $time_12 ] = $time_12; |
|
| 388 | + $time[$time_12] = $time_12; |
|
| 389 | 389 | } elseif ($mode == 24) { |
| 390 | - $time[ $time_24 ] = $time_24; |
|
| 390 | + $time[$time_24] = $time_24; |
|
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | } |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | */ |
| 475 | 475 | function is_weekend($date) |
| 476 | 476 | { |
| 477 | - $date = (! is_numeric($date) ? strtotime(str_replace('/', '-', $date)) : $date); |
|
| 477 | + $date = ( ! is_numeric($date) ? strtotime(str_replace('/', '-', $date)) : $date); |
|
| 478 | 478 | $date = date('D', $date); |
| 479 | 479 | |
| 480 | 480 | if ($date == 'Sat' OR $date == 'Sun') { |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | */ |
| 499 | 499 | function is_weekday($date) |
| 500 | 500 | { |
| 501 | - $date = (! is_numeric($date) ? strtotime(str_replace('/', '-', $date)) : $date); |
|
| 501 | + $date = ( ! is_numeric($date) ? strtotime(str_replace('/', '-', $date)) : $date); |
|
| 502 | 502 | $date = date('D', $date); |
| 503 | 503 | |
| 504 | 504 | if ( ! in_array($date, ['Sat', 'Sun'])) { |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | */ |
| 524 | 524 | function get_age($birthday, $return = 'years') |
| 525 | 525 | { |
| 526 | - $birthday = (! is_numeric($birthday) ? strtotime(str_replace('/', '-', $birthday)) : $birthday); |
|
| 526 | + $birthday = ( ! is_numeric($birthday) ? strtotime(str_replace('/', '-', $birthday)) : $birthday); |
|
| 527 | 527 | |
| 528 | 528 | $birthday = new DateTime(date('Y-m-d', $birthday)); |
| 529 | 529 | $now = new DateTime(date('Y-m-d')); |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | ]; |
| 539 | 539 | |
| 540 | 540 | if (array_key_exists($return, $available)) { |
| 541 | - return $interval->{$available[ $return ]}; |
|
| 541 | + return $interval->{$available[$return]}; |
|
| 542 | 542 | } elseif (isset($interval->{$return})) { |
| 543 | 543 | return $interval->{$return}; |
| 544 | 544 | } |
@@ -623,8 +623,8 @@ discard block |
||
| 623 | 623 | } |
| 624 | 624 | foreach ($periods as $period => $seconds_in_period) { |
| 625 | 625 | if ($seconds >= $seconds_in_period) { |
| 626 | - $durations[ $period ] = floor($seconds / $seconds_in_period); |
|
| 627 | - $seconds -= $durations[ $period ] * $seconds_in_period; |
|
| 626 | + $durations[$period] = floor($seconds / $seconds_in_period); |
|
| 627 | + $seconds -= $durations[$period] * $seconds_in_period; |
|
| 628 | 628 | } |
| 629 | 629 | } |
| 630 | 630 | } |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | */ |
| 676 | 676 | function add_time_duration($start_time, $duration, $return = 'time') |
| 677 | 677 | { |
| 678 | - $start_time = (! is_numeric($start_time) ? strtotime($start_time) : $start_time); |
|
| 678 | + $start_time = ( ! is_numeric($start_time) ? strtotime($start_time) : $start_time); |
|
| 679 | 679 | $duration = $duration * 60 * 60; // (x) hours * 60 minutes * 60 seconds |
| 680 | 680 | |
| 681 | 681 | $add_time = $start_time + $duration; |
@@ -701,8 +701,8 @@ discard block |
||
| 701 | 701 | */ |
| 702 | 702 | function calculate_hours($start_time, $end_time, $return = 'time') |
| 703 | 703 | { |
| 704 | - $start_time = (! is_numeric($start_time) ? strtotime($start_time) : $start_time); |
|
| 705 | - $end_time = (! is_numeric($end_time) ? strtotime($end_time) : $end_time); |
|
| 704 | + $start_time = ( ! is_numeric($start_time) ? strtotime($start_time) : $start_time); |
|
| 705 | + $end_time = ( ! is_numeric($end_time) ? strtotime($end_time) : $end_time); |
|
| 706 | 706 | |
| 707 | 707 | // Times Difference |
| 708 | 708 | $difference = $end_time - $start_time; |
@@ -743,8 +743,8 @@ discard block |
||
| 743 | 743 | */ |
| 744 | 744 | function time_difference($start_time, $end_time, $return = 'array') |
| 745 | 745 | { |
| 746 | - $start_time = (! is_numeric($start_time) ? strtotime($start_time) : $start_time); |
|
| 747 | - $end_time = (! is_numeric($end_time) ? strtotime($end_time) : $end_time); |
|
| 746 | + $start_time = ( ! is_numeric($start_time) ? strtotime($start_time) : $start_time); |
|
| 747 | + $end_time = ( ! is_numeric($end_time) ? strtotime($end_time) : $end_time); |
|
| 748 | 748 | |
| 749 | 749 | // Times Difference |
| 750 | 750 | $difference = $end_time - $start_time; |
@@ -869,12 +869,12 @@ discard block |
||
| 869 | 869 | $seconds -= $minutes * 60; |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | - $format[ 'days' ] = $days; |
|
| 873 | - $format[ 'years' ] = $years; |
|
| 874 | - $format[ 'months' ] = $months; |
|
| 875 | - $format[ 'hours' ] = $hours; |
|
| 876 | - $format[ 'minutes' ] = $minutes; |
|
| 877 | - $format[ 'seconds' ] = $seconds; |
|
| 872 | + $format['days'] = $days; |
|
| 873 | + $format['years'] = $years; |
|
| 874 | + $format['months'] = $months; |
|
| 875 | + $format['hours'] = $hours; |
|
| 876 | + $format['minutes'] = $minutes; |
|
| 877 | + $format['seconds'] = $seconds; |
|
| 878 | 878 | |
| 879 | 879 | return new \O2System\Spl\Datastructures\SplArrayObject($format); |
| 880 | 880 | } |
@@ -1164,7 +1164,7 @@ discard block |
||
| 1164 | 1164 | |
| 1165 | 1165 | $days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; |
| 1166 | 1166 | |
| 1167 | - return $days_in_month[ $month - 1 ]; |
|
| 1167 | + return $days_in_month[$month - 1]; |
|
| 1168 | 1168 | } |
| 1169 | 1169 | } |
| 1170 | 1170 | |
@@ -1324,9 +1324,9 @@ discard block |
||
| 1324 | 1324 | if (isset($ampm)) { |
| 1325 | 1325 | $ampm = strtolower($ampm); |
| 1326 | 1326 | |
| 1327 | - if ($ampm[ 0 ] === 'p' && $hour < 12) { |
|
| 1327 | + if ($ampm[0] === 'p' && $hour < 12) { |
|
| 1328 | 1328 | $hour += 12; |
| 1329 | - } elseif ($ampm[ 0 ] === 'a' && $hour === 12) { |
|
| 1329 | + } elseif ($ampm[0] === 'a' && $hour === 12) { |
|
| 1330 | 1330 | $hour = 0; |
| 1331 | 1331 | } |
| 1332 | 1332 | } |
@@ -1370,12 +1370,12 @@ discard block |
||
| 1370 | 1370 | |
| 1371 | 1371 | // Date Like: YYYYMMDD |
| 1372 | 1372 | if (preg_match('/^(\d{2})\d{2}(\d{4})$/i', $bad_date, $matches)) { |
| 1373 | - return date($format, strtotime($matches[ 1 ] . '/01/' . $matches[ 2 ])); |
|
| 1373 | + return date($format, strtotime($matches[1] . '/01/' . $matches[2])); |
|
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | 1376 | // Date Like: MM-DD-YYYY __or__ M-D-YYYY (or anything in between) |
| 1377 | 1377 | if (preg_match('/^(\d{1,2})-(\d{1,2})-(\d{4})$/i', $bad_date, $matches)) { |
| 1378 | - return date($format, strtotime($matches[ 3 ] . '-' . $matches[ 1 ] . '-' . $matches[ 2 ])); |
|
| 1378 | + return date($format, strtotime($matches[3] . '-' . $matches[1] . '-' . $matches[2])); |
|
| 1379 | 1379 | } |
| 1380 | 1380 | |
| 1381 | 1381 | // Any other kind of string, when converted into UNIX time, |
@@ -1455,7 +1455,7 @@ discard block |
||
| 1455 | 1455 | return $zones; |
| 1456 | 1456 | } |
| 1457 | 1457 | |
| 1458 | - return isset($zones[ $tz ]) ? $zones[ $tz ] : 0; |
|
| 1458 | + return isset($zones[$tz]) ? $zones[$tz] : 0; |
|
| 1459 | 1459 | } |
| 1460 | 1460 | } |
| 1461 | 1461 | |
@@ -1539,7 +1539,7 @@ discard block |
||
| 1539 | 1539 | * the end date might actually be less than 24 hours away from the previously |
| 1540 | 1540 | * generated DateTime object, but either way - we have to append it manually. |
| 1541 | 1541 | */ |
| 1542 | - if ( ! is_int($arg) && $range[ count($range) - 1 ] !== $arg->format($format)) { |
|
| 1542 | + if ( ! is_int($arg) && $range[count($range) - 1] !== $arg->format($format)) { |
|
| 1543 | 1543 | $range[] = $arg->format($format); |
| 1544 | 1544 | } |
| 1545 | 1545 | |
@@ -1557,10 +1557,12 @@ |
||
| 1557 | 1557 | } |
| 1558 | 1558 | $range[] = $from->format($format); |
| 1559 | 1559 | |
| 1560 | - if (is_int($arg)) // Day intervals |
|
| 1560 | + if (is_int($arg)) { |
|
| 1561 | + // Day intervals |
|
| 1561 | 1562 | { |
| 1562 | 1563 | do { |
| 1563 | 1564 | $from->modify('+1 day'); |
| 1565 | + } |
|
| 1564 | 1566 | $range[] = $from->format($format); |
| 1565 | 1567 | } while (--$arg > 0); |
| 1566 | 1568 | } else // end date UNIX timestamp |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | $return = explode("\n", wordwrap(strrev($text), $col_length)); |
| 52 | 52 | |
| 53 | 53 | if (count($return) > $cols) { |
| 54 | - $return[ $cols - 1 ] .= " " . $return[ $cols ]; |
|
| 55 | - unset($return[ $cols ]); |
|
| 54 | + $return[$cols - 1] .= " " . $return[$cols]; |
|
| 55 | + unset($return[$cols]); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $return = array_map("strrev", $return); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $return = wordwrap($return, $chars, "\n"); |
| 87 | 87 | preg_match("/(.+\n?){0,$lines}/", $return, $regs); |
| 88 | 88 | |
| 89 | - return $regs[ 0 ]; |
|
| 89 | + return $regs[0]; |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | // ------------------------------------------------------------------------ |
@@ -141,11 +141,11 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | preg_match('/^\s*+(?:\S++\s*+){1,' . (int)$limit . '}/', $str, $matches); |
| 143 | 143 | |
| 144 | - if (strlen($str) === strlen($matches[ 0 ])) { |
|
| 144 | + if (strlen($str) === strlen($matches[0])) { |
|
| 145 | 145 | $end_char = ''; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - return rtrim($matches[ 0 ]) . $end_char; |
|
| 148 | + return rtrim($matches[0]) . $end_char; |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
@@ -299,9 +299,9 @@ discard block |
||
| 299 | 299 | // strip the entire chunk and replace it with a marker. |
| 300 | 300 | $unwrap = []; |
| 301 | 301 | if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $string, $matches)) { |
| 302 | - for ($i = 0, $c = count($matches[ 0 ]); $i < $c; $i++) { |
|
| 303 | - $unwrap[] = $matches[ 1 ][ $i ]; |
|
| 304 | - $string = str_replace($matches[ 0 ][ $i ], '{{unwrapped' . $i . '}}', $string); |
|
| 302 | + for ($i = 0, $c = count($matches[0]); $i < $c; $i++) { |
|
| 303 | + $unwrap[] = $matches[1][$i]; |
|
| 304 | + $string = str_replace($matches[0][$i], '{{unwrapped' . $i . '}}', $string); |
|
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | |
@@ -18,9 +18,9 @@ discard block |
||
| 18 | 18 | ->withQuery(''); |
| 19 | 19 | |
| 20 | 20 | if ($uriConfig = config()->offsetGet('uri')) { |
| 21 | - if ( ! empty($uriConfig[ 'base' ])) { |
|
| 21 | + if ( ! empty($uriConfig['base'])) { |
|
| 22 | 22 | $base = (is_https() ? 'https' : 'http') . '://' . str_replace(['http://', 'https://'], '', |
| 23 | - $uriConfig[ 'base' ]); |
|
| 23 | + $uriConfig['base']); |
|
| 24 | 24 | $uri = new \O2System\Kernel\Http\Message\Uri($base); |
| 25 | 25 | } |
| 26 | 26 | } |
@@ -45,14 +45,14 @@ discard block |
||
| 45 | 45 | ->withQuery(''); |
| 46 | 46 | |
| 47 | 47 | if ($uriConfig = config()->offsetGet('uri')) { |
| 48 | - if ( ! empty($uriConfig[ 'base' ])) { |
|
| 48 | + if ( ! empty($uriConfig['base'])) { |
|
| 49 | 49 | $base = (is_https() ? 'https' : 'http') . '://' . str_replace(['http://', 'https://'], '', |
| 50 | - $uriConfig[ 'base' ]); |
|
| 50 | + $uriConfig['base']); |
|
| 51 | 51 | $uri = new \O2System\Kernel\Http\Message\Uri($base); |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if(isset($subdomain)) { |
|
| 55 | + if (isset($subdomain)) { |
|
| 56 | 56 | $uri = $uri->withSubDomain($subdomain); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | $url = parse_url($uri); |
| 172 | 172 | |
| 173 | - if ( ! $url or ! isset($url[ 'scheme' ])) { |
|
| 173 | + if ( ! $url or ! isset($url['scheme'])) { |
|
| 174 | 174 | return (is_https() ? 'https://' : 'http://') . $uri; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | function redirect_url($uri = '', $method = 'auto', $code = null) |
| 199 | 199 | { |
| 200 | - if(is_array($uri)) { |
|
| 200 | + if (is_array($uri)) { |
|
| 201 | 201 | $uri = implode('/', $uri); |
| 202 | 202 | } |
| 203 | 203 | |
@@ -206,15 +206,15 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // IIS environment likely? Use 'refresh' for better compatibility |
| 209 | - if ($method === 'auto' && isset($_SERVER[ 'SERVER_SOFTWARE' ]) && strpos( |
|
| 210 | - $_SERVER[ 'SERVER_SOFTWARE' ], |
|
| 209 | + if ($method === 'auto' && isset($_SERVER['SERVER_SOFTWARE']) && strpos( |
|
| 210 | + $_SERVER['SERVER_SOFTWARE'], |
|
| 211 | 211 | 'Microsoft-IIS' |
| 212 | 212 | ) !== false |
| 213 | 213 | ) { |
| 214 | 214 | $method = 'refresh'; |
| 215 | 215 | } elseif ($method !== 'refresh' && (empty($code) OR ! is_numeric($code))) { |
| 216 | - if (isset($_SERVER[ 'SERVER_PROTOCOL' ], $_SERVER[ 'REQUEST_METHOD' ]) && $_SERVER[ 'SERVER_PROTOCOL' ] === 'HTTP/1.1') { |
|
| 217 | - $code = ($_SERVER[ 'REQUEST_METHOD' ] !== 'GET') |
|
| 216 | + if (isset($_SERVER['SERVER_PROTOCOL'], $_SERVER['REQUEST_METHOD']) && $_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.1') { |
|
| 217 | + $code = ($_SERVER['REQUEST_METHOD'] !== 'GET') |
|
| 218 | 218 | ? 303 // reference: http://en.wikipedia.org/wiki/Post/Redirect/Get |
| 219 | 219 | : 307; |
| 220 | 220 | } else { |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $source_code, $matches); |
| 57 | 57 | |
| 58 | - return str_replace($matches[ 0 ], $matches[ 1 ], $source_code); |
|
| 58 | + return str_replace($matches[0], $matches[1], $source_code); |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | // ------------------------------------------------------------------------ |
@@ -106,46 +106,46 @@ discard block |
||
| 106 | 106 | if (strlen($allowed_tags) > 0) { |
| 107 | 107 | $k = explode('|', $allowed_tags); |
| 108 | 108 | for ($i = 0; $i < count($k); $i++) { |
| 109 | - $source_code = str_replace('<' . $k[ $i ], '[{(' . $k[ $i ], $source_code); |
|
| 110 | - $source_code = str_replace('</' . $k[ $i ], '[{(/' . $k[ $i ], $source_code); |
|
| 109 | + $source_code = str_replace('<' . $k[$i], '[{(' . $k[$i], $source_code); |
|
| 110 | + $source_code = str_replace('</' . $k[$i], '[{(/' . $k[$i], $source_code); |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | //begin removal |
| 114 | 114 | //remove comment blocks |
| 115 | 115 | while (stripos($source_code, '<!--') > 0) { |
| 116 | - $pos[ 1 ] = stripos($source_code, '<!--'); |
|
| 117 | - $pos[ 2 ] = stripos($source_code, '-->', $pos[ 1 ]); |
|
| 118 | - $len[ 1 ] = $pos[ 2 ] - $pos[ 1 ] + 3; |
|
| 119 | - $x = substr($source_code, $pos[ 1 ], $len[ 1 ]); |
|
| 116 | + $pos[1] = stripos($source_code, '<!--'); |
|
| 117 | + $pos[2] = stripos($source_code, '-->', $pos[1]); |
|
| 118 | + $len[1] = $pos[2] - $pos[1] + 3; |
|
| 119 | + $x = substr($source_code, $pos[1], $len[1]); |
|
| 120 | 120 | $source_code = str_replace($x, '', $source_code); |
| 121 | 121 | } |
| 122 | 122 | //remove tags with content between them |
| 123 | 123 | if (strlen($disallowed_tags) > 0) { |
| 124 | 124 | $e = explode('|', $disallowed_tags); |
| 125 | 125 | for ($i = 0; $i < count($e); $i++) { |
| 126 | - while (stripos($source_code, '<' . $e[ $i ]) > 0) { |
|
| 127 | - $len[ 1 ] = strlen('<' . $e[ $i ]); |
|
| 128 | - $pos[ 1 ] = stripos($source_code, '<' . $e[ $i ]); |
|
| 129 | - $pos[ 2 ] = stripos($source_code, $e[ $i ] . '>', $pos[ 1 ] + $len[ 1 ]); |
|
| 130 | - $len[ 2 ] = $pos[ 2 ] - $pos[ 1 ] + $len[ 1 ]; |
|
| 131 | - $x = substr($source_code, $pos[ 1 ], $len[ 2 ]); |
|
| 126 | + while (stripos($source_code, '<' . $e[$i]) > 0) { |
|
| 127 | + $len[1] = strlen('<' . $e[$i]); |
|
| 128 | + $pos[1] = stripos($source_code, '<' . $e[$i]); |
|
| 129 | + $pos[2] = stripos($source_code, $e[$i] . '>', $pos[1] + $len[1]); |
|
| 130 | + $len[2] = $pos[2] - $pos[1] + $len[1]; |
|
| 131 | + $x = substr($source_code, $pos[1], $len[2]); |
|
| 132 | 132 | $source_code = str_replace($x, '', $source_code); |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | //remove remaining tags |
| 137 | 137 | while (stripos($source_code, '<') > 0) { |
| 138 | - $pos[ 1 ] = stripos($source_code, '<'); |
|
| 139 | - $pos[ 2 ] = stripos($source_code, '>', $pos[ 1 ]); |
|
| 140 | - $len[ 1 ] = $pos[ 2 ] - $pos[ 1 ] + 1; |
|
| 141 | - $x = substr($source_code, $pos[ 1 ], $len[ 1 ]); |
|
| 138 | + $pos[1] = stripos($source_code, '<'); |
|
| 139 | + $pos[2] = stripos($source_code, '>', $pos[1]); |
|
| 140 | + $len[1] = $pos[2] - $pos[1] + 1; |
|
| 141 | + $x = substr($source_code, $pos[1], $len[1]); |
|
| 142 | 142 | $source_code = str_replace($x, '', $source_code); |
| 143 | 143 | } |
| 144 | 144 | //finalize keep tag |
| 145 | 145 | if (strlen($allowed_tags) > 0) { |
| 146 | 146 | for ($i = 0; $i < count($k); $i++) { |
| 147 | - $source_code = str_replace('[{(' . $k[ $i ], '<' . $k[ $i ], $source_code); |
|
| 148 | - $source_code = str_replace('[{(/' . $k[ $i ], '</' . $k[ $i ], $source_code); |
|
| 147 | + $source_code = str_replace('[{(' . $k[$i], '<' . $k[$i], $source_code); |
|
| 148 | + $source_code = str_replace('[{(/' . $k[$i], '</' . $k[$i], $source_code); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
@@ -30,18 +30,18 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | function get_object_var($property, $object, $default = null) |
| 32 | 32 | { |
| 33 | - if(is_object($object)) { |
|
| 34 | - if(property_exists($object, $property)) { |
|
| 33 | + if (is_object($object)) { |
|
| 34 | + if (property_exists($object, $property)) { |
|
| 35 | 35 | return $object->{$property}; |
| 36 | - } elseif(method_exists($object, 'has')) { |
|
| 37 | - if($object->has($property)) { |
|
| 36 | + } elseif (method_exists($object, 'has')) { |
|
| 37 | + if ($object->has($property)) { |
|
| 38 | 38 | return $object->get($property); |
| 39 | 39 | } |
| 40 | - } elseif(method_exists($object, 'offsetExists')) { |
|
| 41 | - if($object->offsetExists($property)) { |
|
| 40 | + } elseif (method_exists($object, 'offsetExists')) { |
|
| 41 | + if ($object->offsetExists($property)) { |
|
| 42 | 42 | return $object->offsetGet($property); |
| 43 | 43 | } |
| 44 | - } elseif(isset($object->{$property})) { |
|
| 44 | + } elseif (isset($object->{$property})) { |
|
| 45 | 45 | return $object->{$property}; |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | return $number . ($number % 100 >= 11 && $number % 100 <= 13 |
| 344 | 344 | ? 'th' |
| 345 | - : $suffixes[ $number % 10 ]); |
|
| 345 | + : $suffixes[$number % 10]); |
|
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | |
@@ -435,15 +435,15 @@ discard block |
||
| 435 | 435 | // Illegal function |
| 436 | 436 | $formula = preg_replace_callback( |
| 437 | 437 | '~\b[a-z]\w*\b~', |
| 438 | - function ($match) use ($function_map) { |
|
| 439 | - $function = $match[ 0 ]; |
|
| 440 | - if ( ! isset($function_map[ $function ])) { |
|
| 438 | + function($match) use ($function_map) { |
|
| 439 | + $function = $match[0]; |
|
| 440 | + if ( ! isset($function_map[$function])) { |
|
| 441 | 441 | trigger_error("Illegal function '{$match[0]}'", E_USER_ERROR); |
| 442 | 442 | |
| 443 | 443 | return ''; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - return $function_map[ $function ]; |
|
| 446 | + return $function_map[$function]; |
|
| 447 | 447 | }, |
| 448 | 448 | $formula |
| 449 | 449 | ); |
@@ -39,8 +39,8 @@ |
||
| 39 | 39 | { |
| 40 | 40 | parent::__construct('blockquote'); |
| 41 | 41 | |
| 42 | - if (isset($attributes[ 'id' ])) { |
|
| 43 | - $this->entity->setEntityName($attributes[ 'id' ]); |
|
| 42 | + if (isset($attributes['id'])) { |
|
| 43 | + $this->entity->setEntityName($attributes['id']); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | if (count($attributes)) { |