getType(); if (! $type instanceof ReflectionNamedType || $type->isBuiltin()) { return null; } $name = $type->getName(); if (! is_null($class = $parameter->getDeclaringClass())) { if ($name === 'self') { return $class->getName(); } if ($name === 'parent' && $parent = $class->getParentClass()) { return $parent->getName(); } } return $name; } /** * Get a contextual attribute from a dependency. * * @param \ReflectionParameter $dependency * @return \ReflectionAttribute|null */ public static function getContextualAttributeFromDependency($dependency) { return $dependency->getAttributes(ContextualAttribute::class, ReflectionAttribute::IS_INSTANCEOF)[0] ?? null; } }