php-conventions

Installation
SKILL.md

PHP Conventions

These are non-negotiable personal conventions unless explicitly overridden by the user.

Language & Syntax

  • Strict types — Every PHP file must declare declare(strict_types=1); at the top. If it is an existing file or extracting legacy code (which may depend on type-juggling) into a new file, you do not need to add it, but mention it to the user.

  • Prefer explicit falsy checks — Use the narrowest comparison that matches the real condition, such as === null, === '', or === 0, instead of broad checks like if (! $someValue). Negation is fine when the value is genuinely bool (for example, if (! $isEnabled)). This avoids surprising type coercion and makes intent clearer to humans and tools. Though using empty() is not preferred, it is better than writing methods like this:

    // Unnecessary code, don't do this:
    public function isNonEmptyEmail(?string $email): bool
    {
        return $email !== null && $email !== '';
    }
    
Installs
23
GitHub Stars
5
First Seen
Apr 4, 2026
php-conventions — cosmastech/skills