Skip to content

Migration of ZString, ZArray, ZObject to EBox #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 6, 2025

Conversation

jmjoy
Copy link
Member

@jmjoy jmjoy commented Jun 5, 2025

This pull request introduces significant refactoring across multiple components of the codebase to enhance memory management, improve type safety, and simplify the implementation of core structures. Key changes include transitioning to the EBox smart pointer for memory management, streamlining object and array handling, and updating type conversions for better compatibility with the Zend Engine.

Memory Management Improvements:

  • Introduced EBox<T> in phper/src/alloc.rs as a smart pointer for PHP values allocated in Zend Engine memory, replacing manual memory management. It handles deallocation automatically and provides safe access to PHP resources.
  • Updated ZObject and StateObject<T> in phper/src/objects.rs to use EBox<T> for memory management, simplifying their implementation and ensuring proper cleanup. [1] [2]

Array Handling Enhancements:

  • Refactored ZArray in phper/src/arrays.rs to use EBox<ZArr> for memory management, replacing manual pointer handling and improving safety. [1] [2]
  • Added a Drop implementation for ZArr to ensure proper memory cleanup when arrays are destroyed.

Type Conversion Updates:

  • Standardized pointer casting for type conversions across the codebase to ensure compatibility with Zend Engine APIs. Examples include updates in phper/src/classes.rs, phper/src/functions.rs, and phper/src/objects.rs. [1] [2] [3]

Test Improvements:

  • Added an assertion to verify HTTP response status codes in integration tests for the HTTP server.

Documentation and Cleanup:

  • Removed outdated ebox! macro and associated EBox implementation from phper-alloc/src/lib.rs and phper-alloc/src/macros.rs. These have been replaced with the new EBox implementation in phper/src/alloc.rs. [1] [2]
  • Updated documentation for ZObject and StateObject<T> to reflect their new implementations using EBox. [1] [2]

@jmjoy jmjoy marked this pull request as ready for review June 6, 2025 01:19
@jmjoy jmjoy merged commit 9e1f1d0 into phper-framework:master Jun 6, 2025
22 checks passed
@jmjoy jmjoy deleted the merge branch June 6, 2025 01:19
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.

1 participant