Skip to content

Commit 84adb0b

Browse files
authored
adding function start and end line number (#219)
1 parent 5021078 commit 84adb0b

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

phper-doc/doc/_06_module/_02_register_functions/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ The output of `php --re` for this function would look like:
115115
Function [ <internal:integration> function my_function ] {
116116
117117
- Parameters [3] {
118-
Parameter #0 [ <required> ?class_name $a_class ]
118+
Parameter #0 [ <required> ?\MyNamespace\MyInterface $a_class ]
119119
Parameter #1 [ <optional> string $name = 'my_default' ]
120120
Parameter #2 [ <optional> bool $optional_bool = <default> ]
121121
}

phper/src/functions.rs

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

673+
/// Gets the start line number of the declaration of the currently
674+
/// executing function.
675+
pub fn get_line_start(&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+
684+
/// Gets the end line number of the declaration of the currently
685+
/// executing function.
686+
pub fn get_line_end(&self) -> Option<u32> {
687+
unsafe {
688+
match u32::from(self.inner.type_) {
689+
ZEND_USER_FUNCTION | ZEND_EVAL_CODE => Some(self.inner.op_array.line_end),
690+
_ => None,
691+
}
692+
}
693+
}
694+
673695
/// Get the function or method fully-qualified name.
674696
pub fn get_function_or_method_name(&self) -> ZString {
675697
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)