From 0a542445749dd4f0b141fa18d99d751cf388e25d Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 23 Mar 2024 08:46:49 +0100 Subject: [PATCH 1/3] Added Runtime->getRawBinary() --- src/Runtime.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Runtime.php b/src/Runtime.php index 8cbdfe4..0c8a542 100644 --- a/src/Runtime.php +++ b/src/Runtime.php @@ -93,14 +93,14 @@ public function performsJustInTimeCompilation(): bool /** * Returns the path to the binary of the current runtime. */ - public function getBinary(): string + public function getRawBinary(): string { if (self::$initialized) { return self::$binary; } if (PHP_BINARY !== '') { - self::$binary = escapeshellarg(PHP_BINARY); + self::$binary = PHP_BINARY; self::$initialized = true; return self::$binary; @@ -115,7 +115,7 @@ public function getBinary(): string foreach ($possibleBinaryLocations as $binary) { if (is_readable($binary)) { - self::$binary = escapeshellarg($binary); + self::$binary = $binary; self::$initialized = true; return self::$binary; @@ -130,6 +130,14 @@ public function getBinary(): string return self::$binary; } + /** + * Returns the path to the binary of the current runtime. + */ + public function getBinary(): string + { + return escapeshellarg($this->getRawBinary()); + } + public function getNameWithVersion(): string { return $this->getName() . ' ' . $this->getVersion(); From 6d3e0f0a727beb194360885a32728dd232fcc911 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 23 Mar 2024 08:47:34 +0100 Subject: [PATCH 2/3] Added test --- tests/RuntimeTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/RuntimeTest.php b/tests/RuntimeTest.php index 3362c21..14375f3 100644 --- a/tests/RuntimeTest.php +++ b/tests/RuntimeTest.php @@ -41,6 +41,11 @@ public function testBinaryCanBeRetrieved(): void { $this->assertNotEmpty((new Runtime)->getBinary()); } + + public function testRawBinaryCanBeRetrieved(): void + { + $this->assertNotEmpty((new Runtime)->getRawBinary()); + } public function testIsPhpReturnsTrueWhenRunningOnPhp(): void { From 7c0c4fcfedc3051f1cf0de5438a188d5ab9fe783 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 23 Mar 2024 08:54:40 +0100 Subject: [PATCH 3/3] more precise docs --- src/Runtime.php | 4 ++-- tests/RuntimeTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Runtime.php b/src/Runtime.php index 0c8a542..66a267b 100644 --- a/src/Runtime.php +++ b/src/Runtime.php @@ -91,7 +91,7 @@ public function performsJustInTimeCompilation(): bool } /** - * Returns the path to the binary of the current runtime. + * Returns the raw path to the binary of the current runtime. */ public function getRawBinary(): string { @@ -131,7 +131,7 @@ public function getRawBinary(): string } /** - * Returns the path to the binary of the current runtime. + * Returns the escaped path to the binary of the current runtime. */ public function getBinary(): string { diff --git a/tests/RuntimeTest.php b/tests/RuntimeTest.php index 14375f3..00828e7 100644 --- a/tests/RuntimeTest.php +++ b/tests/RuntimeTest.php @@ -41,7 +41,7 @@ public function testBinaryCanBeRetrieved(): void { $this->assertNotEmpty((new Runtime)->getBinary()); } - + public function testRawBinaryCanBeRetrieved(): void { $this->assertNotEmpty((new Runtime)->getRawBinary());