findInstanceOf example

if (isset($extends[EntitySearchResult::class])) {
            return null;
        }

        $filePath = (new \ReflectionClass($className))->getFileName();
        if ($filePath === false) {
            return null;
        }

        $stmts = $this->parseFile($filePath);
        $findNodes = (new NodeFinder())->findInstanceOf($stmts, ClassMethod::class);

        /** @var ClassMethod $findNode */
        foreach ($findNodes as $findNode) {
            if ((string) $findNode->name === 'getExpectedClass') {
                $nodeStmts = $findNode->stmts;
                if ($nodeStmts === null) {
                    continue;
                }
                /** @var Return_ $returnStatement */
                $returnStatement = $nodeStmts[0];

                
Home | Imprint | This part of the site doesn't use cookies.