pmmp / ext-pmmpthread

Fork of https://github.com/krakjoe/pthreads with a revamped API and PHP 8.1+ support
Other
82 stars 15 forks source link

Scan op_array->literals for class and function dependencies #135

Open dktapps opened 9 months ago

dktapps commented 9 months ago

A possible rather simple solution to issues like #111 and #115.

My initial thought was to scan the op_array for opcodes like NEW, INIT_FCALL etc to find dependencies. However, these opcodes all have different operand layouts, making it particularly inconvenient to retrieve dependencies.

A simpler option, though a bit uglier, is to just scan op_array->literals for IS_STRING zvals and then check if there are any functions or classes in the current file with the same name. This might end up copying some irrelevant stuff in some cases (if a user string happens to have the same name as a function declared in the current file), but would probably be much more robust and require less maintenance.

dktapps commented 9 months ago

This is also a problem for global constants. Unfortunately, it's not possible to tell where a constant was declared, which is problematic.