src/PhpToZephir/ClassCollector.php
public function collect(array $stmts, $fileName)
    {
        $namespace = null;
        $class = null;

        foreach ($this->nodeFetcher->foreachNodes($stmts) as $nodeData) {
            $node = $nodeData['node'];
            if ($node instanceof Stmt\Goto_) {
                throw new \Exception('Goto not supported in '.$fileName.' on line '.$node->getLine());
            } elseif ($node instanceof Stmt\InlineHTML) {
                throw new \Exception('InlineHTML not supported in '.$fileName.' on line '.$node->getLine());
            } elseif ($node instanceof Stmt\HaltCompiler) {
                throw new \Exception('HaltCompiler not supported in '.$fileName.' on line '.$node->getLine());
            } elseif ($node instanceof MagicConst\Trait_) {
                throw new \Exception('MagicConst\Trait_ not supported in '.$fileName.' on line '.$node->getLine());
            } elseif ($node instanceof Stmt\Trait_) {
                throw new \Exception('Trait not supported in '.$fileName.' on line '.$node->getLine());
            } elseif ($node instanceof Stmt\Namespace_ && !empty($node->name)) {
                $namespace = implode('\\', $node->name->parts);
            } elseif ($node instanceof Stmt\Interface_ || $node instanceof Stmt\Class_) {
                if ($class !== null) {
                    throw new \Exception('Multiple class find in '.$fileName);
                }
                $class = $namespace.'\\'.$this->reservedWordReplacer->replace($node->name);
            }
        }

        if ($namespace === null) {
            throw new \Exception('Namespace not found in '.$fileName);
        }

        if ($class === null) {
            throw new \Exception('No class found in '.$fileName);
        }

        $this->collected[$class] = $stmts;

        return $class;
    }
public function collect(array $stmts, $fileName)
    {
        $namespace = null;
        $class = null;

        foreach ($this->nodeFetcher->foreachNodes($stmts) as $nodeData) {
            $node = $nodeData['node'];
            if ($node instanceof Stmt\Goto_) {
                throw new \Exception('Goto not supported in '.$fileName.' on line '.$node->getLine());
            } elseif ($node instanceof Stmt\InlineHTML) {
                throw new \Exception('InlineHTML not supported in '.$fileName.' on line '.$node->getLine());
            } elseif ($node instanceof Stmt\HaltCompiler) {
                throw new \Exception('HaltCompiler not supported in '.$fileName.' on line '.$node->getLine());
            } elseif ($node instanceof MagicConst\Trait_) {
                throw new \Exception('MagicConst\Trait_ not supported in '.$fileName.' on line '.$node->getLine());
            } elseif ($node instanceof Stmt\Trait_) {
                throw new \Exception('Trait not supported in '.$fileName.' on line '.$node->getLine());
            } elseif ($node instanceof Stmt\Namespace_ && !empty($node->name)) {
                $namespace = implode('\\', $node->name->parts);
            } elseif ($node instanceof Stmt\Interface_ || $node instanceof Stmt\Class_) {
                if ($class !== null) {
                    throw new \Exception('Multiple class find in '.$fileName);
                }
                $class = $namespace.'\\'.$this->reservedWordReplacer->replace($node->name);
            }
        }

        if ($namespace === null) {
            throw new \Exception('Namespace not found in '.$fileName);
        }

        if ($class === null) {
            throw new \Exception('No class found in '.$fileName);
        }

        $this->collected[$class] = $stmts;

        return $class;
    }
public function collect ( array $ stmts , $ fileName ) { $ namespace = null ; $ class = null ; foreach ( $ this -> nodeFetcher -> foreachNodes ( $ stmts ) as $ nodeData ) { $ node = $ nodeData [ 'node' ] ; if ( $ node instanceof Stmt \ Goto_ ) { throw new \ Exception ( 'Goto not supported in ' . $ fileName . ' on line ' . $ node -> getLine ( ) ) ; } elseif ( $ node instanceof Stmt \ InlineHTML ) { throw new \ Exception ( 'InlineHTML not supported in ' . $ fileName . ' on line ' . $ node -> getLine ( ) ) ; } elseif ( $ node instanceof Stmt \ HaltCompiler ) { throw new \ Exception ( 'HaltCompiler not supported in ' . $ fileName . ' on line ' . $ node -> getLine ( ) ) ; } elseif ( $ node instanceof MagicConst \ Trait_ ) { throw new \ Exception ( 'MagicConst\Trait_ not supported in ' . $ fileName . ' on line ' . $ node -> getLine ( ) ) ; } elseif ( $ node instanceof Stmt \ Trait_ ) { throw new \ Exception ( 'Trait not supported in ' . $ fileName . ' on line ' . $ node -> getLine ( ) ) ; } elseif ( $ node instanceof Stmt \ Namespace_ && ! empty ( $ node -> name ) ) { $ namespace = implode ( '\\' , $ node -> name -> parts ) ; } elseif ( $ node instanceof Stmt \ Interface_ || $ node instanceof Stmt \ Class_ ) { if ( $ class !== null ) { throw new \ Exception ( 'Multiple class find in ' . $ fileName ) ; } $ class = $ namespace . '\\' . $ this -> reservedWordReplacer -> replace ( $ node -> name ) ; } } if ( $ namespace === null ) { throw new \ Exception ( 'Namespace not found in ' . $ fileName ) ; } if ( $ class === null ) { throw new \ Exception ( 'No class found in ' . $ fileName ) ; } $ this -> collected [ $ class ] = $ stmts ; return $ class ; }
@param Node[]  $stmts
@param unknown $fileName

@return string
@param Node [] $stmts @param unknown $fileName