Skip to content

Commit 6540b92

Browse files
committed
add function.get_lineno
function line number represents the first line of the definition of the currently executing function, which can differ from execute_data.opcode rename execute_data.get_lineno to get_opline_lineno to better describe what the value is
1 parent 5021078 commit 6540b92

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

phper/src/functions.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,17 @@ impl ZFunc {
670670
}
671671
}
672672

673+
/// Gets the line number of the declaration of the currently
674+
/// executing function.
675+
pub fn get_lineno(&self) -> Option<u32> {
676+
unsafe {
677+
match u32::from(self.inner.type_) {
678+
ZEND_USER_FUNCTION | ZEND_EVAL_CODE => Some(self.inner.op_array.line_start),
679+
_ => None,
680+
}
681+
}
682+
}
683+
673684
/// Get the function or method fully-qualified name.
674685
pub fn get_function_or_method_name(&self) -> ZString {
675686
unsafe {

phper/src/values.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl ExecuteData {
133133
/// Gets the current opline line number if available. This represents the
134134
/// line number in the source code where the current operation is being
135135
/// executed.
136-
pub fn get_lineno(&self) -> Option<u32> {
136+
pub fn get_opline_lineno(&self) -> Option<u32> {
137137
unsafe {
138138
match u32::from((*self.inner.func).type_) {
139139
ZEND_USER_FUNCTION | ZEND_EVAL_CODE => {

0 commit comments

Comments
 (0)