-
Notifications
You must be signed in to change notification settings - Fork 1
Add BDR factory and PostFetch layers to WebQuery #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
05a60b7
Add BDR factory and PostFetch layers to WebQuery
koriym dc368fe
Document BDR factory and PostFetch in README
koriym cda875b
Drop WebFetchClass in favor of constructor-only hydration
koriym 2d728d3
Reject entities without a constructor explicitly
koriym e63fe1f
Replace PDO-shaped fetch classes with a single web-native mapper
koriym 770e07f
Rename invokeLegacy to rawResponse
koriym 46450d1
Bind DocBlockFactoryInterface in the web module
koriym d1eddba
Widen reflection-docblock constraint to ^5.3 || ^6.0
koriym b853968
Cover the remaining response-mapping branches
koriym 2349318
Clarify isRow doc comment: union means nullable T|null
koriym File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Ray\MediaQuery\Exception; | ||
|
|
||
| /** | ||
| * Thrown when an entity class has no constructor. | ||
| * | ||
| * The Web layer hydrates entities through constructor named arguments, so a | ||
| * class without a constructor cannot receive the response data. | ||
| */ | ||
| final class EntityWithoutConstructorException extends LogicException | ||
| { | ||
| /** @param string $entity Entity class name. */ | ||
| public function __construct(string $entity) | ||
| { | ||
| parent::__construct("Entity '{$entity}' has no constructor; constructor hydration requires one"); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Ray\MediaQuery\Exception; | ||
|
|
||
| /** | ||
| * Thrown when the return-type entity class cannot be found. | ||
| */ | ||
| final class InvalidWebEntityException extends LogicException | ||
| { | ||
| public function __construct(string $entity) | ||
| { | ||
| parent::__construct("Entity class not found: {$entity}"); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Ray\MediaQuery\Exception; | ||
|
|
||
| /** | ||
| * Thrown when #[WebQuery(factory: ...)] points to a class or method that is | ||
| * neither a static method nor a class resolvable via DI. | ||
| */ | ||
| final class InvalidWebFactoryException extends LogicException | ||
| { | ||
| public function __construct(string $factory, string $method) | ||
| { | ||
| parent::__construct( | ||
| "Factory '{$factory}::{$method}()' is not callable; provide a static method or a class resolvable via DI", | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Ray\MediaQuery\Exception; | ||
|
|
||
| use function implode; | ||
|
|
||
| /** | ||
| * Thrown when a required constructor or factory parameter is absent from the | ||
| * decoded HTTP response. | ||
| */ | ||
| final class MissingResponseKeyException extends LogicException | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| { | ||
| /** | ||
| * @param string $target Target being built, e.g. "App\Product::__construct". | ||
| * @param string $missingParam The parameter that was not found. | ||
| * @param list<string> $availableKeys Keys present in the response. | ||
| */ | ||
| public function __construct(string $target, string $missingParam, array $availableKeys) | ||
| { | ||
| $available = implode(', ', $availableKeys); | ||
| parent::__construct( | ||
| "'{$target}' requires parameter '{$missingParam}' but it was not found in response keys: [{$available}]", | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Ray\MediaQuery; | ||
|
|
||
| use Ray\MediaQuery\Annotation\WebQuery; | ||
|
|
||
| /** | ||
| * Value object passed to PostFetchInterface::fromContext(). | ||
| * | ||
| * Carries the fetch result, the original method arguments, and the | ||
| * #[WebQuery] annotation so that post-processors have full context. | ||
| */ | ||
| final class PostFetchContext | ||
| { | ||
| /** | ||
| * @param mixed $result Output of fetchRow() or fetchAll(). | ||
| * @param array<string, string> $query Method arguments passed to the interceptor. | ||
| * @param WebQuery $webQuery The annotation (id, type, factory). | ||
| */ | ||
| public function __construct( | ||
| public readonly mixed $result, | ||
| public readonly array $query, | ||
| public readonly WebQuery $webQuery, | ||
| ) { | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Ray\MediaQuery; | ||
|
|
||
| /** | ||
| * Implemented by return-type classes that wish to post-process fetch results. | ||
| * | ||
| * The static named constructor receives all context produced by the fetch layer | ||
| * and returns a fully formed domain object — no DI involved. | ||
| * | ||
| * Analogous to PostQueryInterface in ray/media-query, but for the Web layer | ||
| * where a single HTTP request replaces multiple SQL statements. | ||
| */ | ||
| interface PostFetchInterface | ||
| { | ||
| public static function fromContext(PostFetchContext $context): static; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.