Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Common PHP mistakes and anti-patterns to avoid for cleaner, more maintainable code.
.claude/skills/valec3-backend-php-anti-patterns/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | -3% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 38% | 0% |
| case-22 | ✓→✓ | = Same ✓ | 48% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 3% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 48% | 0% |
php<?php // ❌ Bad: Class does everything class User { public function save() {} public function sendEmail() {} public function generatePDF() {} public function processPayment() {} public function logActivity() {} } // ✅ Good: Single Responsibility class User { // Only user data and basic operations } class UserRepository { public function save(User $user) {} } class EmailService { public function sendWelcomeEmail(User $user) {} }
php<?php // ❌ Bad: Global variables global $db; $users = $db->query('SELECT * FROM users'); // ✅ Good: Dependency injection class UserController { public function __construct( private readonly Database $db ) {} public function index() { $users = $this->db->query('SELECT * FROM users'); } }
php<?php // ❌ Bad: Swallowing exceptions try { $user = $this->getUser($id); } catch (\Exception $e) { // Do nothing } // ✅ Good: Handle or propagate try { $user = $this->getUser($id); } catch (NotFoundException $e) { return $this->respond(['error' => 'User not found'], 404); } catch (\Exception $e) { log_message('error', $e->getMessage()); throw $e; }
php<?php // ❌ Bad if ($user->status === 1) { // What does 1 mean? } // ✅ Good: Use enums or constants enum UserStatus: int { case ACTIVE = 1; case INACTIVE = 2; } if ($user->status === UserStatus::ACTIVE) { // Clear intent }
php<?php // ❌ Bad: Unclear structure $user = [ 'id' => 1, 'name' => 'John', 'data' => ['email' => 'john@example.com'] ]; // ✅ Good: Use DTOs or entities class User { public function __construct( public readonly int $id, public readonly string $name, public readonly string $email ) {} }
php<?php // ❌ Bad: Relying on loose comparison if ($value == true) {} // '1', 'yes', [1] all match if ($count == 0) {} // '', null, false, [] all match // ✅ Good: Strict comparison if ($value === true) {} if ($count === 0) {}
php<?php // ❌ Bad: Returning error codes function getUser(int $id) { $user = $this->db->find($id); return $user ?: false; } // ✅ Good: Throw exceptions function getUser(int $id): User { $user = $this->db->find($id); if (!$user) { throw new NotFoundException('User not found'); } return $user; }
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-22 | pass→pass | 11,839 | 9,919 | -16% | 1 | 1 | 0% | 1,813 | 2,679 | +48% | 0 | 0 | — |
case-01 | fail→pass | 17,260 | 9,188 | -47% | 1 | 1 | 0% | 2,894 | 2,803 | -3% | 0 | 0 | — |
case-02 | pass→pass | 12,967 | 7,215 | -44% | 1 | 1 | 0% | 2,280 | 2,337 | +3% | 0 | 0 | — |
case-03 | fail→fail | 12,348 | 11,353 | -8% | 1 | 1 | 0% | 2,256 | 3,045 | +35% | 0 | 0 | — |
case-04 | pass→pass | 10,072 | 9,522 | -5% | 1 | 1 | 0% | 1,924 | 2,857 | +48% | 0 | 0 | — |
case-05 | pass→pass | 13,810 | 10,564 | -24% | 1 | 1 | 0% | 2,515 | 3,059 | +22% | 0 | 0 | — |
case-06 | pass→pass | 11,513 | 10,276 | -11% | 1 | 1 | 0% | 2,117 | 2,789 | +32% | 0 | 0 | — |
case-07 | pass→pass | 11,119 | 8,419 | -24% | 1 | 1 | 0% | 1,944 | 2,407 | +24% | 0 | 0 | — |
case-08 | pass→pass | 12,698 | 9,272 | -27% | 1 | 1 | 0% | 2,516 | 2,770 | +10% | 0 | 0 | — |
case-09 | pass→pass | 7,075 | 4,658 | -34% | 1 | 1 | 0% | 1,476 | 1,879 | +27% | 0 | 0 | — |
case-10 | pass→pass | 13,916 | 8,731 | -37% | 1 | 1 | 0% | 2,377 | 2,635 | +11% | 0 | 0 | — |
case-11 | pass→pass | 9,927 | 7,909 | -20% | 1 | 1 | 0% | 1,497 | 2,388 | +60% | 0 | 0 | — |
case-12 | fail→pass | 8,299 | 6,406 | -23% | 1 | 1 | 0% | 1,657 | 2,293 | +38% | 0 | 0 | — |
case-21 | pass→pass | 17,123 | 15,278 | -11% | 1 | 1 | 0% | 2,962 | 3,479 | +17% | 0 | 0 | — |
case-13 | pass→pass | 28,816 | 7,492 | -74% | 1 | 1 | 0% | 1,854 | 2,408 | +30% | 0 | 0 | — |
case-14 | pass→pass | 10,251 | 8,668 | -15% | 1 | 1 | 0% | 2,012 | 2,446 | +22% | 0 | 0 | — |
case-15 | pass→pass | 9,222 | 5,369 | -42% | 1 | 1 | 0% | 1,557 | 1,923 | +24% | 0 | 0 | — |
case-16 | pass→pass | 12,617 | 13,097 | +4% | 1 | 1 | 0% | 2,174 | 3,258 | +50% | 0 | 0 | — |
case-17 | pass→pass | 8,089 | 5,255 | -35% | 1 | 1 | 0% | 1,374 | 1,845 | +34% | 0 | 0 | — |
case-18 | pass→pass | 3,419 | 3,359 | -2% | 1 | 1 | 0% | 488 | 1,498 | +207% | 0 | 0 | — |
case-19 | pass→pass | 9,677 | 6,312 | -35% | 1 | 1 | 0% | 2,035 | 2,127 | +5% | 0 | 0 | — |
case-20 | pass→pass | 14,582 | 14,548 | -0% | 1 | 1 | 0% | 2,836 | 3,725 | +31% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.