Skip to content

Commit

Permalink
minor #34308 [Security] Avoid unnecessary usage of Reflection (chalasr)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.4 branch.

Discussion
----------

[Security] Avoid unnecessary usage of Reflection

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Commits
-------

2377418 [Security] Avoid unnecessary usage of Reflection
  • Loading branch information
chalasr committed Nov 9, 2019
2 parents 36041a8 + 2377418 commit d5ba535
Showing 1 changed file with 1 addition and 3 deletions.
Expand Up @@ -78,9 +78,7 @@ private function createEncoder(array $config, bool $isExtra = false): PasswordEn
throw new \InvalidArgumentException(sprintf('"arguments" must be set in %s.', json_encode($config)));
}

$reflection = new \ReflectionClass($config['class']);

$encoder = $reflection->newInstanceArgs($config['arguments']);
$encoder = new $config['class'](...$config['arguments']);

if ($isExtra || !\in_array($config['class'], [NativePasswordEncoder::class, SodiumPasswordEncoder::class], true)) {
return $encoder;
Expand Down

0 comments on commit d5ba535

Please sign in to comment.