merge: cascade 8.4 into master (README, resolved) - #185
Merged
Conversation
…pe(), ClassSpecializer::evict() Dependant packages were reaching behind the API line for operations that had no named entry point: probing Core::$executor to ask "is the engine booted", deleting class-table buckets through the @internal HashTable::delete(), and pairing Core::sizeof(Core::type(...)) so a raw FFI\CType crossed the boundary. - ClassSpecializer::evict(): the destroying counterpart of specialize(). Removes the class-table bucket so destroy_zend_class() dismantles the entry now, while op_array-refcounted bodies shared with the source stay alive. Refuses internal and shared-memory (immutable/preloaded) entries. The explicit-teardown test now exercises it. - Core::sizeOfType(): the named form of the sizeof(type(...)) pair; Core::type() is @internal so no raw CType crosses the API line anymore. - Core::isUsable(): non-throwing projection of the boot guard, for consumers and test bootstraps deciding whether engine paths can run here at all - hand-rolled ffi.enable checks get the supported 'preload' mode wrong. - AGENTS.md: a 'Consuming z-engine from another package' section drawing the line those leaks crossed because it was never written down. No ReflectionClass::evict() mirror on purpose: an instance method destroying the entry its own wrapper points at invites use-after-free on $this. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019TGQqR7ByjHrVSYKVHPrkJ
Closes #21, open since 2019 on one blocker recorded in its own comments: 'the composer autoloader calls Core::init() before preload initialization'. An unconditional boot binds the definitions with FFI::cdef(), which lasts for the preload request only, and leaves an engine behind that turns the script's own Core::preload() into a no-op - the server starts and every request after it fails. bootstrap.php (autoload.files) therefore recognises the preload stage and serves it with Core::preload(), whose FFI::load() publishes the definitions under FFI_SCOPE for the life of the server; everything else gets Core::init(). The stage is identified by the one fact that distinguishes it - during preloading the script named by opcache.preload is the first file the process included. Verified end to end on a matching PHP line: FFI::scope('ZEngine') resolves in the request that follows, and does not when the preload script skips the boot. A host that cannot run the engine (no ext-ffi, ffi.enable=0, wrong PHP minor, no definitions for the platform) is left uninitialized in silence - throwing from an autoloaded file would break static analysis, FFI-disabled test jobs and composer-time tooling at require. Nothing is lost: Core::init() is idempotent, so code that needs the engine calls it and gets the same explanation this file swallowed. ZENGINE_AUTOBOOT=0 skips the boot entirely. Core::preload() is now idempotent too, so the explicit call an existing opcache.preload script makes after requiring the autoloader stays harmless. Review feedback on the API additions: - Core::isUsable() dropped - init() and isInitialized() are enough - evict() reads the class through ReflectionClass::isUserDefined()/ isImmutable()/isPreloaded() instead of ce_flags off the raw entry; the new isPreloaded() sits beside isImmutable() - the consumer section folded into 'Public APIs never leak CData', keeping the @internal / FFI-CData part Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019TGQqR7ByjHrVSYKVHPrkJ
PHP does not support opcache preloading on Windows at all, so both preload cases failed there: the engine reported 'Preloading is not supported on Windows', and the scratch script path went through a short name (RUNNER~1) whose tilde broke -d ini parsing before that. Guarded with the same skip the repository already uses for opcache.preload (issue #119), on the two cases that need it rather than the whole class - the opt-out and silent-failure cases are plain autoload behaviour and keep running everywhere. The --fail-on-skipped opcache gate runs on Linux and macOS, where preloading exists and neither case skips. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019TGQqR7ByjHrVSYKVHPrkJ
…audit-1t6xy7 feat: boot from Composer's autoloader (closes #21), plus ClassSpecializer::evict() and Core::sizeOfType()
Only README.md conflicted. The 8.4 side replaced the 'initialize the library once' block with the autoload bootstrap (#21); master had meanwhile appended a Windows note to that same block (5b0dee9), so the two sides edited one paragraph. Resolved in favour of the 8.4 text, with the Windows fact carried forward and restated for the new model: preloading does not exist there, so each process binds the definitions for itself - which is the same autoload bootstrap taking its other branch, not something the consumer does differently. No include/ conflicts, so nothing to regenerate. master's 8.5 version guard and headers are untouched. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019TGQqR7ByjHrVSYKVHPrkJ
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.
Resolved counterpart of the automated cascade #184, which is
dirtyand cannot be resolved in place — its head is the8.4release branch, and fixing it there would mean mergingmasterbackwards into 8.4, against the branch model (AGENTS.md: fixes cascade upward, never downward). Same approach as #182.The one conflict
README.md, and it is a genuine collision rather than header drift:8.4(feat: boot from Composer's autoloader (closes #21), plus ClassSpecializer::evict() and Core::sizeOfType() #183) replaced the "initialize the library once" block with the autoload bootstrap (Add automatic self-registration via Composer #21)masterhad meanwhile appended a Windows note to that same block (5b0dee9)Resolved in favour of the 8.4 text, carrying the Windows fact forward and restating it for the new model — preloading does not exist on Windows, so each process binds the definitions for itself, which is the same autoload bootstrap taking its other branch rather than anything the consumer does differently.
Everything else auto-merged:
AGENTS.md,composer.json,src/Core.php. Noinclude/conflicts, so nothing to regenerate.Verified on the merged tree
SUPPORTED_PHP_VERSION_ID = [80500, 80600],include/8.5untouchedbootstrap.php,tests/AutoBootTest.php,autoload.files,Core::sizeOfType(),Core::preload()idempotence guard,ClassSpecializer::evict(),ReflectionClass::isPreloaded()Core::isUsable()correctly absent (dropped during feat: boot from Composer's autoloader (closes #21), plus ClassSpecializer::evict() and Core::sizeOfType() #183 review)php -lclean on every changed fileCI on this branch is the real gate — it runs the full matrix against PHP 8.5, which is what #183 could not exercise.
Merging this closes the cascade and unblocks lisachenko/userland-php-generics#14, whose PHP 8.5 jobs are the only thing still red there (its PHP 8.4 jobs went green as soon as #183 landed).
🤖 Generated with Claude Code
https://claude.ai/code/session_019TGQqR7ByjHrVSYKVHPrkJ
Generated by Claude Code