/** * @param \Donquixote\HastyReflectionCommon\NamespaceUseContext\NamespaceUseContextInterface $namespaceUseContext * @param \Donquixote\HastyPhpAst\Ast\ClassLike\AstClassLikeInterface $astNode * @param \Donquixote\HastyReflectionCommon\Canvas\ClassIndex\ClassIndexInterface $classIndex * * @return \Donquixote\HastyReflectionCommon\Reflection\ClassLike\ClassLikeReflectionInterface */ static function create(NamespaceUseContextInterface $namespaceUseContext, AstClassLikeInterface $astNode, ClassIndexInterface $classIndex) { $declaration = new Declaration($astNode->getDocComment(), $namespaceUseContext); $name = NULL !== ($namespace = $namespaceUseContext->getNamespaceName()) ? $namespace . '\\' . $astNode->getShortName() : $astNode->getShortName(); $header = new ClassLikeHeader_Ast($name, $astNode); $extends = ClassExtends_Ast::createFromAst($astNode, $classIndex, $namespaceUseContext); $ownInterfaces = OwnInterfaces_Ast::createFromAst($astNode, $classIndex, $namespaceUseContext); $interfacesAll = new AllInterfaces_FromOwn($extends, $ownInterfaces); if ($header->isInterface()) { $interfacesAll = $interfacesAll->withSelfInterfaceName($name, $classIndex); } $ownBody = new OwnBody_Ast($astNode->getBody(), $classIndex, $name); $body = ClassLikeBody_Composite::createFromOwnBody($extends, $interfacesAll, $ownBody); return new ClassLikeReflection_Composite($declaration, $header, $extends, $interfacesAll, $ownInterfaces, $body); }
/** * @param string $name * @param \ReflectionClass $reflectionClass * @param \Donquixote\HastyReflectionCommon\Canvas\ClassIndex\ClassIndexInterface $classIndex * * @return \Donquixote\HastyReflectionCommon\Reflection\ClassLike\ClassLikeReflection_Composite */ static function createFromReflection($name, \ReflectionClass $reflectionClass, ClassIndexInterface $classIndex) { $declaration = Declaration::createFromReflection($reflectionClass); $header = new ClassLikeHeader_Native($reflectionClass); $extends = ($parentReflectionClass = $reflectionClass->getParentClass()) ? new ClassExtends_ByName($classIndex, $parentReflectionClass->getName()) : new ClassExtends_None(); $ownInterfaceNames = $reflectionClass->getInterfaceNames(); $allInterfaceNames = $ownInterfaceNames; $interfacesAll = new AllInterfaces_FromNames($classIndex, $allInterfaceNames); if ($reflectionClass->isInterface()) { $interfacesAll = $interfacesAll->withSelfInterfaceName($name, $classIndex); } $ownInterfaces = new OwnInterfaces_FromNames($classIndex, $ownInterfaceNames); $ownBody = new OwnBody_Native($reflectionClass, $classIndex); $body = ClassLikeBody_Composite::createFromOwnBody($extends, $interfacesAll, $ownBody); return new ClassLikeReflection_Composite($declaration, $header, $extends, $interfacesAll, $ownInterfaces, $body, $classIndex); }