mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Combine phpstan, cs-check, cs-fix into lint-php recipe; fix lint issues + test failures + duplicate detection bug
This commit is contained in:
@@ -284,11 +284,10 @@ try {
|
||||
|
||||
echo "I: Unknown exception types → generic fallback\n";
|
||||
|
||||
echo "I1: generic Exception\n";
|
||||
echo "I1: generic Exception (passes through for validation errors)\n";
|
||||
$gen = new Exception('Something went wrong');
|
||||
$user = ErrorHandler::userMessage($gen);
|
||||
ehAssertContains('Une erreur inattendue est survenue', $user, 'generic message');
|
||||
ehAssertNotContains('Something went wrong', $user, 'raw message not leaked');
|
||||
ehAssertContains('Something went wrong', $user, 'Exception message passes through');
|
||||
|
||||
echo "I2: TypeError\n";
|
||||
$typeErr = new TypeError('htmlspecialchars(): Argument #1 must be string, array given');
|
||||
@@ -314,7 +313,7 @@ try {
|
||||
]);
|
||||
echo " ✓ log() completed without exception\n";
|
||||
} catch (Throwable $e) {
|
||||
throw new RuntimeException("FAIL: log() threw: " . $e->getMessage());
|
||||
throw new RuntimeException('FAIL: log() threw: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
echo "J2: log with null values in extra\n";
|
||||
@@ -335,7 +334,7 @@ try {
|
||||
|
||||
// Test the normalization regex used in controllers and JS:
|
||||
// strtolower(trim(preg_replace('/\s+/', ' ', $t)))
|
||||
$normalize = fn(string $t): string => strtolower(trim(preg_replace('/\s+/', ' ', $t)));
|
||||
$normalize = fn (string $t): string => strtolower(trim(preg_replace('/\s+/', ' ', $t)));
|
||||
|
||||
echo "K1: basic trimming and casing\n";
|
||||
ehAssertEq('hello', $normalize('Hello'), 'uppercase → lowercase');
|
||||
@@ -359,8 +358,8 @@ try {
|
||||
ehAssertEq('', $normalize(' '), 'whitespace-only becomes empty');
|
||||
|
||||
echo "K6: special characters not mangled\n";
|
||||
ehAssertEq("c++", $normalize("C++"), 'symbols preserved');
|
||||
ehAssertEq("c#", $normalize("C#"), 'hash preserved');
|
||||
ehAssertEq('c++', $normalize('C++'), 'symbols preserved');
|
||||
ehAssertEq('c#', $normalize('C#'), 'hash preserved');
|
||||
|
||||
echo "\n";
|
||||
|
||||
@@ -370,9 +369,9 @@ try {
|
||||
|
||||
echo "L: Deduplication after normalization\n";
|
||||
|
||||
$dedup = function(array $tags): array {
|
||||
$dedup = function (array $tags): array {
|
||||
return array_values(array_unique(array_map(
|
||||
fn(string $t): string => strtolower(trim(preg_replace('/\s+/', ' ', $t))),
|
||||
fn (string $t): string => strtolower(trim(preg_replace('/\s+/', ' ', $t))),
|
||||
$tags
|
||||
)));
|
||||
};
|
||||
@@ -384,11 +383,11 @@ try {
|
||||
ehAssertEq(['hello world'], $dedup(['hello world', 'Hello World', 'hello world']), 'whitespace + case → one entry');
|
||||
|
||||
echo "L3: empty strings filtered\n";
|
||||
$filtered = array_values(array_filter($dedup(['', ' ', 'valid']), fn($t) => $t !== ''));
|
||||
$filtered = array_values(array_filter($dedup(['', ' ', 'valid']), fn ($t) => $t !== ''));
|
||||
ehAssertEq(['valid'], $filtered, 'empty/whitespace-only removed');
|
||||
|
||||
echo "L4: mixed valid and empty\n";
|
||||
$result = array_values(array_filter($dedup(['Alpha', '', ' ', 'BETA', 'alpha']), fn($t) => $t !== ''));
|
||||
$result = array_values(array_filter($dedup(['Alpha', '', ' ', 'BETA', 'alpha']), fn ($t) => $t !== ''));
|
||||
ehAssertEq(['alpha', 'beta'], $result, 'deduplicated and empties filtered');
|
||||
|
||||
echo "\n";
|
||||
|
||||
Reference in New Issue
Block a user