fix name handling
authorMichael Wallner <mike@php.net>
Tue, 27 Feb 2018 13:32:01 +0000 (14:32 +0100)
committerMichael Wallner <mike@php.net>
Tue, 27 Feb 2018 13:32:01 +0000 (14:32 +0100)
src/pharext/PackageInfo.php

index 3e2a78d11827a08e5842affea4bf37cdc44cd5a2..0385c1df69dc0cbedb34ed8f220c6e8331be4a35 100644 (file)
@@ -5,6 +5,7 @@ namespace pharext;
 trait PackageInfo
 {
        /**
+        * @param string $path package root
         * @return array
         */
        public function findPackageInfo($path) {
@@ -12,7 +13,7 @@ trait PackageInfo
                        if (!strlen($name = $this->findPackageName($path, $header))) {
                                return [];
                        }
-                       if (!$release = $this->findPackageReleaseVersion($path, $header, strtoupper($name))) {
+                       if (!$release = $this->findPackageReleaseVersion($path, $header, $name)) {
                                return [];
                        }
                } catch (Exception $e) {
@@ -41,19 +42,21 @@ trait PackageInfo
 
        }
 
-       private function findPackageReleaseVersion($path, $header, $uname) {
+       private function findPackageReleaseVersion($path, $header, $name) {
+               $uc_name = strtoupper($name);
                $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, "#if defined(PHP_PECL_%s_VERSION)\n", $uc_name);
+               fprintf($cpp_hnd, "PHP_PECL_%s_VERSION\n", $uc_name);
+               fprintf($cpp_hnd, "#elif defined(PHP_%s_VERSION)\n", $uc_name);
+               fprintf($cpp_hnd, "PHP_%s_VERSION\n", $uc_name);
+               fprintf($cpp_hnd, "#elif defined(%s_VERSION)\n", $uc_name);
+               fprintf($cpp_hnd, "%s_VERSION\n", $uc_name);
                fprintf($cpp_hnd, "#endif\n");
                fflush($cpp_hnd);
-               $php_inc = (new ExecCmd((PHP_BINARY ?? "php")."-config"))->run([
+               $php_cnf = (defined("PHP_BINARY") ? PHP_BINARY : "php") . "-config";
+               $php_inc = (new ExecCmd($php_cnf))->run([
                        "--includes"
                ])->getOutput();
                $ext_inc = (new ExecCmd("find"))->run([