Update from PSR-2 to PSR-12

- Tabs are indent
- Warning at 120, Error at 240 char length
This commit is contained in:
Clemens Schwaighofer
2021-07-14 10:00:56 +09:00
parent 11daac6d23
commit 6722468bdb
96 changed files with 2855 additions and 1677 deletions
+17 -10
View File
@@ -1,9 +1,11 @@
<?php declare(strict_types=1);
<?php
/*
* html convert functions
*/
declare(strict_types=1);
namespace CoreLibs\Combined;
class ArrayHandler
@@ -23,7 +25,8 @@ class ArrayHandler
if (!is_array($haystack)) {
$haystack = [];
}
if ($key_lookin != null &&
if (
$key_lookin != null &&
!empty($key_lookin) &&
array_key_exists($key_lookin, $haystack) &&
$needle === $haystack[$key_lookin]
@@ -31,20 +34,23 @@ class ArrayHandler
$path[] = $key_lookin;
} else {
foreach ($haystack as $key => $val) {
if (is_scalar($val) &&
if (
is_scalar($val) &&
$val === $needle &&
empty($key_lookin)
) {
$path[] = $key;
break;
} elseif (is_scalar($val) &&
} elseif (
is_scalar($val) &&
!empty($key_lookin) &&
$key === $key_lookin &&
$val == $needle
) {
$path[] = $key;
break;
} elseif (is_array($val) &&
} elseif (
is_array($val) &&
$path = self::arraySearchRecursive(
$needle,
(array)$val,
@@ -160,7 +166,7 @@ class ArrayHandler
{
// croak on not enough arguemnts (we need at least two)
if (func_num_args() < 2) {
trigger_error(__FUNCTION__ .' needs two or more array arguments', E_USER_WARNING);
trigger_error(__FUNCTION__ . ' needs two or more array arguments', E_USER_WARNING);
return false;
}
// default key is not string
@@ -174,14 +180,14 @@ class ArrayHandler
}
// check that arrays count is at least two, else we don't have enough to do anything
if (count($arrays) < 2) {
trigger_error(__FUNCTION__.' needs two or more array arguments', E_USER_WARNING);
trigger_error(__FUNCTION__ . ' needs two or more array arguments', E_USER_WARNING);
return false;
}
$merged = [];
while ($arrays) {
$array = array_shift($arrays);
if (!is_array($array)) {
trigger_error(__FUNCTION__ .' encountered a non array argument', E_USER_WARNING);
trigger_error(__FUNCTION__ . ' encountered a non array argument', E_USER_WARNING);
return false;
}
if (!$array) {
@@ -259,9 +265,10 @@ class ArrayHandler
{
$ret_array = [];
// do this to only run count once
for ($i = 0, $iMax = count($db_array); $i < $iMax; $i ++) {
for ($i = 0, $iMax = count($db_array); $i < $iMax; $i++) {
// if no key then we make an order reference
if ($key !== false &&
if (
$key !== false &&
$value !== false &&
(($set_only && $db_array[$i][$value]) || (!$set_only))
) {
+16 -13
View File
@@ -1,9 +1,11 @@
<?php declare(strict_types=1);
<?php
/*
* image thumbnail, rotate, etc
*/
declare(strict_types=1);
namespace CoreLibs\Combined;
class DateTime
@@ -21,7 +23,7 @@ class DateTime
list ($timestamp, $ms) = array_pad(explode('.', (string)round($timestamp, 4)), 2, null);
$string = date("Y-m-d H:i:s", (int)$timestamp);
if ($show_micro && $ms) {
$string .= ' '.$ms.'ms';
$string .= ' ' . $ms . 'ms';
}
return $string;
}
@@ -50,12 +52,12 @@ class DateTime
if ($timestamp == 0) {
$time_string = '0s';
} else {
for ($i = 0, $iMax = count($timegroups); $i < $iMax; $i ++) {
for ($i = 0, $iMax = count($timegroups); $i < $iMax; $i++) {
$output = floor((float)$timestamp / $timegroups[$i]);
$timestamp = (float)$timestamp % $timegroups[$i];
// output has days|hours|min|sec
if ($output || $time_string) {
$time_string .= $output.$labels[$i].(($i + 1) != count($timegroups) ? ' ' : '');
$time_string .= $output . $labels[$i] . (($i + 1) != count($timegroups) ? ' ' : '');
}
}
}
@@ -65,13 +67,13 @@ class DateTime
$ms = preg_replace("/^0+(\d+)$/", '${1}', $ms);
// add ms if there
if ($show_micro) {
$time_string .= ' '.(!$ms ? 0 : $ms).'ms';
$time_string .= ' ' . (!$ms ? 0 : $ms) . 'ms';
} elseif (!$time_string) {
$time_string .= (!$ms ? 0 : $ms).'ms';
$time_string .= (!$ms ? 0 : $ms) . 'ms';
}
}
if ($negative) {
$time_string = '-'.$time_string;
$time_string = '-' . $time_string;
}
} else {
$time_string = $timestamp;
@@ -108,7 +110,7 @@ class DateTime
}
}
if (isset($matches[10]) && is_numeric($matches[10])) {
$timestamp .= '.'.$matches[10];
$timestamp .= '.' . $matches[10];
}
if ($negative) {
$timestamp *= -1;
@@ -159,7 +161,8 @@ class DateTime
if (!is_numeric($hour) || !is_numeric($min)) {
return false;
}
if (($hour < 0 || $hour > 24) ||
if (
($hour < 0 || $hour > 24) ||
($min < 0 || $min > 60) ||
(is_numeric($sec) && ($sec < 0 || $sec > 60))
) {
@@ -192,15 +195,15 @@ class DateTime
// check that month & day are two digits and then combine
foreach (['start', 'end'] as $prefix) {
foreach (['month', 'day'] as $date_part) {
$_date = $prefix.'_'.$date_part;
$_date = $prefix . '_' . $date_part;
if (isset($$_date) && $$_date < 10 && !preg_match("/^0/", $$_date)) {
$$_date = '0'.$$_date;
$$_date = '0' . $$_date;
}
}
$_date = $prefix.'_date';
$_date = $prefix . '_date';
$$_date = '';
foreach (['year', 'month', 'day'] as $date_part) {
$_sub_date = $prefix.'_'.$date_part;
$_sub_date = $prefix . '_' . $date_part;
$$_date .= $$_sub_date;
}
}