From d0b3be9be781291dfbc149904f068a5e9a93e677 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 15 Dec 2024 22:26:07 +0300 Subject: [PATCH] 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; }