Returns the type of the class a node is contained in
Returns null if the class is anonymous or the node is not contained in a class

@param Node $node The node used to find the containing class

@return Types\Object_|null
1172
private function getContainingClassType(Node $node)
    {
        $classFqn = $this->getContainingClassFqn($node);
        return $classFqn ? new Types\Object_(new Fqsen('\\' . $classFqn)) : null;
    }
848872
private function removeSelfTypeMethod(Class_ $node): Class_
    {
        foreach ((array) $node->stmts as $key => $stmt) {
            if (! $stmt instanceof ClassMethod) {
                continue;
            }

            if (count((array) $stmt->stmts) !== 1) {
                continue;
            }

            $innerClassMethodStmt = $stmt->stmts[0] instanceof Expression ? $stmt->stmts[0]->expr : $stmt->stmts[0];

            if (! $innerClassMethodStmt instanceof MethodCall) {
                continue;
            }

            if (! $this->isName($innerClassMethodStmt, 'shouldHaveType')) {
                continue;
            }

            // not the tested type
            if (! $this->isValue($innerClassMethodStmt->args[0]->value, $this->testedClass)) {
                continue;
            }

            // remove it
            unset($node->stmts[$key]);
        }

        return $node;
    }
107576
public function getParamTypeInfos(Node $node): array
    {
        if ($node->getDocComment() === null) {
            return [];
        }

        $phpDocInfo = $this->createPhpDocInfoFromNode($node);
        $types = $phpDocInfo->getParamTagValues();

        if ($types === []) {
            return [];
        }

        $fqnTypes = $phpDocInfo->getParamTagValues();

        $paramTypeInfos = [];
        /** @var AttributeAwareParamTagValueNode $paramTagValueNode */
        foreach ($types as $i => $paramTagValueNode) {
            $fqnParamTagValueNode = $fqnTypes[$i];

            $paramTypeInfo = new ParamTypeInfo(
                $paramTagValueNode->parameterName,
                $this->typeAnalyzer,
                $paramTagValueNode->getAttribute(Attribute::TYPE_AS_ARRAY),
                $fqnParamTagValueNode->getAttribute(Attribute::RESOLVED_NAMES)
            );

            $paramTypeInfos[$paramTypeInfo->getName()] = $paramTypeInfo;
        }

        return $paramTypeInfos;
    }
325107
private function getClassType($node, TypeInterface $parent): string
    {
        $phpFile = RootRetrieverHelper::getRoot($parent);

        switch (true) {
            case $node instanceof Node\Identifier:
            case $node->isRelative():
            case $node->isUnqualified():
                $name = $this->getUnqualifiedClassType($node, $phpFile);
                break;
            case $node->isFullyQualified():
                $name = $node->toString();
                break;
            case $node->isQualified():
                $name = $this->getQualifiedClassType($node, $phpFile);
                break;
            default:
                return TypeInterface::UNKNOWN_CUSTOM;
        }

        // Get the last name part
        $nameArray = explode('\\', $name);
        $lastPart  = end($nameArray);

        $phpFile->addConcreteUse($name, $lastPart);

        return $lastPart;
    }
1309769
public function getClassName(AbstractNode $node): string
    {
        $fullQualifiedName = $node->getFullQualifiedName();
        $fullQualifiedName = explode('::', $fullQualifiedName);

        return array_shift($fullQualifiedName);
    }
278817
public function parent($node = null)
	{
		if ($node)
		{
			$parents = $this->xpath('ancestor-or-self::' . $node);
		}
		else
		{
			$parents = $this->xpath('parent::*');
		}

		return $parents[0];
	}
640936
public function getNodeType()
	{
		if ( is_null( $this->domNode ) ) return null;
		return isset(  DOMXPathNavigator::$nodeTypeMap[ $this->domNode->nodeType ] )
			? DOMXPathNavigator::$nodeTypeMap[ $this->domNode->nodeType ]
			: XPathNodeType::Element;
	}
1029923
protected function resolve(Node $node)
    {
        $value = null;
        try {
            ++$this->nodeLevel;

            $methodName = $this->getDispatchMethodFor($node);
            if (method_exists($this, $methodName)) {
                $value = $this->$methodName($node);
            }
        } finally {
            --$this->nodeLevel;
        }

        return $value;
    }
301014
private function getPrimitiveValue(Node $node) {
		if ($this->isBool($node)) {
			return (bool) $this->getExpression($node);
		}
	
		if ($this->isNull($node)) {
			return null;
		}
	
		return $node->value;
	}
1013120
protected function isEntity(ClassNode $node)
    {
        $docComment = $node->getDocComment();

        if (0 < preg_match($this->getStringProperty('classIsEntityRegex'), $docComment)) {
            return true;
        }

        if (true === $node->isAbstract()) {
            return false;
        }

        if (0 < preg_match($this->getStringProperty('entityRegex'), $docComment)) {
            return true;
        }

        return false;
    }
117897
protected function compileDoctype(Node $node)
    {

        $name = $node->name;
        $value = isset($this->options['doctypes'][$name]) ? $this->options['doctypes'][$name] : '<!DOCTYPE '.$name.'>';

        if ($name === 'xml') {

            $this->options['mode'] = self::MODE_XML;

            if ($this->options['echo_xml_doctype'])
                $value = "<?='$value'?>";

        } else if (in_array($name, $this->options['xhtml_modes']))
            $this->options['mode'] = self::MODE_XHTML;
        else
            $this->options['mode'] = self::MODE_HTML;

        return $value;
    }
960241
public function matches(\Neos\ContentRepository\Domain\Model\NodeData $node)
    {
        $nodeIsMatchingNodeType = false;

        for($i=0; $i<$this->searchDepth;$i++){
            $parentNode = $node->getParent();

            if($parentNode!==null){
                // This will break atm for NodeTypes that no longer exist - see /Packages/Application/Neos.ContentRepository/Classes/TYPO3/TYPO3CR/Migration/Filters/NodeType.php
                // version stated there is a "hack" though and does not allow for standard UnitTesting
                $nodeType = $parentNode->getNodeType();

                if ($this->withSubTypes === true) {
                    $nodeIsMatchingNodeType = $nodeType->isOfType($this->nodeTypeName);
                } else {
                    if ($nodeType->getName() === $this->nodeTypeName) {
                        $nodeIsMatchingNodeType = true;
                        break;
                    }
                }
                $node = $parentNode;
            }
            else{
                break;
            }
        }

        return $nodeIsMatchingNodeType;
    }
774835
protected function getData($node)
    {
        if (isset($node->data)) {
            return $node->data;
        } else if (isset($node->nodeValue)) {
            return $node->nodeValue;
        } else if (isset($node->textContent)) {
            return $node->textContent;
        }
        return null;
    }
431717
private function fetchReflectionClass(Node\Name $node)
    {
        $className  = $node->toString();
        $isFQNClass = $node instanceof Node\Name\FullyQualified;
        if ($isFQNClass) {
            // check to see if the class is already loaded and is safe to use
            // PHP's ReflectionClass to determine if the class is user defined
            if (class_exists($className, false)) {
                $refClass = new \ReflectionClass($className);
                if (!$refClass->isUserDefined()) {
                    return $refClass;
                }
            }
            return new ReflectionClass($className);
        }

        if ('self' === $className) {
            if ($this->context instanceof \ReflectionClass) {
                return $this->context;
            } elseif (method_exists($this->context, 'getDeclaringClass')) {
                return $this->context->getDeclaringClass();
            }
        }

        if ('parent' === $className) {
            if ($this->context instanceof \ReflectionClass) {
                return $this->context->getParentClass();
            } elseif (method_exists($this->context, 'getDeclaringClass')) {
                return $this->context->getDeclaringClass()->getParentClass();
            }
        }

        if (method_exists($this->context, 'getFileName')) {
            /** @var ReflectionFileNamespace|null $fileNamespace */
            $fileName      = $this->context->getFileName();
            $namespaceName = $this->resolveScalarMagicConstNamespace();

            $fileNamespace = new ReflectionFileNamespace($fileName, $namespaceName);
            return $fileNamespace->getClass($className);
        }

        throw new ReflectionException("Can not resolve class $className");
    }
1339425
protected function traverseNode(Node $node) : Node
    {
        foreach ($node->getSubNodeNames() as $name) {
            $subNode =& $node->$name;

            if (\is_array($subNode)) {
                $subNode = $this->traverseArray($subNode);
                if ($this->stopTraversal) {
                    break;
                }
            } elseif ($subNode instanceof Node) {
                $traverseChildren = true;
                foreach ($this->visitors as $visitor) {
                    $return = $visitor->enterNode($subNode, $traverseChildren);
                    if (null !== $return) {
                        if ($return instanceof Node) {
                            $subNode = $return;
                        } elseif (self::DONT_TRAVERSE_CHILDREN === $return) {
                            $traverseChildren = false;
                        } elseif (self::STOP_TRAVERSAL === $return) {
                            $this->stopTraversal = true;
                            break 2;
                        } else {
                            throw new \LogicException(
                                'enterNode() returned invalid value of type ' . gettype($return)
                            );
                        }
                    }
                }

                if ($traverseChildren) {
                    $subNode = $this->traverseNode($subNode);
                    if ($this->stopTraversal) {
                        break;
                    }
                }

                foreach ($this->visitors as $visitor) {
                    $return = $visitor->leaveNode($subNode);
                    if (null !== $return) {
                        if ($return instanceof Node) {
                            $subNode = $return;
                        } elseif (self::STOP_TRAVERSAL === $return) {
                            $this->stopTraversal = true;
                            break 2;
                        } elseif (\is_array($return)) {
                            throw new \LogicException(
                                'leaveNode() may only return an array ' .
                                'if the parent structure is an array'
                            );
                        } else {
                            throw new \LogicException(
                                'leaveNode() returned invalid value of type ' . gettype($return)
                            );
                        }
                    }
                }
            }
        }

        return $node;
    }
915529
public static function getClosestAggregateNode(NodeInterface $node)
    {
        while ($node !== null && !$node->getNodeType()->isAggregate()) {
            $node = $node->getParent();
        }
        return $node;
    }
19823
public function get($node = null)
    {
        if ($node !== null) {
            $nodes         = explode(':', $node);
            $configuration = $this->getConfiguration();
            foreach ($nodes as $node) {
                $configuration = $configuration->{$node};
            }
        } else {
            $configuration = $this->getConfiguration();
        }

        return $configuration;
    }