php-spx
php-spx copied to clipboard
Closure names aliased & ambiguous in reports
A closure name, as returned/generated by the Zend Engine, follows this pattern \Foo\Bar{closure}
(when created by a class method) where Foo
is the namespace and Bar
the class.
Thus if the class's methods create several closures at several places then they will appear as a single closure and theirs stats will be merged.
Moreover a closure name does not bring any information about where it is created.
I just ran into this issue as well.
I think it would be good if SPX could append the line numbers of the closure, for example \Foo\Bar{closure}150-157
This way it's easy to identify exactly which closure in a given class was called.
Yes, we need something like this, but the line range will still fail with short arrow functions defined on the same line. Do you know how other profilers handle this case ?
My initial goal was to build a callgraph out of the data that SPX collects - similar to Blackfire.io
Here's a demo: https://demo.blackfire.io/profiles/d5f83d3d-ba09-43ee-9e33-51677cf9c988/graph?settings%5Bdimension%5D=wt&settings%5Bdisplay%5D=landscape&settings%5BtabPane%5D=nodes&selected=&callname=main()&constraintDoc=
They add the line numbers as the suffix - and in some cases also have some "ID"/hash, but I don't know how that gets calculated.