Loading...
Loading...
PHP 8.5+ modern patterns, PSR standards, and SOLID principles. Use when reviewing PHP code, checking type safety, auditing code quality, or ensuring PHP best practices. Triggers on "review PHP", "check PHP code", "audit PHP", or "PHP best practices".
npx skill4agent add asyrafhussin/agent-skills php-best-practices| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Type System | CRITICAL | |
| 2 | Modern Features | CRITICAL | |
| 3 | PSR Standards | HIGH | |
| 4 | SOLID Principles | HIGH | |
| 5 | Error Handling | HIGH | |
| 6 | Performance | MEDIUM | |
| 7 | Security | CRITICAL | |
type-strict-modetype-return-typestype-parameter-typestype-property-typestype-union-typestype-intersection-typestype-nullabletype-mixed-avoidtype-void-returntype-never-returnmodern-constructor-promotionmodern-readonly-propertiesmodern-readonly-classesmodern-enumsmodern-attributesmodern-match-expressionmodern-named-argumentsmodern-nullsafe-operatormodern-arrow-functionsmodern-first-class-callablespsr-4-autoloadingpsr-12-coding-stylepsr-naming-conventionspsr-file-structurepsr-namespace-declarationsolid-single-responsibilitysolid-open-closedsolid-liskov-substitutionsolid-interface-segregationsolid-dependency-inversionerror-custom-exceptionserror-exception-hierarchyerror-try-catch-specificerror-finally-cleanuperror-never-suppressperf-avoid-globalsperf-lazy-loadingperf-array-functionsperf-string-functionsperf-generatorssec-input-validationsec-output-escapingsec-password-hashingsec-sql-preparedsec-file-uploads<?php
declare(strict_types=1);
// Constructor promotion + readonly
class User
{
public function __construct(
public readonly string $id,
private string $email,
) {}
}
// Enums with methods
enum Status: string
{
case Active = 'active';
case Inactive = 'inactive';
public function label(): string
{
return match($this) {
self::Active => 'Active',
self::Inactive => 'Inactive',
};
}
}
// Match expression
$result = match($status) {
'pending' => 'Waiting',
'active' => 'Running',
default => 'Unknown',
};
// Nullsafe operator
$country = $user?->getAddress()?->getCountry();
// Arrow functions
$names = array_map(fn(User $u) => $u->name, $users);file:line - [category] Description of issuesrc/Services/UserService.php:15 - [type] Missing return type declaration
src/Models/Order.php:42 - [modern] Use match expression instead of switch
src/Controllers/ApiController.php:28 - [solid] Class has multiple responsibilitiesrules/modern-constructor-promotion.md
rules/type-strict-mode.md
rules/solid-single-responsibility.md