public function execute(ContainerInterface $app) { try { $app->inject($this->test); } catch (CannotInjectException $exception) { $propertyName = $exception->getProperty(); $className = $exception->getClass(); if (class_exists($className)) { $app->inject($this->test, [$propertyName => $app->create($className)]); } else { throw $exception; } } }