Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/repro/issue_enum_unserialize_roundtrip.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
declare(strict_types=1);
enum E: int { case A = 1; }
$s = serialize(E::A);
echo $s, "\n";
$u = unserialize($s);
var_export($u);
echo "\n", ($u === E::A) ? "same\n" : "diff\n";
100 changes: 100 additions & 0 deletions test/unit/RuntimeShrinkCloseoutTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php

declare(strict_types=1);

namespace PHPCompiler;

use PHPUnit\Framework\TestCase;

/**
* php-in-php closeout guard (#5211, #1492): open queue issues #5200–#5708 C TUs deleted; LLVM/PHP SSOT in ext/ + lib/JIT/.
*
* @group aot-lint
*/
final class RuntimeShrinkCloseoutTest extends TestCase
{
private string $repoRoot;

protected function setUp(): void
{
$this->repoRoot = dirname(__DIR__, 2);
}

/** @return list<string> */
private function deletedAotRuntimeSources(): array
{
return [
'phpc_settype.c', // #5200
'phpc_dir.c', // #5258 / #5494
'phpc_fs_dir.c', // #5258 / #6982
'phpc_unserialize.c', // #5280 / #5991
'phpc_string_cslashes.c', // #5278 / #5652
'phpc_class_methods.c', // #5290
'phpc_ini_set.c', // #5363 / #5736
'phpc_json_decode.c', // #5302 / #6202
'hash_crypto.c', // #5227 / #7189
'password_crypto.c', // #5234 / #5708 / #6906
'superglobals_refresh.c', // #5330
'phpc_stream.c', // #5343 / #6821
'preg_match.c', // #5289
];
}

public function testDeletedPhpInPhpRuntimeSourcesAbsent(): void
{
$runtimeDir = $this->repoRoot.'/lib/AOT/runtime';
$linker = (string) file_get_contents($this->repoRoot.'/lib/AOT/Linker.php');
$jitBuiltinDir = $this->repoRoot.'/lib/JIT/Builtin';

foreach ($this->deletedAotRuntimeSources() as $basename) {
$this->assertFileDoesNotExist(
$runtimeDir.'/'.$basename,
"{$basename} must stay deleted (php-in-php migration)"
);
$this->assertFileDoesNotExist(
$jitBuiltinDir.'/'.$basename,
"lib/JIT/Builtin/{$basename} must not reappear"
);
$this->assertStringNotContainsString(
$basename,
$linker,
"Linker must not list {$basename}"
);
}
}

public function testPhpReplacementsPresent(): void
{
$checks = [
'ext/standard/JitSettype.php' => 'JitSettype',
'ext/standard/VmSerialize.php' => 'resolveEnumCaseVariable',
'lib/JIT/Builtin/StringUnserializeJit.php' => '__compiler_unserialize',
'lib/JIT/Builtin/IniRuntime.php' => 'VmIni',
'lib/JIT/Builtin/StringJsonDecodeJit.php' => '__compiler_json_decode',
'lib/JIT/Builtin/StringPasswordCryptoJit.php' => 'password_hash',
'lib/JIT/Builtin/StringHashCryptoNativeJit.php' => 'hash',
'lib/JIT/Builtin/StringDirJit.php' => 'phpc_dir',
'lib/JIT/Builtin/StringFsDirJit.php' => 'StringFsDirJit',
'ext/standard/stripcslashes.php' => 'VmString',
];

foreach ($checks as $relativePath => $needle) {
$path = $this->repoRoot.'/'.$relativePath;
$this->assertFileExists($path, "{$relativePath} must exist as PHP SSOT");
$source = (string) file_get_contents($path);
$this->assertStringContainsString($needle, $source, "{$relativePath} must implement {$needle}");
}
}

public function testOnlyProgressAbiRemainsInAotRuntime(): void
{
$runtimeDir = $this->repoRoot.'/lib/AOT/runtime';
$cFiles = glob($runtimeDir.'/*.c') ?: [];
sort($cFiles);
$this->assertSame(
[$runtimeDir.'/phpc_progress.c'],
$cFiles,
'Only phpc_progress.c (frozen SIGSEGV ABI) may remain under lib/AOT/runtime/'
);
}
}