Skip to content

Commit

Permalink
do not use reflection to instantiate objects, use new instead
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikbosch committed May 16, 2024
1 parent 149711e commit dc90cfc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/Resolver/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ public function merge(Blueprint $mergeBlueprint): Blueprint
/**
* Instantiates a new object based on the current blueprint.
*
* @param ReflectionClass $reflectedClass
*
* @return object
*/
public function __invoke(Resolver $resolver, ReflectionClass $reflectedClass): object
public function __invoke(Resolver $resolver): object
{
$object = $reflectedClass->newInstanceArgs(
array_map(
$className = $this->className;

$object = new $className(
...array_map(
function ($val) use ($resolver) {
// is the param missing?
if ($val instanceof UnresolvedParam) {
Expand Down
2 changes: 0 additions & 2 deletions src/Resolver/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ public function resolve(Blueprint $blueprint, array $contextualBlueprints = []):
return call_user_func(
$this->expandParams($this->getUnified($blueprint->getClassName())->merge($blueprint)),
$this,
$this->reflector->getClass($blueprint->getClassName())
);
}

Expand Down Expand Up @@ -255,7 +254,6 @@ public function resolve(Blueprint $blueprint, array $contextualBlueprints = []):
$resolved = call_user_func(
$this->expandParams($this->getUnified($blueprint->getClassName())->merge($blueprint)),
$this,
$this->reflector->getClass($blueprint->getClassName())
);

foreach ($contextualBlueprints as $contextualBlueprint) {
Expand Down

0 comments on commit dc90cfc

Please sign in to comment.