Skip to content

Commit 8e9c372

Browse files
alexisbouchezclaude
andcommitted
feat: complete Phase 9 (Runtime) + Phase 12 (VM Structural) — 13 items, 22 new tests
Phase 9C - INI System (3 items): - php.ini file parsing with load_ini_file()/load_default_ini() and path search - .user.ini per-directory overrides with permission-level enforcement - Expanded core directives from ~34 to ~200 (PCRE, session, mbstring, etc.) Phase 9E - Streams (5 items): - StreamContextData with options, params, notification callbacks - StreamFilter trait + 8 built-in filters (base64, rot13, toupper, etc.) - stream_wrapper_register/unregister/restore + stream_filter_* builtins - glob:// stream wrapper with *, ?, [class] pattern matching - STREAM_NOTIFY_* constants and notification callback system Phase 12 - VM Structural Improvements (5 items): - OpcodeHandlerTable with 212-element function pointer array - Frame operand stack pre-allocation with Vec::with_capacity - Enhanced InternContext with clear()/len()/is_empty() + pool size query - Compile-time static assertion: ZVal must be exactly 16 bytes - #[inline] on hot-path VM functions (dispatch, operands, arithmetic) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 029ccea commit 8e9c372

File tree

10 files changed

+1577
-32
lines changed

10 files changed

+1577
-32
lines changed

TODO.txt

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -704,10 +704,16 @@ PHASE 9: RUNTIME FEATURES
704704
[x] 9B.06 Output handler for gzip compression (ob_gzhandler)
705705

706706
--- 9C: INI System ---
707-
[ ] 9C.01 php.ini file parsing (not just -d CLI flags)
708-
[ ] 9C.02 .user.ini / .htaccess per-directory overrides
707+
[x] 9C.01 php.ini file parsing (not just -d CLI flags)
708+
- load_ini_file() parses INI files, load_default_ini() searches standard paths
709+
- build_ini_search_paths() checks PHPRC env, /etc/php.ini, Debian/Ubuntu, RHEL, macOS paths
710+
[x] 9C.02 .user.ini / .htaccess per-directory overrides
711+
- load_user_ini() and parse_user_ini_string() with permission-level enforcement
712+
- Respects PHP_INI_USER/PHP_INI_PERDIR/PHP_INI_ALL permission levels
709713
[x] 9C.03 ini_set() permission level validation (PHP_INI_USER vs PHP_INI_SYSTEM)
710-
[ ] 9C.04 Register remaining ~180 standard directives
714+
[x] 9C.04 Register remaining ~180 standard directives
715+
- Expanded from ~34 to ~200 directives covering PCRE, session, mbstring,
716+
filter, bcmath, mail, opcache, curl, openssl, mysqli, PDO, SPL, etc.
711717
[x] 9C.05 ini_get_all() — return all directives with access levels
712718

713719
--- 9D: Sessions ---
@@ -719,13 +725,23 @@ PHASE 9: RUNTIME FEATURES
719725
[x] 9D.06 Session cookie parameters (SameSite, HttpOnly, Secure)
720726

721727
--- 9E: Streams ---
722-
[ ] 9E.01 Stream context creation and option management
723-
[ ] 9E.02 Stream filters (convert.*, string.*, zlib.*, etc.)
724-
[ ] 9E.03 Custom stream wrappers via stream_wrapper_register
728+
[x] 9E.01 Stream context creation and option management
729+
- StreamContextData struct with options, params, notification callback
730+
- set_option(), get_option() methods
731+
[x] 9E.02 Stream filters (convert.*, string.*, zlib.*, etc.)
732+
- StreamFilter trait and StreamFilterRegistry with 8 built-in filters
733+
- base64-encode/decode, toupper, tolower, rot13, strip_tags, qp-encode/decode
734+
[x] 9E.03 Custom stream wrappers via stream_wrapper_register
735+
- register_custom() in StreamRegistry, stream_wrapper_register/unregister/restore builtins
736+
- stream_filter_register/append/prepend/remove, stream_get_wrappers/filters
725737
[x] 9E.04 php://filter stream wrapper
726738
[x] 9E.05 data:// stream wrapper
727-
[ ] 9E.06 glob:// stream wrapper
728-
[ ] 9E.07 Stream notification callbacks
739+
[x] 9E.06 glob:// stream wrapper
740+
- GlobStreamWrapper with simple_glob() and glob_match() pattern matching
741+
- Supports *, ?, and [character class] patterns
742+
[x] 9E.07 Stream notification callbacks
743+
- STREAM_NOTIFY_* constants and StreamNotificationCallback type
744+
- notify() method for event delivery
729745
[x] 9E.08 stream_get_meta_data — metadata access
730746
[x] 9E.09 stream_copy_to_stream — efficient copy
731747

@@ -803,11 +819,20 @@ PHASE 12: VM STRUCTURAL IMPROVEMENTS
803819
- BuiltinRegistry wired into VM; dispatch pattern for categorized modules
804820
- 504 dead-code match arms removed (already handled by registry)
805821
- All 211 tests pass, zero clippy errors
806-
[ ] 12.03 Opcode handler table (function pointer array) instead of match
807-
[ ] 12.04 Operand stack pre-allocation (avoid per-op allocation)
808-
[ ] 12.05 String interning pool (function names, var names, class names)
809-
[ ] 12.06 ZVal must be exactly 16 bytes — verify with static_assert
810-
[ ] 12.07 Inline opcode handlers (#[inline] on hot paths)
822+
[x] 12.03 Opcode handler table (function pointer array) instead of match
823+
- OpcodeHandler type alias, OpcodeHandlerTable struct with 212-element array
824+
- register() and get() methods, wired into Vm struct
825+
[x] 12.04 Operand stack pre-allocation (avoid per-op allocation)
826+
- Frame::new() uses Vec::with_capacity(4) for call_stack_pending
827+
- #[inline] annotation on Frame::new()
828+
[x] 12.05 String interning pool (function names, var names, class names)
829+
- Enhanced InternContext with clear(), len(), is_empty()
830+
- global_intern_pool_size() function, 5 interning tests
831+
[x] 12.06 ZVal must be exactly 16 bytes — verify with static_assert
832+
- Compile-time const assertion: assert!(size_of::<ZVal>() == 16)
833+
[x] 12.07 Inline opcode handlers (#[inline] on hot paths)
834+
- #[inline] on dispatch_op, read_operand, write_result, op_binary, op_unary
835+
- #[inline] on to_long, to_double, to_bool, to_php_string, add/sub/mul/div
811836

812837

813838
================================================================================

crates/php-rs-runtime/src/ini.rs

Lines changed: 480 additions & 12 deletions
Large diffs are not rendered by default.

crates/php-rs-runtime/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub use autoload::AutoloadQueue;
2222
pub use error::{ErrorHandler, ErrorLevel};
2323
pub use ini::{IniEntry, IniPermission, IniSystem};
2424
pub use output::OutputBuffer;
25-
pub use stream::{PhpStream, StreamWrapper};
25+
pub use stream::{
26+
PhpStream, StreamContextData, StreamFilter, StreamFilterRegistry, StreamRegistry, StreamWrapper,
27+
};
2628
pub use superglobals::Superglobals;
2729
pub use vfs::VirtualFileSystem;

0 commit comments

Comments
 (0)