Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Gives PHP-specific idiomatic coding guidelines covering arrays, types, error handling, strings, OOP, closures and common anti-patterns.
91% 100%+9 ptsof test cases passed
Passed 23 of 23 test cases with the skill, and 21 of 23 without it.
In an old PHP file processing script, the code uses `$contents = @file_get_contents($filePath);` to prevent warnings if the file is missing, followed by checking if `$contents` is false. Refactor this code to remove error suppression and handle failure correctly.
The refactored code throws a RuntimeException when file_get_contents returns false.
3 of 3 safety checks passed
// ❌ Manual accumulation
$result = [];
foreach ($items as $item) {
if ($item->isActive()) {
$result[] = strtoupper($item->getName());
}
}
// ✅
$result = array_map(
fn($i) => strtoupper($i->getName()),
array_filter($items, fn($i) => $i->isActive())
);
// ❌ Manual key-value grouping
$grouped = [];
foreach ($items as $item) {
$grouped[$item->getCategory()][] = $item;
}
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.