acc-create-null-object
Generates Null Object pattern for PHP 8.5. Creates safe default implementations eliminating null checks. Includes unit tests.
Best use case
acc-create-null-object is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Generates Null Object pattern for PHP 8.5. Creates safe default implementations eliminating null checks. Includes unit tests.
Teams using acc-create-null-object should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/acc-create-null-object/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How acc-create-null-object Compares
| Feature / Agent | acc-create-null-object | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Generates Null Object pattern for PHP 8.5. Creates safe default implementations eliminating null checks. Includes unit tests.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Null Object Pattern Generator
Creates Null Object pattern infrastructure for eliminating null checks.
## When to Use
| Scenario | Example |
|----------|---------|
| Optional dependencies | Logger, Cache, Notifier |
| Missing entities | Customer, User, Product |
| Feature toggles | Disabled feature returns null object |
| Default implementations | No-op defaults |
## Component Characteristics
### Interface
- Defines expected behavior
- Shared by real and null implementations
- Enables polymorphic usage
### Null Object
- Implements interface with no-op behavior
- Returns neutral values
- Never throws on calls
### Benefits
- Eliminates null checks
- Follows Liskov Substitution
- Simplifies client code
---
## Generation Process
### Step 1: Generate Interface
**Path:** `src/Domain/{BoundedContext}/`
1. `{Name}Interface.php` — Interface with `isNull()` method
### Step 2: Generate Null Object
**Path:** `src/Domain/{BoundedContext}/`
1. `Null{Name}.php` — Null implementation returning neutral values
### Step 3: Generate Real Implementation
**Path:** `src/Domain/{BoundedContext}/`
1. `{Name}.php` — Real implementation with business logic
### Step 4: Generate Tests
1. `Null{Name}Test.php` — Null object behavior tests
---
## File Placement
| Component | Path |
|-----------|------|
| Interface | `src/Domain/{BoundedContext}/` |
| Null Object | `src/Domain/{BoundedContext}/` |
| Real Implementation | `src/Domain/{BoundedContext}/` |
| Unit Tests | `tests/Unit/Domain/{BoundedContext}/` |
---
## Naming Conventions
| Component | Pattern | Example |
|-----------|---------|---------|
| Interface | `{Name}Interface` | `CustomerInterface` |
| Real Implementation | `{Name}` | `Customer` |
| Null Object | `Null{Name}` | `NullCustomer` |
| Test | `{ClassName}Test` | `NullCustomerTest` |
---
## Neutral Return Values
| Type | Neutral Value |
|------|---------------|
| `string` | `''` (empty string) |
| `int` | `0` |
| `float` | `0.0` |
| `bool` | `false` |
| `array` | `[]` |
| `void` | No return |
| Object | Empty/default instance |
| Collection | Empty collection |
---
## Quick Template Reference
### Interface
```php
interface {Name}Interface
{
public function {method1}(): {returnType1};
public function {method2}({params}): {returnType2};
public function isNull(): bool;
}
```
### Null Object
```php
final readonly class Null{Name} implements {Name}Interface
{
public function {method1}(): {returnType1}
{
return {neutralValue1};
}
public function isNull(): bool
{
return true;
}
}
```
### Real Implementation
```php
final readonly class {Name} implements {Name}Interface
{
public function __construct({properties}) {}
public function {method1}(): {returnType1}
{
return {realImplementation};
}
public function isNull(): bool
{
return false;
}
}
```
---
## Usage Example
### Repository Returning Null Object
```php
final readonly class DoctrineCustomerRepository implements CustomerRepositoryInterface
{
public function findById(CustomerId $id): CustomerInterface
{
$row = $this->connection->fetchAssociative(
'SELECT * FROM customers WHERE id = :id',
['id' => $id->toString()]
);
if ($row === false) {
return new NullCustomer();
}
return $this->hydrate($row);
}
}
```
### Client Code Without Null Checks
```php
final readonly class CreateOrderUseCase
{
public function execute(CreateOrderCommand $command): Order
{
$customer = $this->customers->findById($command->customerId);
// No null check needed - NullCustomer returns 0.0
$discount = $customer->getDiscount();
$order = Order::create(
customerId: $customer->id(),
items: $command->items,
discount: $discount
);
return $order;
}
}
```
---
## Anti-patterns to Avoid
| Anti-pattern | Problem | Solution |
|--------------|---------|----------|
| Throwing in Null | Unexpected exceptions | Return neutral values |
| No `isNull()` | Can't detect null object | Add isNull method |
| Different Interface | LSP violation | Same interface as real |
| Side Effects | Unexpected behavior | Pure no-op methods |
| Complex Logic | Not a null object | Keep simple and neutral |
---
## References
For complete PHP templates and examples, see:
- `references/templates.md` — Interface, NullObject, Real Implementation, NullLogger, NullCache templates
- `references/examples.md` — NullCustomer, NullNotifier, Repository integration examples and testsRelated Skills
accessibility-object-model-integration
Programmatic manipulation of the accessibility tree to support complex custom controls in React.
acc-create-value-object
Generates DDD Value Objects for PHP 8.5. Creates immutable, self-validating objects with equality comparison. Includes unit tests.
acc-create-use-case
Generates Application Use Cases for PHP 8.5. Creates orchestration services that coordinate domain objects, handle transactions, and dispatch events. Includes unit tests.
acc-create-unit-test
Generates PHPUnit unit tests for PHP 8.5. Creates isolated tests with AAA pattern, proper naming, attributes, and one behavior per test. Supports Value Objects, Entities, Services.
acc-create-test-double
Generates test doubles (Mocks, Stubs, Fakes, Spies) for PHP 8.5. Creates appropriate double type based on testing needs with PHPUnit MockBuilder patterns.
acc-create-test-builder
Generates Test Data Builder and Object Mother patterns for PHP 8.5. Creates fluent builders with sensible defaults and factory methods for test data creation.
acc-create-strategy
Generates Strategy pattern for PHP 8.5. Creates interchangeable algorithm families with context class, strategy interface, and concrete implementations. Includes unit tests.
acc-create-state
Generates State pattern for PHP 8.5. Creates state machines with context, state interface, and concrete states for behavior changes. Includes unit tests.
acc-create-specification
Generates DDD Specification for PHP 8.5. Creates reusable business rule objects for validation, filtering, and querying with composite pattern support. Includes unit tests.
acc-create-saga-pattern
Generates Saga pattern components for PHP 8.5. Creates Saga interfaces, steps, orchestrator, state management, and compensation logic with unit tests.
acc-create-retry-pattern
Generates Retry pattern for PHP 8.5. Creates resilience component with exponential backoff, jitter, and configurable retry strategies. Includes unit tests.
acc-create-responder
Generates ADR Responder classes for PHP 8.5. Creates HTTP response builders with PSR-7/PSR-17 support. Includes unit tests.