From 0a67ef016937be775c7f8ba027301c343a9f154a Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Mon, 16 Dec 2024 22:47:24 +0300 Subject: [PATCH] Remove unnecessary code in `DefinitionStorage` (#101) Co-authored-by: Alexander Makarov --- CHANGELOG.md | 2 +- src/DefinitionStorage.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb38181..237541a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 3.3.1 under development -- no changes in this release. +- Enh #101: Minor performance improvement by removing unnecessary code in `DefinitionStorage` (@vjik) ## 3.3.0 March 16, 2024 diff --git a/src/DefinitionStorage.php b/src/DefinitionStorage.php index c9e0459..202cba8 100644 --- a/src/DefinitionStorage.php +++ b/src/DefinitionStorage.php @@ -135,7 +135,8 @@ private function isResolvable(string $id, array $building): bool $parameter = $dependency->getReflection(); $type = $parameter->getType(); - if ($parameter->isVariadic() || $parameter->isOptional()) { + // This condition covers variadic parameters, because variadic parameter is optional + if ($parameter->isOptional()) { /** @infection-ignore-all Mutation don't change behaviour, but degrade performance. */ break; }