public function convert(CodeCollectorInterface $codeCollector, Logger $logger, $filterFileName = null)
    {
        $zephirCode = array();
        $classes = array();

        $files = $codeCollector->getCode();
        $count = count($files);
        $codes = array();

        $logger->log('Collect class names');
        $progress = $logger->progress($count);

        foreach ($files as $fileName => $fileContent) {
            try {
                $codes[$fileName] = $this->parser->parse($fileContent);
                $classes[$fileName] = $this->classCollector->collect($codes[$fileName], $fileName);
            } catch (\Exception $e) {
                $logger->log(
                    sprintf(
                        '<error>Could not convert file'."\n".'"%s"'."\n".'cause : %s %s %s</error>'."\n",
                        $fileName,
                        $e->getMessage(),
                        $e->getFile(),
                        $e->getLine()
                    )
                );
            }
            $progress->advance();
        }

        $progress->finish();

        $logger->log("\nConvert php to zephir");
        $progress = $logger->progress(count($classes));

        foreach ($classes as $phpFile => $class) {
            if ($filterFileName !== null) {
                if (basename($phpFile, '.php') !== $filterFileName) {
                    continue;
                }
            }

            $phpCode = $codes[$phpFile];
            $fileName = basename($phpFile, '.php');
            try {
                $converted = $this->convertCode($phpCode, $this->classCollector, $logger, $phpFile, $classes);
                $converted['class'] = $class;
            } catch (\Exception $e) {
                $logger->log(
                    sprintf(
                        'Could not convert file "%s" cause : %s %s %s'."\n",
                        $phpFile,
                        $e->getMessage(),
                        $e->getFile(),
                        $e->getLine()
                    )
                );
                $progress->advance();
                continue;
            }

            $zephirCode[$phpFile] = array_merge(
                $converted,
                array(
                    'phpPath' => substr($phpFile, 0, strrpos($phpFile, '/')),
                    'fileName' => $fileName,
                    'fileDestination' => $converted['class'].'.zep',
                )
             );

            $zephirCode[$phpFile]['fileDestination'] = str_replace('\\', '/', $zephirCode[$phpFile]['fileDestination']);

            foreach ($converted['additionalClass'] as $aditionalClass) {
                $zephirCode[$phpFile.$aditionalClass['name']] = array_merge(
                    array(
                        'fileName' => $aditionalClass['name'],
                        'zephir' => $aditionalClass['code'],
                        'fileDestination' => str_replace('\\', '/', $converted['namespace']).'/'.$aditionalClass['name'].'.zep',
                        'destination' => str_replace('\\', '/', $converted['namespace']).'/',
                    )
                );
            }

            $progress->advance();
        }

        $progress->finish();
        $logger->log("\n");

        return $zephirCode;
    }
public function convert(CodeCollectorInterface $codeCollector, Logger $logger, $filterFileName = null)
    {
        $zephirCode = array();
        $classes = array();

        $files = $codeCollector->getCode();
        $count = count($files);
        $codes = array();

        $logger->log('Collect class names');
        $progress = $logger->progress($count);

        foreach ($files as $fileName => $fileContent) {
            try {
                $codes[$fileName] = $this->parser->parse($fileContent);
                $classes[$fileName] = $this->classCollector->collect($codes[$fileName], $fileName);
            } catch (\Exception $e) {
                $logger->log(
                    sprintf(
                        '<error>Could not convert file'."\n".'"%s"'."\n".'cause : %s %s %s</error>'."\n",
                        $fileName,
                        $e->getMessage(),
                        $e->getFile(),
                        $e->getLine()
                    )
                );
            }
            $progress->advance();
        }

        $progress->finish();

        $logger->log("\nConvert php to zephir");
        $progress = $logger->progress(count($classes));

        foreach ($classes as $phpFile => $class) {
            if ($filterFileName !== null) {
                if (basename($phpFile, '.php') !== $filterFileName) {
                    continue;
                }
            }

            $phpCode = $codes[$phpFile];
            $fileName = basename($phpFile, '.php');
            try {
                $converted = $this->convertCode($phpCode, $this->classCollector, $logger, $phpFile, $classes);
                $converted['class'] = $class;
            } catch (\Exception $e) {
                $logger->log(
                    sprintf(
                        'Could not convert file "%s" cause : %s %s %s'."\n",
                        $phpFile,
                        $e->getMessage(),
                        $e->getFile(),
                        $e->getLine()
                    )
                );
                $progress->advance();
                continue;
            }

            $zephirCode[$phpFile] = array_merge(
                $converted,
                array(
                    'phpPath' => substr($phpFile, 0, strrpos($phpFile, '/')),
                    'fileName' => $fileName,
                    'fileDestination' => $converted['class'].'.zep',
                )
             );

            $zephirCode[$phpFile]['fileDestination'] = str_replace('\\', '/', $zephirCode[$phpFile]['fileDestination']);

            foreach ($converted['additionalClass'] as $aditionalClass) {
                $zephirCode[$phpFile.$aditionalClass['name']] = array_merge(
                    array(
                        'fileName' => $aditionalClass['name'],
                        'zephir' => $aditionalClass['code'],
                        'fileDestination' => str_replace('\\', '/', $converted['namespace']).'/'.$aditionalClass['name'].'.zep',
                        'destination' => str_replace('\\', '/', $converted['namespace']).'/',
                    )
                );
            }

            $progress->advance();
        }

        $progress->finish();
        $logger->log("\n");

        return $zephirCode;
    }
@param CodeCollectorInterface $codeCollector
@param Logger                 $logger
@param string                 $filterFileName

@return array