From 4afb553a9672f3851195a62cda639b4c0cf998c4 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Sun, 16 Aug 2026 00:53:43 -0400 Subject: [PATCH] simplify Dispatcher@mustUseContainer --- flight/core/Dispatcher.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/flight/core/Dispatcher.php b/flight/core/Dispatcher.php index 39a9be1..cf9fc39 100644 --- a/flight/core/Dispatcher.php +++ b/flight/core/Dispatcher.php @@ -495,18 +495,24 @@ class Dispatcher } /** - * Checks to see if a container should be used or not. + * Checks if the class must be resolved by the container. * - * @param string|object $class the class to verify - * - * @return boolean + * @deprecated This method will be removed. + * @param class-string|object $class Class name or object. */ public function mustUseContainer($class): bool { - return $this->containerHandler !== null && ( - (is_object($class) === true && strpos(get_class($class), 'flight\\') === false) - || is_string($class) - ); + $container = $this->containerHandler; + + if (is_object($class)) { + $class = get_class($class); + } + + if ($container instanceof Container && $container->has($class)) { + return true; + } + + return is_callable($container); } /** Fixes output buffering issues when an exception is thrown. */