PHP Null Object Pattern Generator
Generates production-grade Null Object pattern implementations for PHP 8.4 to eliminate repetitive null checks and improve code safety.
This skill automates the creation of the Null Object design pattern within PHP applications, specifically tailored for Domain-Driven Design (DDD) and Clean Architecture contexts. It generates a unified interface with an isNull() method, a safe 'no-op' null implementation with appropriate neutral return values, a real implementation scaffold, and corresponding unit tests. By replacing null return values with polymorphic objects, it helps developers write cleaner, more robust code that strictly follows the Liskov Substitution Principle and eliminates defensive programming boilerplate.
Características Principales
01Smart neutral return value mapping for all standard PHP types
02DDD-compliant directory structure and naming convention enforcement
03Automated generation of PHP 8.4 interfaces and implementations
04Automated PHPUnit test generation for the Null implementation
05Standardized isNull() method implementation for explicit state checking
0645 GitHub stars
Casos de Uso
01Handling missing domain entities in repositories to avoid null pointer exceptions
02Implementing safe default behaviors for feature toggles and optional modules
03Replacing null checks for optional dependencies like Loggers, Notifiers, or Cachers