@@ -124,6 +124,8 @@ class Container extends Component
124124 /**
125125 * @var array cached dependencies indexed by class/interface names. Each class name
126126 * is associated with a list of constructor parameter types or default values.
127+ *
128+ * @phpstan-var array<class-string, array<string, mixed>>
127129 */
128130 private $ _dependencies = [];
129131 /**
@@ -386,10 +388,21 @@ public function getDefinitions()
386388 * @param array $config configurations to be applied to the new instance
387389 * @return object the newly created instance of the specified class
388390 * @throws NotInstantiableException If resolved to an abstract class or an interface (since 2.0.9)
391+ *
392+ * @template T of object
393+ *
394+ * @phpstan-param class-string<T> $class
395+ * @psalm-param class-string<T> $class
396+ *
397+ * @phpstan-return T
398+ * @psalm-return T
389399 */
390400 protected function build ($ class , $ params , $ config )
391401 {
392- /** @var ReflectionClass $reflection */
402+ /**
403+ * @var ReflectionClass $reflection
404+ * @phpstan-var ReflectionClass<T> $reflection
405+ */
393406 list ($ reflection , $ dependencies ) = $ this ->getDependencies ($ class );
394407
395408 $ addDependencies = [];
@@ -503,6 +516,14 @@ protected function mergeParams($class, $params)
503516 * @param string $class class name, interface name or alias name
504517 * @return array the dependencies of the specified class.
505518 * @throws NotInstantiableException if a dependency cannot be resolved or if a dependency cannot be fulfilled.
519+ *
520+ * @template T of object
521+ *
522+ * @phpstan-param class-string<T> $class
523+ * @psalm-param class-string<T> $class
524+ *
525+ * @phpstan-return array{ReflectionClass<T>, array<string, mixed>}
526+ * @psalm-return array{ReflectionClass<T>, array<string, mixed>}
506527 */
507528 protected function getDependencies ($ class )
508529 {
@@ -590,6 +611,9 @@ private function isNulledParam($param)
590611 * @param ReflectionClass|null $reflection the class reflection associated with the dependencies
591612 * @return array the resolved dependencies
592613 * @throws InvalidConfigException if a dependency cannot be resolved or if a dependency cannot be fulfilled.
614+ *
615+ * @phpstan-param ReflectionClass<object>|null $reflection
616+ * @psalm-param ReflectionClass<object>|null $reflection
593617 */
594618 protected function resolveDependencies ($ dependencies , $ reflection = null )
595619 {
0 commit comments