# Inject code within Compiler?

- Thread: https://externals.io/message/56640
- Original archive: https://news-web.php.net/php.internals/56640
- Started by Clint M Priest on 2011-11-26T01:47:14+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #56640 — Clint M Priest — 2011-11-26T01:47:14+00:00

URL: https://externals.io/message/56640#56640

Trying implement empty getter/setter syntax such as:

public $Hours {
   get;
   set;
}

Is there any way to "inject" code into the compile process?

I'm trying via (just some proof of concept code, ignore the buffer overrun potential)

                                                char injected_code[1024] = "";
                                                sprintf((char*)&injected_code, "{ return $this->%s; }", Z_STRVAL(var_name->u.constant));

                                                znode *injected_node = emalloc(sizeof(znode));
                                                Z_STRVAL(injected_node->u.constant) = (char*)&injected_code;
                                                Z_STRLEN(injected_node->u.constant) = strlen(injected_code);
                                                zend_do_abstract_method(function_token, modifiers, injected_node TSRMLS_CC);

However this is causing a segfault, I'm assuming this is because I'm not initializing something of the znode properly.

How can I do this?

Thanks,

-Clint
