Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ will not run under Ray.Di or will break framework expectations.
8. **Reason services**: always define an `…Interface` and depend on the
interface, never the concrete class. Ray.Di binds the implementation.
9. **Namespaces**: follow the existing per-demo pattern
(`Be\Pattern\<Name>\<Layer>\…` or `Be\App\<Layer>\…`). Never invent a new
root namespace.
`Be\Pattern\<Name>\<Layer>\…`. Never invent a new root namespace.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
10. **No side effects in Beings.** A Being transforms data; external I/O
belongs in an injected Reason service.

Expand All @@ -119,9 +118,10 @@ will not run under Ray.Di or will break framework expectations.
## 5. Templates

Copy-pasteable minimal skeletons for every layer live in
[`docs/templates/`](./docs/templates/). They are intentionally outside any
Composer autoload scope (`namespace Be\Template;`) so they do not pollute demo
class maps.
[`docs/templates/`](./docs/templates/). They are intentionally outside Composer
autoload scope and use placeholder namespaces of the form
`Be\Pattern\Template\<Layer>;` — mirror that shape when copying a template into
a real demo (replace `Template` with the actual demo name).

---

Expand Down
6 changes: 3 additions & 3 deletions demos/order-processing/bin/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace Be\App;
namespace Be\Pattern\OrderProcessing;

require dirname(__DIR__) . '/vendor/autoload.php';

use Be\App\Input\OrderInput;
use Be\App\Module\AppModule;
use Be\Pattern\OrderProcessing\Input\OrderInput;
use Be\Pattern\OrderProcessing\Module\AppModule;
use Be\Framework\Becoming;
use Be\Framework\Exception\SemanticVariableException;
use Ray\Di\Injector;
Expand Down
6 changes: 3 additions & 3 deletions demos/order-processing/composer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "be-framework/app",
"name": "be-framework/demo-order-processing",
"type": "project",
"autoload": {
"psr-4": {
"Be\\App\\": "src/"
"Be\\Pattern\\OrderProcessing\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Be\\App\\Tests\\": "tests/"
"Be\\Pattern\\OrderProcessing\\Tests\\": "tests/"
}
},
"require": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

declare(strict_types=1);

namespace Be\App;
namespace Be\Pattern\OrderProcessing;

// ═══════════════════════════════════════════════════════════════════════════
// INPUT - The starting point (Aristotle's Dynamis - Potentiality)
Expand Down
2 changes: 1 addition & 1 deletion demos/order-processing/src/Attribute/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Attribute;
namespace Be\Pattern\OrderProcessing\Attribute;

use Attribute;
use Ray\Di\Di\Qualifier;
Expand Down
2 changes: 1 addition & 1 deletion demos/order-processing/src/Attribute/Amount.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Attribute;
namespace Be\Pattern\OrderProcessing\Attribute;

use Attribute;
use Ray\Di\Di\Qualifier;
Expand Down
2 changes: 1 addition & 1 deletion demos/order-processing/src/Attribute/AuthorizationCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Attribute;
namespace Be\Pattern\OrderProcessing\Attribute;

use Attribute;
use Ray\Di\Di\Qualifier;
Expand Down
2 changes: 1 addition & 1 deletion demos/order-processing/src/Attribute/CardNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Attribute;
namespace Be\Pattern\OrderProcessing\Attribute;

use Attribute;
use Ray\Di\Di\Qualifier;
Expand Down
2 changes: 1 addition & 1 deletion demos/order-processing/src/Attribute/CarrierId.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Attribute;
namespace Be\Pattern\OrderProcessing\Attribute;

use Attribute;
use Ray\Di\Di\Qualifier;
Expand Down
2 changes: 1 addition & 1 deletion demos/order-processing/src/Attribute/ProductId.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Attribute;
namespace Be\Pattern\OrderProcessing\Attribute;

use Attribute;
use Ray\Di\Di\Qualifier;
Expand Down
2 changes: 1 addition & 1 deletion demos/order-processing/src/Attribute/Quantity.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Attribute;
namespace Be\Pattern\OrderProcessing\Attribute;

use Attribute;
use Ray\Di\Di\Qualifier;
Expand Down
2 changes: 1 addition & 1 deletion demos/order-processing/src/Attribute/WarehouseId.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Attribute;
namespace Be\Pattern\OrderProcessing\Attribute;

use Attribute;
use Ray\Di\Di\Qualifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

namespace Be\App\Being\Inventory;
namespace Be\Pattern\OrderProcessing\Being\Inventory;

use Ray\InputQuery\Attribute\Input;
use Ray\Di\Di\Inject;
use Be\App\Reason\InventoryChecker;
use Be\Pattern\OrderProcessing\Reason\InventoryChecker;

final readonly class QuantityChecked
{
Expand Down
4 changes: 2 additions & 2 deletions demos/order-processing/src/Being/Inventory/StockLocated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

namespace Be\App\Being\Inventory;
namespace Be\Pattern\OrderProcessing\Being\Inventory;

use Ray\InputQuery\Attribute\Input;
use Ray\Di\Di\Inject;
use Be\App\Reason\WarehouseLocator;
use Be\Pattern\OrderProcessing\Reason\WarehouseLocator;

final readonly class StockLocated
{
Expand Down
4 changes: 2 additions & 2 deletions demos/order-processing/src/Being/Payment/CardValidated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

namespace Be\App\Being\Payment;
namespace Be\Pattern\OrderProcessing\Being\Payment;

use Ray\InputQuery\Attribute\Input;
use Ray\Di\Di\Inject;
use Be\App\Reason\CardValidator;
use Be\Pattern\OrderProcessing\Reason\CardValidator;

final readonly class CardValidated
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace Be\App\Being\Payment;
namespace Be\Pattern\OrderProcessing\Being\Payment;

use Be\App\Moment\Potential\PaymentCapture;
use Be\App\Reason\PaymentGateway;
use Be\Pattern\OrderProcessing\Moment\Potential\PaymentCapture;
use Be\Pattern\OrderProcessing\Reason\PaymentGateway;
use Ray\Di\Di\Inject;
Comment on lines +8 to 9

@coderabbitai coderabbitai Bot Apr 16, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify concrete-vs-interface usage for PaymentGateway in source.
rg -nP 'use\s+Be\\Pattern\\OrderProcessing\\Reason\\PaymentGateway(;|\s)' demos/order-processing/src
rg -nP '#\[Inject\]\s+PaymentGateway\b' demos/order-processing/src
rg -nP 'bind\(PaymentGatewayInterface::class\)\s*->\s*to\(PaymentGateway::class\)' demos/order-processing/src/Module/AppModule.php

Repository: be-framework/be-patterns

Length of output: 483


Depend on PaymentGatewayInterface instead of the concrete PaymentGateway class.

Reason services must depend on their interface contract, never the concrete implementation. Ray.Di handles binding the interface to the implementation.

Proposed fix
-use Be\Pattern\OrderProcessing\Reason\PaymentGateway;
+use Be\Pattern\OrderProcessing\Reason\PaymentGatewayInterface;
-        #[Inject] PaymentGateway $gateway,
+        #[Inject] PaymentGatewayInterface $gateway,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@demos/order-processing/src/Being/Payment/PaymentAuthorized.php` around lines
8 - 9, The class in PaymentAuthorized.php currently depends on the concrete
PaymentGateway class; change the dependency to the interface by replacing any
use/import of Be\Pattern\OrderProcessing\Reason\PaymentGateway with the
corresponding PaymentGatewayInterface and update constructor/property/type-hints
in PaymentAuthorized (e.g., constructor parameter or property named
paymentGateway) to type-hint PaymentGatewayInterface so Ray.Di can bind the
interface to its implementation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CodeRabbit Out of scope for this PR — this is a pre-existing issue (file unchanged apart from the namespace rename). All six Beings in order-processing inject concrete Reason classes instead of interfaces; worth a follow-up PR to convert them together for consistency.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@koriym, understood — agreed that a batch fix across all six Beings is cleaner than touching just one in a rename-only PR. Would you like me to open a GitHub issue to track the follow-up work of replacing all concrete Reason class injections with their corresponding interfaces in the order-processing Beings?


🧠 Learnings used
Learnt from: CR
Repo: be-framework/be-patterns PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-15T07:51:02.660Z
Learning: Applies to demos/*/src/Reason/*.php : Reason services MUST always define an `…Interface` and depend on the interface, never the concrete class. Ray.Di binds the implementation.

Learnt from: CR
Repo: be-framework/be-patterns PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-15T07:51:02.660Z
Learning: Applies to demos/*/src/Being/*.php : Do not make a Being that reaches into a database directly. Put the I/O in a `Reason` interface, inject it, and keep the Being a pure transformation.

Learnt from: CR
Repo: be-framework/be-patterns PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-15T07:51:02.660Z
Learning: Applies to demos/*/src/Being/*.php : No side effects in Beings. A Being transforms data; external I/O belongs in an injected Reason service.

Learnt from: koriym
Repo: be-framework/be-patterns PR: 11
File: docs/templates/MomentTemplate.php:0-0
Timestamp: 2026-04-15T03:35:41.350Z
Learning: In the `be-patterns` repository, `Be\App\<Layer>` is reserved exclusively for the canonical "production-like alternative" comparison example at `demos/order-processing/docs/comparison/After_BeFramework.php`. Template/skeleton files under `docs/templates/` must NOT use `Be\App\<Layer>` as their namespace, to avoid shadowing that exemplar. Instead, template files use `Be\Demo\Template\<Layer>` (with `Template` standing in for the demo name), mirroring the `Be\Demo\<Name>\<Layer>` pattern. This convention is intentional for teaching clarity.

Learnt from: koriym
Repo: be-framework/be-patterns PR: 11
File: docs/templates/BeingTemplate.php:0-0
Timestamp: 2026-04-15T03:35:29.572Z
Learning: In be-framework/be-patterns, treat the namespace prefix `Be\App\<Layer>` as reserved and use it only for the “production-like alternative” pedagogical example found in `demos/order-processing/docs/comparison/After_BeFramework.php`. Do not use `Be\App\<Layer>` in other files (e.g., template skeletons or documentation examples) because it will blur the intended pedagogical distinction.

Learnt from: CR
Repo: be-framework/be-patterns PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-15T07:51:02.660Z
Learning: Applies to demos/**/*.php : Use namespaces following the per-demo pattern (`Be\Pattern\<Name>\<Layer>\…` or `Be\App\<Layer>\…`). Never invent a new root namespace.

Learnt from: koriym
Repo: be-framework/be-patterns PR: 11
File: docs/templates/BeingTemplate.php:0-0
Timestamp: 2026-04-15T03:35:36.320Z
Learning: In the be-patterns repository (PHP, BE Framework), template skeleton files under `docs/templates/` use `Be\Demo\Template\<Layer>` as their placeholder namespace (e.g., `Be\Demo\Template\Being`, `Be\Demo\Template\Final`). This mirrors the `Be\Demo\<Name>\<Layer>` pattern with `Template` standing in for the demo name, per the TODO comment instructing readers to replace it when copying into a real demo.

use Ray\InputQuery\Attribute\Input;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

namespace Be\App\Being\Shipping;
namespace Be\Pattern\OrderProcessing\Being\Shipping;

use Ray\InputQuery\Attribute\Input;
use Ray\Di\Di\Inject;
use Be\App\Reason\AddressValidator;
use Be\Pattern\OrderProcessing\Reason\AddressValidator;

final readonly class AddressValidated
{
Expand Down
4 changes: 2 additions & 2 deletions demos/order-processing/src/Being/Shipping/CarrierSelected.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

namespace Be\App\Being\Shipping;
namespace Be\Pattern\OrderProcessing\Being\Shipping;

use Ray\InputQuery\Attribute\Input;
use Ray\Di\Di\Inject;
use Be\App\Reason\CarrierSelector;
use Be\Pattern\OrderProcessing\Reason\CarrierSelector;

final readonly class CarrierSelected
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Exception;
namespace Be\Pattern\OrderProcessing\Exception;

use Be\Framework\Attribute\Message;
use DomainException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Exception;
namespace Be\Pattern\OrderProcessing\Exception;

use Be\Framework\Attribute\Message;
use DomainException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Exception;
namespace Be\Pattern\OrderProcessing\Exception;

use Be\Framework\Attribute\Message;
use DomainException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Exception;
namespace Be\Pattern\OrderProcessing\Exception;

use Be\Framework\Attribute\Message;
use DomainException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Exception;
namespace Be\Pattern\OrderProcessing\Exception;

use Be\Framework\Attribute\Message;
use DomainException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Exception;
namespace Be\Pattern\OrderProcessing\Exception;

use Be\Framework\Attribute\Message;
use DomainException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Exception;
namespace Be\Pattern\OrderProcessing\Exception;

use Be\Framework\Attribute\Message;
use DomainException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Exception;
namespace Be\Pattern\OrderProcessing\Exception;

use Be\Framework\Attribute\Message;
use DomainException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Exception;
namespace Be\Pattern\OrderProcessing\Exception;

use Be\Framework\Attribute\Message;
use DomainException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Exception;
namespace Be\Pattern\OrderProcessing\Exception;

use Be\Framework\Attribute\Message;
use DomainException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Exception;
namespace Be\Pattern\OrderProcessing\Exception;

use Be\Framework\Attribute\Message;
use DomainException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Exception;
namespace Be\Pattern\OrderProcessing\Exception;

use Be\Framework\Attribute\Message;
use DomainException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Exception;
namespace Be\Pattern\OrderProcessing\Exception;

use Be\Framework\Attribute\Message;
use DomainException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Exception;
namespace Be\Pattern\OrderProcessing\Exception;

use Be\Framework\Attribute\Message;
use DomainException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Be\App\Exception;
namespace Be\Pattern\OrderProcessing\Exception;

use Be\Framework\Attribute\Message;
use DomainException;
Expand Down
8 changes: 4 additions & 4 deletions demos/order-processing/src/Final/OrderConfirmed.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

namespace Be\App\Final;
namespace Be\Pattern\OrderProcessing\Final;

use Be\App\Moment\InventoryReserved;
use Be\App\Moment\PaymentCompleted;
use Be\App\Moment\ShippingArranged;
use Be\Pattern\OrderProcessing\Moment\InventoryReserved;
use Be\Pattern\OrderProcessing\Moment\PaymentCompleted;
use Be\Pattern\OrderProcessing\Moment\ShippingArranged;
use Ray\Di\Di\Inject;

/**
Expand Down
4 changes: 2 additions & 2 deletions demos/order-processing/src/Input/OrderInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Be\App\Input;
namespace Be\Pattern\OrderProcessing\Input;

use Be\App\Final\OrderConfirmed;
use Be\Pattern\OrderProcessing\Final\OrderConfirmed;
use Be\Framework\Attribute\Be;

/**
Expand Down
Loading
Loading