Master backend architectures, REST API design, microservices, and server-side development across multiple languages. Use this as a central index to access specialized sub-skills.
中文简介正在准备中。当前显示原文说明。
Generates Null Object pattern for PHP 8.5. Creates safe default implementations eliminating null checks. Includes unit tests.
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
Creates Null Object pattern infrastructure for eliminating null checks.
| Scenario | Example |
|---|---|
| Optional dependencies | Logger, Cache, Notifier |
| Missing entities | Customer, User, Product |
| Feature toggles | Disabled feature returns null object |
| Default implementations | No-op defaults |
Path: src/Domain/{BoundedContext}/
{Name}Interface.php — Interface with isNull() methodPath: src/Domain/{BoundedContext}/
Null{Name}.php — Null implementation returning neutral valuesPath: src/Domain/{BoundedContext}/
{Name}.php — Real implementation with business logicNull{Name}Test.php — Null object behavior tests| Component | Path |
|---|---|
| Interface | src/Domain/{BoundedContext}/ |
| Null Object | src/Domain/{BoundedContext}/ |
| Real Implementation | src/Domain/{BoundedContext}/ |
| Unit Tests | tests/Unit/Domain/{BoundedContext}/ |
| Component | Pattern | Example |
|---|---|---|
| Interface | {Name}Interface | CustomerInterface |
| Real Implementation | {Name} | Customer |
| Null Object | Null{Name} | NullCustomer |
| Test | {ClassName}Test | NullCustomerTest |
| Type | Neutral Value |
|---|---|
string | '' (empty string) |
int | 0 |
float | 0.0 |
bool | false |
array | [] |
void | No return |
| Object | Empty/default instance |
| Collection | Empty collection |
interface {Name}Interface
{
public function {method1}(): {returnType1};
public function {method2}({params}): {returnType2};
public function isNull(): bool;
}
final readonly class Null{Name} implements {Name}Interface
{
public function {method1}(): {returnType1}
{
return {neutralValue1};
}
public function isNull(): bool
{
return true;
}
}
final readonly class {Name} implements {Name}Interface
{
public function __construct({properties}) {}
public function {method1}(): {returnType1}
{
return {realImplementation};
}
public function isNull(): bool
{
return false;
}
}
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);
}
}
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-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 |
For complete PHP templates and examples, see:
references/templates.md — Interface, NullObject, Real Implementation, NullLogger, NullCache templatesreferences/examples.md — NullCustomer, NullNotifier, Repository integration examples and tests还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Master backend architectures, REST API design, microservices, and server-side development across multiple languages. Use this as a central index to access specialized sub-skills.
中文简介正在准备中。当前显示原文说明。
在每次回复中使用固定前缀并列出本次实际参考的指令/文件,便于校验是否遵循上下文与规则。
中文简介正在准备中。当前显示原文说明。
Automate 21risk tasks via Rube MCP (Composio). Always search tools first for current schemas.
中文简介正在准备中。当前显示原文说明。
Automate 2chat tasks via Rube MCP (Composio). Always search tools first for current schemas.
中文简介正在准备中。当前显示原文说明。
Arquitecto de Soluciones Principal y Consultor Tecnológico de Andru.ia. Diagnostica y traza la hoja de ruta óptima para proyectos de IA en español.
中文简介正在准备中。当前显示原文说明。
[00] META. Orchestrate skills into dynamic chains for complex tasks. Analyzes the task, discovers available skills, builds an optimal chain, explains why each skill is needed, and executes step-by-step with user confirmation. Use for any complex task requiring multiple thinking/research/analysis steps. Triggers on "plan this", "how to approach", "what's the strategy", "build a plan", or any multi-step problem requiring skill orchestration.
中文简介正在准备中。当前显示原文说明。