merge: cascade 8.4 into master - #222
Merged
Merged
Conversation
…r AST hooks While CG(in_compilation) is set, the engine promotes every internally-raised exception to a fatal error before any catch runs - including exceptions thrown and caught entirely inside library code, such as Core::cast()'s array-decay probe. That made nearly every AST accessor, and Compiler::getFileName()'s StringEntry path, fatal when called from inside a zend_ast_process callback, and it pushed consumers (scalar-objects) into reflecting out the raw compiler globals to read CG(compiled_filename) themselves - a reach-through the 'public APIs never leak CData' rule exists to prevent. Two named public methods replace that reach-through: - Compiler::getFileName() now reads the zend_string bytes directly via FFI::string() instead of the throwing StringEntry path, so it is safe to call inside the hook. Same contract otherwise. - Compiler::withoutCompilationMode(\Closure): mixed clears CG(in_compilation), runs the operation and restores the previous mode in a finally block - the enter/leave is automatic and exception-safe. AstProcessHook exposes both as getFileName() and withoutCompilationMode() delegates, so AST consumers get everything they need from the hook object itself without touching Core::$compiler or any engine struct. Verified on the 8.5 line as well (files are identical on both): full default suite plus the internal-group CompilerTest on PHP 8.5.9 - the two new hook-context tests fatal without the getFileName fix and pass with it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015M297P4ypTeKaP2u2bfrLq
…ationMode() The Compiler-level primitive becomes processInCompilationMode(bool $isEnabled, \Closure $process): mixed - enter the requested compilation mode, run the operation, restore the previous mode in a finally block. AstProcessHook::withoutCompilationMode() stays as the consumer-facing shorthand and now delegates with $isEnabled = false, which is the direction AST consumers need. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015M297P4ypTeKaP2u2bfrLq
…ern instead Review feedback on #221: AstProcessHook::withoutCompilationMode() was a one-line delegate that only added surface. The bracket lives solely on Compiler::processInCompilationMode(); the AstProcessHook class docblock now shows how consumers bracket their tree work with it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015M297P4ypTeKaP2u2bfrLq
…r3us feat(system): consumer-safe file name and compilation-mode bracket for AST hooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automated cascade merge of
8.4intomaster(branch flow defined in.github/branch-flow.json).Resolve conflicts in favour of the newer engine structures where they touch
include/- regenerate headers on the target branch instead of merging them textually. See AGENTS.md.