문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top