-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce custom transformers (#10)
- Loading branch information
Showing
32 changed files
with
759 additions
and
89 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
* Allows to retrieve a mapper. | ||
* | ||
* @author Joel Wurtz <[email protected]> | ||
* | ||
* @internal | ||
*/ | ||
interface AutoMapperRegistryInterface | ||
{ | ||
|
This file contains 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 |
---|---|---|
|
@@ -16,12 +16,15 @@ | |
use PhpParser\ParserFactory; | ||
|
||
/** | ||
* Extracts the code of the given method from a given class and wraps it inside a closure, in order to inject it | ||
* in the generated mappers. | ||
* | ||
* @author Nicolas Philippe <[email protected]> | ||
* @author Baptiste Leduc <[email protected]> | ||
* | ||
* @internal | ||
*/ | ||
final readonly class AstExtractor | ||
final readonly class ClassMethodToCallbackExtractor | ||
{ | ||
private Parser $parser; | ||
|
||
|
@@ -31,9 +34,6 @@ public function __construct(?Parser $parser = null) | |
} | ||
|
||
/** | ||
* Extracts the code of the given method from a given class, and wraps it inside a closure, in order to inject it | ||
* in the generated mappers. | ||
* | ||
* @param class-string $class | ||
* @param Arg[] $inputParameters | ||
*/ | ||
|
@@ -63,16 +63,6 @@ public function extract(string $class, string $method, array $inputParameters): | |
throw new InvalidArgumentException("Input parameters and method parameters in class \"{$class}\" do not match."); | ||
} | ||
|
||
foreach ($classMethod->getParams() as $key => $parameter) { | ||
/** @var Expr\Variable $inputParameterValue */ | ||
$inputParameterValue = $inputParameters[$key]->value; | ||
|
||
if ($parameter->var instanceof Expr\Variable && $inputParameterValue->name !== $parameter->var->name) { | ||
$parameterName = \is_string($parameter->var->name) ? $parameter->var->name : 'N/A'; | ||
throw new InvalidArgumentException("Method parameter \"{$parameterName}\" does not match type \"{$inputParameters[$key]->getType()}\" from input parameter \"{$inputParameters[$key]->name}\" in \"{$class}::{$method}\" method."); | ||
} | ||
} | ||
|
||
$closureParameters = []; | ||
foreach ($classMethod->getParams() as $parameter) { | ||
if ($parameter->var instanceof Expr\Variable && $parameter->type instanceof Identifier) { | ||
|
This file contains 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 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 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 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 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
Oops, something went wrong.