test(compiler): verify opcode build state in incremental compilation

- Added assertion to check opcodeBuildChecked property is false
- Used reflection to access parent class properties when needed
- Removed anonymousOpcode configuration from build parameters
- Ensured proper state verification for compiler fingerprint tests
master
韩天峰 3 weeks ago
parent f3999413f2
commit 1a2a49addb
  1. 5
      phpunit/src/Build/CompilerGeneratorFingerprintTest.php
  2. 1
      src/Build/IncrementalCompilationTrait.php

@ -21,6 +21,11 @@ final class CompilerGeneratorFingerprintTest extends TestCase
$method = (new ReflectionClass(\TypePhp\Translator::class))->getMethod('getIncrementalGeneratorFingerprint');
$native = $method->invoke($compiler);
self::assertMatchesRegularExpression('/^[a-f0-9]{64}$/D', $native);
$reflection = new ReflectionClass($compiler);
while (!$reflection->hasProperty('opcodeBuildChecked')) {
$reflection = $reflection->getParentClass();
}
self::assertFalse($reflection->getProperty('opcodeBuildChecked')->getValue($compiler));
self::assertSame($native, $method->invoke($compiler));
define('TYPEPHP_PHP_SCRIPT_ENTRY', true);
self::assertNotSame($native, $method->invoke($compiler));

@ -365,7 +365,6 @@ trait IncrementalCompilationTrait
'platform' => $this->targetPlatform,
'literalStrings' => !$this->noLiteralStrings,
'debug' => $this->debug,
'anonymousOpcode' => $this->canEmbedAnonymousClassOpcode(),
]));
// New self-hosted compiler builds embed their immutable source snapshot.

Loading…
Cancel
Save