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.
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.