Skip to content
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

Question: Possible to get whole body of function not one line? #66

Open
klebann opened this issue Dec 23, 2020 · 4 comments
Open

Question: Possible to get whole body of function not one line? #66

klebann opened this issue Dec 23, 2020 · 4 comments

Comments

@klebann
Copy link

klebann commented Dec 23, 2020

Is that possible to get whole body of function as a string when you find specific function in this function?

Example:

function(){
    $var = "not important";
    notme();
}

function2(){
    $var = "important";
    imhere();
}

Command: phpgrep find only imhere();

Output:

    $var = "important";
    imhere();
@klebann klebann changed the title Question: Get whole body of function not one line Question: Possible to get whole body of function not one line? Dec 23, 2020
@quasilyte
Copy link
Owner

Will context lines option be enought here (like -C in grep) or do you need an enclosing function?

What should happen if imhere() is located outside of the function?
What if containing function is 1000 lines long? :)

@klebann
Copy link
Author

klebann commented Dec 23, 2020

do you need an enclosing function?

yes

What if containing function is 1000 lines long?

nothing , I have plenty of memory 😄

What should happen if imhere() is located outside of the function?

do I have a choice?whatever will happen, I can handle it.

@quasilyte
Copy link
Owner

do I have a choice?whatever will happen, I can handle it.

I can't implement a feature if its semantics are not well-defined, this is why I'm asking corner-case questions.

The match can happen at a global scope where we have no function to print. Should these matches be ignored or they should be intermixed with function matches?

@klebann
Copy link
Author

klebann commented Dec 24, 2020

Intermixed with function matches

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

No branches or pull requests

2 participants