From d0b3be9be781291dfbc149904f068a5e9a93e677 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 15 Dec 2024 22:26:07 +0300 Subject: [PATCH 1/2] Remove unnecessary code in `DefinitionStorage` --- CHANGELOG.md | 2 +- src/DefinitionStorage.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb38181..1cef151 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 remove 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; } From b211831c71ee3762e19a6f86b2d926c61e4f5f27 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Mon, 16 Dec 2024 22:38:14 +0300 Subject: [PATCH 2/2] Update CHANGELOG.md Co-authored-by: Alexander Makarov --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cef151..237541a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 3.3.1 under development -- Enh #101: Minor performance improvement by remove unnecessary code in `DefinitionStorage` (@vjik) +- Enh #101: Minor performance improvement by removing unnecessary code in `DefinitionStorage` (@vjik) ## 3.3.0 March 16, 2024