Skip to content

merge: cascade 8.4 into master - #222

Merged
lisachenko merged 4 commits into
masterfrom
8.4
Aug 15, 2026
Merged

merge: cascade 8.4 into master#222
lisachenko merged 4 commits into
masterfrom
8.4

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Automated cascade merge of 8.4 into master (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.

claude and others added 4 commits August 15, 2026 05:43
…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
@lisachenko
lisachenko merged commit 29d2f3e into master Aug 15, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants