phpstan checks and fixes
This commit is contained in:
@@ -24,12 +24,12 @@ final class CoreLibsCheckEmailTest extends TestCase
|
|||||||
'get email regex invalid -1, will be 0' => [
|
'get email regex invalid -1, will be 0' => [
|
||||||
-1,
|
-1,
|
||||||
"^[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+\-\/=?^_`{|}~\.]{0,63}@"
|
"^[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+\-\/=?^_`{|}~\.]{0,63}@"
|
||||||
. "[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*\.([a-zA-Z]{2,}){1}$"
|
. "(?!-)[A-Za-z0-9-]{1,63}(?<!-)(?:\.[A-Za-z0-9-]{1,63}(?<!-))*\.[a-zA-Z]{2,6}$"
|
||||||
],
|
],
|
||||||
'get email regex invalid 10, will be 0' => [
|
'get email regex invalid 10, will be 0' => [
|
||||||
10,
|
10,
|
||||||
"^[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+\-\/=?^_`{|}~\.]{0,63}@"
|
"^[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+\-\/=?^_`{|}~\.]{0,63}@"
|
||||||
. "[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*\.([a-zA-Z]{2,}){1}$"
|
. "(?!-)[A-Za-z0-9-]{1,63}(?<!-)(?:\.[A-Za-z0-9-]{1,63}(?<!-))*\.[a-zA-Z]{2,6}$"
|
||||||
],
|
],
|
||||||
'get email regex valid 1, will be 1' => [
|
'get email regex valid 1, will be 1' => [
|
||||||
1,
|
1,
|
||||||
@@ -157,7 +157,7 @@ final class CoreLibsCheckEmailTest extends TestCase
|
|||||||
'error' => 0,
|
'error' => 0,
|
||||||
'message' => 'Invalid email address',
|
'message' => 'Invalid email address',
|
||||||
'regex' => "^[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+\-\/=?^_`{|}~\.]{0,63}@"
|
'regex' => "^[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+\-\/=?^_`{|}~\.]{0,63}@"
|
||||||
. "[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*\.([a-zA-Z]{2,}){1}$"
|
. "(?!-)[A-Za-z0-9-]{1,63}(?<!-)(?:\.[A-Za-z0-9-]{1,63}(?<!-))*\.[a-zA-Z]{2,6}$"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'error 1 will return double @ error' => [
|
'error 1 will return double @ error' => [
|
||||||
@@ -181,7 +181,7 @@ final class CoreLibsCheckEmailTest extends TestCase
|
|||||||
[
|
[
|
||||||
'error' => 3,
|
'error' => 3,
|
||||||
'message' => 'Invalid domain part after @ sign',
|
'message' => 'Invalid domain part after @ sign',
|
||||||
'regex' => "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,}){1}$"
|
'regex' => "@(?!-)[A-Za-z0-9-]{1,63}(?<!-)(?:\.[A-Za-z0-9-]{1,63}(?<!-))*\.[a-zA-Z]{2,6}$"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'error 4 will be invalid domain' => [
|
'error 4 will be invalid domain' => [
|
||||||
@@ -189,7 +189,7 @@ final class CoreLibsCheckEmailTest extends TestCase
|
|||||||
[
|
[
|
||||||
'error' => 4,
|
'error' => 4,
|
||||||
'message' => 'Invalid domain name part',
|
'message' => 'Invalid domain name part',
|
||||||
'regex' => "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\."
|
'regex' => "@(?!-)[A-Za-z0-9-]{1,63}(?<!-)(?:\.[A-Za-z0-9-]{1,63}(?<!-))*\."
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'error 5 will be invalid domain top level only' => [
|
'error 5 will be invalid domain top level only' => [
|
||||||
@@ -197,7 +197,7 @@ final class CoreLibsCheckEmailTest extends TestCase
|
|||||||
[
|
[
|
||||||
'error' => 5,
|
'error' => 5,
|
||||||
'message' => 'Wrong domain top level part',
|
'message' => 'Wrong domain top level part',
|
||||||
'regex' => "\.([a-zA-Z]{2,6}){1}$"
|
'regex' => "\.[a-zA-Z]{2,6}$"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'error 6 will be domain double dot' => [
|
'error 6 will be domain double dot' => [
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use CoreLibs\Logging\Logger\Flag;
|
|||||||
final class CoreLibsLoggingLoggingTest extends TestCase
|
final class CoreLibsLoggingLoggingTest extends TestCase
|
||||||
{
|
{
|
||||||
private const LOG_FOLDER = __DIR__ . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR;
|
private const LOG_FOLDER = __DIR__ . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR;
|
||||||
private const REGEX_BASE = "\[[\d\-\s\.:]+\]\s{1}" // date
|
private const REGEX_BASE = "\[[\d\-\s\.:+T]+\]\s{1}" // date, just basic checks
|
||||||
. "\[[\w\.]+(:\d+)?\]\s{1}" // host:port
|
. "\[[\w\.]+(:\d+)?\]\s{1}" // host:port
|
||||||
. "\[(phar:\/\/)?[\w\-\.\/]+:\d+\]\s{1}" // folder/file [note phar:// is for phpunit]
|
. "\[(phar:\/\/)?[\w\-\.\/]+:\d+\]\s{1}" // folder/file [note phar:// is for phpunit]
|
||||||
. "\[\w+\]\s{1}" // run id
|
. "\[\w+\]\s{1}" // run id
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ print "(kosrt, lower case, reverse): "
|
|||||||
|
|
||||||
print "<hr>";
|
print "<hr>";
|
||||||
$nested = [
|
$nested = [
|
||||||
'B' => 'foo', 'a', '0', 9,
|
'B' => 'foo', 'a', '0', 9, /** @phpstan-ignore-line This is a test for wrong index */
|
||||||
'1' => ['z', 'b', 'a'],
|
'1' => ['z', 'b', 'a'],
|
||||||
'd' => ['zaip', 'bar', 'baz']
|
'd' => ['zaip', 'bar', 'baz']
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class Email
|
|||||||
// 3 => "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,}){1}$", // wrong part after @
|
// 3 => "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,}){1}$", // wrong part after @
|
||||||
3 => "@(?!-)[A-Za-z0-9-]{1,63}(?<!-)(?:\.[A-Za-z0-9-]{1,63}(?<!-))*\.[a-zA-Z]{2,6}$", // wrong part after @
|
3 => "@(?!-)[A-Za-z0-9-]{1,63}(?<!-)(?:\.[A-Za-z0-9-]{1,63}(?<!-))*\.[a-zA-Z]{2,6}$", // wrong part after @
|
||||||
// 4 => "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.", // wrong domain name part
|
// 4 => "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.", // wrong domain name part
|
||||||
4 => "@@(?!-)[A-Za-z0-9-]{1,63}(?<!-)(?:\.[A-Za-z0-9-]{1,63}(?<!-))*\.", // wrong domain name part
|
4 => "@(?!-)[A-Za-z0-9-]{1,63}(?<!-)(?:\.[A-Za-z0-9-]{1,63}(?<!-))*\.", // wrong domain name part
|
||||||
5 => "\.[a-zA-Z]{2,6}$", // wrong top level part
|
5 => "\.[a-zA-Z]{2,6}$", // wrong top level part
|
||||||
6 => "@(.*)\.{2,}", // double .. in domain name part
|
6 => "@(.*)\.{2,}", // double .. in domain name part
|
||||||
7 => "@.*\.$" // ends with a dot, top level, domain missing
|
7 => "@.*\.$" // ends with a dot, top level, domain missing
|
||||||
|
|||||||
@@ -199,15 +199,17 @@ class Math
|
|||||||
callback: fn ($col) => is_array($row) ?
|
callback: fn ($col) => is_array($row) ?
|
||||||
array_reduce(
|
array_reduce(
|
||||||
array: $row,
|
array: $row,
|
||||||
callback: fn ($a, $v, $i = null) => $a + $v * (
|
// TODO check that v is not an array
|
||||||
|
callback: fn ($a, $v, $i = null) => $a + $v * ( /** @phpstan-ignore-line Possible array + int */
|
||||||
// if last entry missing for full copy add a 0 to it
|
// if last entry missing for full copy add a 0 to it
|
||||||
$col[$i ?? array_search($v, $row, true)] ?? 0 /** @phpstan-ignore-line */
|
$col[$i ?? array_search($v, $row, true)] ?? 0
|
||||||
),
|
),
|
||||||
initial: 0,
|
initial: 0,
|
||||||
) :
|
) :
|
||||||
array_reduce(
|
array_reduce(
|
||||||
array: $col,
|
array: $col,
|
||||||
callback: fn ($a, $v) => $a + $v * $row,
|
// TODO check that v is not an array
|
||||||
|
callback: fn ($a, $v) => $a + $v * $row, /** @phpstan-ignore-line Possible array + int */
|
||||||
initial: 0,
|
initial: 0,
|
||||||
),
|
),
|
||||||
array: $bCols,
|
array: $bCols,
|
||||||
|
|||||||
@@ -263,11 +263,11 @@ class ConvertPlaceholder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add the connectors back (1), and the data sets only if no replacement will be done
|
// add the connectors back (1), and the data sets only if no replacement will be done
|
||||||
return $params_lookup[$match] ??
|
return $params_lookup[$match]/* ??
|
||||||
throw new \RuntimeException(
|
throw new \RuntimeException(
|
||||||
'Cannot lookup ' . $match . ' in params lookup list',
|
'Cannot lookup ' . $match . ' in params lookup list',
|
||||||
211
|
211
|
||||||
);
|
)*/;
|
||||||
},
|
},
|
||||||
$converted_placeholders['original']['query']
|
$converted_placeholders['original']['query']
|
||||||
);
|
);
|
||||||
@@ -327,11 +327,11 @@ class ConvertPlaceholder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add the connectors back (1), and the data sets only if no replacement will be done
|
// add the connectors back (1), and the data sets only if no replacement will be done
|
||||||
return $params_lookup[$match] ??
|
return $params_lookup[$match]/* ??
|
||||||
throw new \RuntimeException(
|
throw new \RuntimeException(
|
||||||
'Cannot lookup ' . $match . ' in params lookup list',
|
'Cannot lookup ' . $match . ' in params lookup list',
|
||||||
231
|
231
|
||||||
);
|
)*/;
|
||||||
},
|
},
|
||||||
$converted_placeholders['original']['query']
|
$converted_placeholders['original']['query']
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class Logging
|
|||||||
// if turned off uses old time format without time zone
|
// if turned off uses old time format without time zone
|
||||||
'log_time_format_iso' => [
|
'log_time_format_iso' => [
|
||||||
'type' => 'bool', 'mandatory' => false,
|
'type' => 'bool', 'mandatory' => false,
|
||||||
'default' => true
|
'default' => true, 'deprecated' => false
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user