1
0
mirror of https://github.com/php/pie.git synced 2026-03-23 23:12:17 +01:00

Merge pull request #534 from asgrim/phpize-build-tool-finder-check-api-version

Ensure the build tool finder checks PHP API version in phpize
This commit is contained in:
James Titcumb
2026-03-10 12:02:50 +00:00
committed by GitHub
3 changed files with 31 additions and 3 deletions

View File

@@ -453,7 +453,7 @@ parameters:
-
message: '#^Access to an undefined property Php\\PieUnitTest\\SelfManage\\BuildTools\\PhpizeBuildToolFinderTest\:\:\$phpBinaryPath\.$#'
identifier: property.notFound
count: 3
count: 4
path: test/unit/SelfManage/BuildTools/PhpizeBuildToolFinderTest.php
-

View File

@@ -38,14 +38,16 @@ class PhpizeBuildToolFinder extends BinaryBuildToolFinder
// intentionally ignored - just don't try to use the guessed phpize path
}
$expectedApiVersion = $targetPlatform->phpBinaryPath->phpApiVersion();
foreach ($tools as $tool) {
if (file_exists($tool) && is_executable($tool) && PhpizePath::looksLikeValidPhpize($tool)) {
if (file_exists($tool) && is_executable($tool) && PhpizePath::looksLikeValidPhpize($tool, $expectedApiVersion)) {
return true;
}
$foundTool = (new ExecutableFinder())->find($tool);
if ($foundTool !== null && PhpizePath::looksLikeValidPhpize($foundTool)) {
if ($foundTool !== null && PhpizePath::looksLikeValidPhpize($foundTool, $expectedApiVersion)) {
return true;
}
}

View File

@@ -35,6 +35,7 @@ final class PhpizeBuildToolFinderTest extends TestCase
putenv('PATH=' . realpath(self::GOOD_PHPIZE_PATH));
$mockPhpBinary = $this->createMock(PhpBinaryPath::class);
$mockPhpBinary->method('phpApiVersion')->willReturn('20240924');
(fn () => $this->phpBinaryPath = '/path/to/php')
->bindTo($mockPhpBinary, PhpBinaryPath::class)();
@@ -58,6 +59,7 @@ final class PhpizeBuildToolFinderTest extends TestCase
putenv('PATH=' . realpath(self::BAD_PHPIZE_PATH));
$mockPhpBinary = $this->createMock(PhpBinaryPath::class);
$mockPhpBinary->method('phpApiVersion')->willReturn('20240924');
(fn () => $this->phpBinaryPath = '/path/to/php')
->bindTo($mockPhpBinary, PhpBinaryPath::class)();
@@ -102,4 +104,28 @@ final class PhpizeBuildToolFinderTest extends TestCase
putenv('PATH=' . $oldPath);
}
public function testPhpizeForDifferentPhpApiVersionIsRejected(): void
{
$oldPath = getenv('PATH');
putenv('PATH=' . realpath(self::GOOD_PHPIZE_PATH));
$mockPhpBinary = $this->createMock(PhpBinaryPath::class);
$mockPhpBinary->method('phpApiVersion')->willReturn('20250925');
(fn () => $this->phpBinaryPath = '/path/to/php')
->bindTo($mockPhpBinary, PhpBinaryPath::class)();
self::assertFalse((new PhpizeBuildToolFinder([]))->check(new TargetPlatform(
OperatingSystem::NonWindows,
OperatingSystemFamily::Linux,
$mockPhpBinary,
Architecture::x86_64,
ThreadSafetyMode::NonThreadSafe,
1,
null,
null,
)));
putenv('PATH=' . $oldPath);
}
}