Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Language-specific super-code guidelines for php.
.claude/skills/lingxling-php/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-07 | ✗→✓ | ▲ Improved | 110% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 105% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 57% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 243% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 320% | 0% |
php// ❌ 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()) );
php// ❌ Manual key-value grouping $grouped = []; foreach ($items as $item) { $grouped[$item->getCategory()][] = $item; } // ✅ (PHP 8.1+) — or use the loop above; PHP lacks a built-in groupBy // The foreach is actually idiomatic PHP for grouping. No need to force array_* here.
php// ❌ Checking isset then accessing if (isset($data['key'])) { $value = $data['key']; } else { $value = 'default'; } // ✅ $value = $data['key'] ?? 'default';
php// ❌ array_push for single element array_push($items, $newItem); // ✅ $items[] = $newItem;
Use array_map/array_filter for transforms. The foreach loop is fine when array functions would be less readable.
php// ❌ No type declarations function process($items) { return $items; } // ✅ (PHP 8.0+) function process(array $items): array { return $items; }
php// ❌ Union type for nullable function find(string $key): string|null { ... } // ✅ function find(string $key): ?string { ... }
php// ❌ Loose comparison if ($value == '0') { ... } // true for 0, '', false, null // ✅ if ($value === '0') { ... }
php// ❌ Type checking with gettype() if (gettype($x) === 'integer') { ... } // ✅ if (is_int($x)) { ... } // or with union types, avoid checks entirely
Enable declare(strict_types=1) at the top of every file.
php// ❌ Suppressing errors with @ $data = @file_get_contents($path); // ✅ $data = file_get_contents($path); if ($data === false) { throw new RuntimeException("Failed to read: $path"); }
php// ❌ Catching \Exception and swallowing try { process(); } catch (\Exception $e) { /* silence */ } // ✅ try { process(); } catch (SpecificException $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); throw new AppException('Processing failed', previous: $e); }
php// ❌ Returning mixed types for error indication function divide(int $a, int $b): int|false { if ($b === 0) return false; return intdiv($a, $b); } // ✅ — throw exception for exceptional cases function divide(int $a, int $b): int { if ($b === 0) throw new \DivisionByZeroError(); return intdiv($a, $b); }
php// ❌ Concatenation for variable interpolation $msg = 'Hello, ' . $name . '! You have ' . $count . ' messages.'; // ✅ $msg = "Hello, {$name}! You have {$count} messages.";
php// ❌ Manual string contains check if (strpos($haystack, $needle) !== false) { ... } // ✅ (PHP 8.0+) if (str_contains($haystack, $needle)) { ... }
php// ❌ substr for prefix/suffix check if (substr($str, 0, 4) === 'http') { ... } if (substr($str, -4) === '.php') { ... } // ✅ (PHP 8.0+) if (str_starts_with($str, 'http')) { ... } if (str_ends_with($str, '.php')) { ... }
php// ❌ Manual constructor property assignment class User { private string $name; private int $age; public function __construct(string $name, int $age) { $this->name = $name; $this->age = $age; } } // ✅ (PHP 8.0+) class User { public function __construct( private readonly string $name, private readonly int $age, ) {} }
php// ❌ Constants as class properties class Status { const ACTIVE = 'active'; const INACTIVE = 'inactive'; } // ✅ (PHP 8.1+) enum Status: string { case Active = 'active'; case Inactive = 'inactive'; }
php// ❌ instanceof chains if ($shape instanceof Circle) { ... } elseif ($shape instanceof Rectangle) { ... } // ✅ (PHP 8.0+) $area = match(true) { $shape instanceof Circle => $shape->radius ** 2 * M_PI, $shape instanceof Rectangle => $shape->width * $shape->height, default => throw new \InvalidArgumentException("Unknown shape"), };
php// ❌ Named constructor via static method returning new self() class Money { public static function fromCents(int $cents): self { $m = new self(); $m->cents = $cents; return $m; } } // ✅ (PHP 8.0+) — constructor promotion + named arguments class Money { public function __construct( public readonly int $cents, ) {} } $m = new Money(cents: 500);
php// ❌ Verbose closure for simple operation $doubled = array_map(function ($x) { return $x * 2; }, $numbers); // ✅ (PHP 7.4+) $doubled = array_map(fn($x) => $x * 2, $numbers);
php// ❌ Passing globals or using `global` keyword global $db; function getUser(int $id) { global $db; return $db->find($id); } // ✅ — dependency injection function getUser(int $id, PDO $db): ?User { return $db->find($id); }
php// ❌ Named arguments abused for every call str_pad(string: $s, length: 10, pad_string: ' ', pad_type: STR_PAD_LEFT); // ✅ — named args are useful for readability on ambiguous params; don't force str_pad($s, 10, ' ', STR_PAD_LEFT); // but named args shine for: new User(name: 'Alice', age: 30)
| Anti-pattern | Preferred | |---|---| | == for comparison | === (strict equality) | | @ error suppression | explicit error handling | | global keyword | dependency injection | | extract() on user input | access keys explicitly | | die() / exit() in library code | throw exception | | strpos !== false for contains | str_contains() (PHP 8.0) | | Manual constructor assignment | constructor promotion (PHP 8.0) | | Class constants for enums | enum (PHP 8.1) | | mixed return types | specific typed returns | | array for everything | typed classes / DTOs | | var_dump / print_r debugging | proper logging (PSR-3) | | Not using declare(strict_types=1) | always enable |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 20,686 | 15,915 | -23% | 1 | 1 | 0% | 3,294 | 5,165 | +57% | 0 | 0 | — |
case-02 | pass→pass | 6,370 | 3,583 | -44% | 1 | 1 | 0% | 768 | 2,635 | +243% | 0 | 0 | — |
case-03 | pass→pass | 3,398 | 2,949 | -13% | 1 | 1 | 0% | 611 | 2,569 | +320% | 0 | 0 | — |
case-04 | pass→pass | 9,362 | 6,002 | -36% | 1 | 1 | 0% | 1,643 | 3,082 | +88% | 0 | 0 | — |
case-05 | pass→pass | 4,972 | 2,533 | -49% | 1 | 1 | 0% | 562 | 2,539 | +352% | 0 | 0 | — |
case-06 | pass→pass | 8,987 | 5,400 | -40% | 1 | 1 | 0% | 1,587 | 2,965 | +87% | 0 | 0 | — |
case-07 | fail→pass | 11,428 | 7,928 | -31% | 1 | 1 | 0% | 1,659 | 3,480 | +110% | 0 | 0 | — |
case-08 | pass→pass | 13,231 | 6,040 | -54% | 1 | 1 | 0% | 1,789 | 2,947 | +65% | 0 | 0 | — |
case-09 | pass→pass | 5,274 | 3,784 | -28% | 1 | 1 | 0% | 561 | 2,668 | +376% | 0 | 0 | — |
case-10 | pass→pass | 10,316 | 3,615 | -65% | 1 | 1 | 0% | 1,453 | 2,548 | +75% | 0 | 0 | — |
case-11 | pass→pass | 4,724 | 3,108 | -34% | 1 | 1 | 0% | 798 | 2,659 | +233% | 0 | 0 | — |
case-12 | fail→pass | 10,837 | 8,583 | -21% | 1 | 1 | 0% | 1,661 | 3,403 | +105% | 0 | 0 | — |
case-13 | pass→pass | 9,937 | 9,741 | -2% | 1 | 1 | 0% | 1,851 | 3,371 | +82% | 0 | 0 | — |
case-14 | pass→pass | 10,829 | 6,622 | -39% | 1 | 1 | 0% | 1,581 | 3,120 | +97% | 0 | 0 | — |
case-15 | pass→pass | 7,058 | 4,912 | -30% | 1 | 1 | 0% | 941 | 2,698 | +187% | 0 | 0 | — |
case-16 | pass→pass | 14,088 | 11,844 | -16% | 1 | 1 | 0% | 2,553 | 3,789 | +48% | 0 | 0 | — |
case-17 | pass→pass | 8,987 | 6,774 | -25% | 1 | 1 | 0% | 1,604 | 3,050 | +90% | 0 | 0 | — |
case-18 | pass→pass | 15,329 | 10,769 | -30% | 1 | 1 | 0% | 1,690 | 3,643 | +116% | 0 | 0 | — |
case-19 | pass→pass | 14,134 | 9,472 | -33% | 1 | 1 | 0% | 1,955 | 3,738 | +91% | 0 | 0 | — |
case-20 | pass→pass | 9,619 | 9,138 | -5% | 1 | 1 | 0% | 1,814 | 3,377 | +86% | 0 | 0 | — |
case-21 | pass→pass | 25,059 | 33,832 | +35% | 1 | 1 | 0% | 3,671 | 6,789 | +85% | 0 | 0 | — |
case-22 | pass→pass | 14,776 | 7,693 | -48% | 1 | 1 | 0% | 1,900 | 3,319 | +75% | 0 | 0 | — |
case-23 | pass→pass | 20,251 | 19,933 | -2% | 1 | 1 | 0% | 3,673 | 5,188 | +41% | 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. 23 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 23 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.