Support: How to parse a statement and methods
What an amazing tool! I rarely use it directly, but many of the tools I use depend on it.
But today I'm trying to use it directly, and stuck on how to loop through a $stmt.
public function testDemo(): void
{
$browser = $this->pantherBrowser()
->visit('/')
->assertOn('/')
->takeScreenshot('home.png')
->visit('/en/batsi#tab-locations')
->takeScreenshot('basti-locations.png')
;
$browser
->click('#tab-artists')
->takeScreenshot('artists.png')
;
}
I want to loop through each statement and get back each method call, along with its parameters.
Can anyone point me in the right direction? Thx.
I would put the code in question into a web-ui e.g. https://phpast.com/ or https://getrector.com/ast which generates a "clickable-ast".
that way you get an overview how the code is represented in AST and how you can access all the required information.
depending on what you need, you usually use addVisitor and NodeTraverser (see readme of this project) and collect all you need
Thanks!