-
Notifications
You must be signed in to change notification settings - Fork 20
provide access to return_value, function's type, filename, line number #217
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
base: master
Are you sure you want to change the base?
Conversation
When observing a function via observer API or zend_execute_*, these additional functions allow looking up the function's type and the filename (for user functions and eval'd code). From ExecuteData we can also retrieve the return value in a number of ways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request enhances the phper
crate by adding utility methods to access function metadata and execution context information when working with PHP internals from Rust.
- Added function type and filename retrieval methods to
ZFunc
- Added line number and return value access methods to
ExecuteData
- Provided multiple variants for return value access (immutable, mutable, and raw pointers)
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
phper/src/functions.rs | Adds get_type() and get_filename() methods to ZFunc for retrieving function metadata |
phper/src/values.rs | Adds get_lineno() and return value access methods to ExecuteData for execution context information |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
phper/src/functions.rs
Outdated
/// Get the type of the function (ZEND_USER_FUNCTION, | ||
/// ZEND_INTERNAL_FUNCTION, etc). | ||
pub fn get_type(&self) -> u8 { | ||
unsafe { self.inner.type_ } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider returning a more type-safe enum instead of a raw u8. This would make the API more self-documenting and prevent invalid function type values.
unsafe { self.inner.type_ } | |
pub fn get_type(&self) -> Option<FunctionType> { | |
FunctionType::from_u8(unsafe { self.inner.type_ }) |
Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <[email protected]>
…xecute_data_retval
This pull request adds new utility methods to the
ZFunc
andExecuteData
structs in thephper
crate, providing improved access to function metadata and execution context information. These additions make it easier to retrieve function types, filenames, line numbers, and return values when working with PHP internals from Rust.Function metadata access improvements:
get_type
toZFunc
for retrieving the function type (e.g.,ZEND_USER_FUNCTION
,ZEND_INTERNAL_FUNCTION
).get_filename
toZFunc
to obtain the filename for user-defined or eval'd functions using theop_array
.Execution context access improvements:
get_lineno
toExecuteData
to retrieve the current source code line number for user or eval'd functions.get_return_value
,get_return_value_mut
,get_return_value_mut_ptr
, andget_return_value_ptr
toExecuteData
for accessing the return value in various forms (immutable, mutable, and raw pointers).