Zephir\Compiler::getCurrentVersion PHP Method

getCurrentVersion() public static method

Returns the current version + the ident if available
public static getCurrentVersion ( ) : string
return string
    public static function getCurrentVersion()
    {
        $version = '$Id$';
        if (strlen($version) != 4) {
            return self::VERSION . '-' . substr($version, 0, 10);
        }
        if (!Utils::isWindows()) {
            if (self::$currentVersion === null) {
                if (file_exists(__DIR__ . '/../.git')) {
                    exec('cd ' . __DIR__ . '/.. && git log --format="%H" -n 1', $xversion);
                    if (isset($xversion[0]) && strlen($xversion[0]) > 10) {
                        self::$currentVersion = substr($xversion[0], 0, 10);
                    } else {
                        self::$currentVersion = false;
                    }
                }
            }
            if (self::$currentVersion) {
                return self::VERSION . '-' . self::$currentVersion;
            }
        }
        return self::VERSION;
    }

Usage Example

Example #1
0
 /**
  * Executes the command
  *
  * @param Config $config
  * @param Logger $logger
  */
 public function execute(Config $config, Logger $logger)
 {
     echo self::LOGO, PHP_EOL;
     echo "Zephir version ", Compiler::getCurrentVersion(), PHP_EOL, PHP_EOL;
     echo "Usage: ", PHP_EOL;
     echo "\tcommand [options]", PHP_EOL;
     echo PHP_EOL;
     echo "Available commands:", PHP_EOL;
     foreach (Bootstrap::getCommands() as $command) {
         echo sprintf("\t%-20s%s\n", $command->getUsage(), $command->getDescription());
     }
     echo PHP_EOL;
     echo "Options:", PHP_EOL;
     echo sprintf("\t%-20s%s\n", "-f([a-z0-9\\-]+)", "Enables compiler optimizations");
     echo sprintf("\t%-20s%s\n", "-fno-([a-z0-9\\-]+)", "Disables compiler optimizations");
     echo sprintf("\t%-20s%s\n", "-w([a-z0-9\\-]+)", "Turns a warning on");
     echo sprintf("\t%-20s%s\n", "-W([a-z0-9\\-]+)", "Turns a warning off");
     echo PHP_EOL;
 }
All Usage Examples Of Zephir\Compiler::getCurrentVersion