pharext\PackageInfo::findPackageReleaseVersion PHP Method

findPackageReleaseVersion() private method

private findPackageReleaseVersion ( $path, $header, $uname )
    private function findPackageReleaseVersion($path, $header, $uname)
    {
        $cpp_tmp = new Tempfile("cpp");
        $cpp_hnd = $cpp_tmp->getStream();
        fprintf($cpp_hnd, "#include \"%s\"\n", $header);
        fprintf($cpp_hnd, "#if defined(PHP_PECL_%s_VERSION)\n", $uname);
        fprintf($cpp_hnd, "PHP_PECL_%s_VERSION\n", $uname);
        fprintf($cpp_hnd, "#elif defined(PHP_%s_VERSION)\n", $uname);
        fprintf($cpp_hnd, "PHP_%s_VERSION\n", $uname);
        fprintf($cpp_hnd, "#elif defined(%s_VERSION)\n", $uname);
        fprintf($cpp_hnd, "%s_VERSION\n", $uname);
        fprintf($cpp_hnd, "#endif\n");
        fflush($cpp_hnd);
        $php_inc = (new ExecCmd((PHP_BINARY ?? "php") . "-config"))->run(["--includes"])->getOutput();
        $ext_inc = (new ExecCmd("find"))->run([$path, "-not", "-path", "*/.*", "-type", "d", "-printf", "-I'%p' "])->getOutput();
        $cpp_res = (new ExecCmd("cpp {$php_inc} {$ext_inc}"))->run(["-E", $cpp_tmp])->getOutput();
        return trim(substr($cpp_res, strrpos($cpp_res, "\n")), "\"\n");
    }