PhpBrew\BuildFinder::findInstalledBuilds PHP Method

findInstalledBuilds() public static method

public static findInstalledBuilds ( $stripPrefix = true ) : string[]
return string[]
    public static function findInstalledBuilds($stripPrefix = true)
    {
        $path = Config::getRoot() . DIRECTORY_SEPARATOR . 'php';
        if (!file_exists($path)) {
            throw new Exception($path . ' does not exist.');
        }
        $names = scandir($path);
        $names = array_filter($names, function ($name) use($path) {
            return $name != '.' && $name != '..' && file_exists($path . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'php');
        });
        if ($names == null || empty($names)) {
            return array();
        }
        if ($stripPrefix) {
            $names = array_map(function ($name) {
                return preg_replace('/^php-(?=(\\d+\\.\\d+\\.\\d+((alpha|beta|RC)\\d+)?)$)/', '', $name);
            }, $names);
        }
        uasort($names, 'version_compare');
        // ordering version name ascending... 5.5.17, 5.5.12
        return array_reverse($names);
        // make it descending... since there is no sort function for user-define in reverse order.
    }

Usage Example

Esempio n. 1
0
 public function arguments($args)
 {
     $args->add('php version')->validValues(function () {
         return \PhpBrew\BuildFinder::findInstalledBuilds();
     });
 }
All Usage Examples Of PhpBrew\BuildFinder::findInstalledBuilds