Question

I want to get the total number of opcodes a given (user-defined) function has.

For my purpose, I'm not interested in knowing what the specific opcodes are, just how many exist.

I know of two PECL extensions that would allow me to get this information easily:

Unfortunately, vld only dumps information for a whole script/file (I just want the function). On the other hand, parsekit looks great but it (still) is incompatible with PHP 5.4, which is a shame. I know I could patch it, but I would rather not get my hands dirty and wait for the fix to be included in the main package.

So my question is, is it possible to extrapolate the number of opcodes from the source code tokens?

If yes, what tokens should I ignore / combine / count?

Was it helpful?

Solution

After seeing this I am now 100% sure it would be a major headache to reliably extract the opcodes.

Basically, I would have to write a PHP parser in PHP, which isn't an option.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top