lisachenko / z-engine

:zap: PHP Engine Direct API
MIT License
448 stars 22 forks source link

[Feature] Provide integration with zend_ast_process hook #27

Closed lisachenko closed 4 years ago

lisachenko commented 4 years ago

PHP provides a zend_ast_process hook. It is called for every compiled script and allows to modify the AST after it is parsed and created. This hook can be used for runtime source-code transformation, optimization, etc as it will be possible to completely rewrite AST with another one.

For example of AST transformation, please see https://github.com/GoogleCloudPlatform/stackdriver-debugger-php-extension/blob/master/docs/design.md#modifying-source-at-compilation-time

This feature also should be useful for AOP, Design-by-Contract frameworks, tracing tools and much more.