Re: Support execution scope realization at runtime (or last pieces forprivate class support)
| From: | Andrea Faulds | Date: | Thu, 29 Oct 2015 18:41:06 +0000 |
| Subject: | Re: Support execution scope realization at runtime (or last pieces forprivate class support) | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-89006@lists.php.net to get a copy of this message | ||
Hi Guilherme,
guilhermeblanco@gmail.com wrote:
Currently, there's no way to determine at runtime what is the scope of the execution. This means you can't resolve if the current instruction is happening on a top-level scope, in a class definition, namespace, function or method. Together with this (maybe even more importantly), there's no way to resolve namespaces in any way, since they only exist up to compile time (they become part of class name through string append), and no real data structure around it exists. I was forced to create a weird string check to make it work... =(Making plain string literals in function calls be interpreted differently depending on context does not sound like a good idea to me. Functions shouldn't rely on hidden (non-syntactically-obvious) contextual information; I think func_get_args() et al. were a mistake. I'm not sure why we'd need to resolve namespaces at runtime anyway. If you just need to pass the name of a class to a function, we have ::class. Is there some use-case I'm unaware of? Thanks. -- Andrea Faulds http://ajf.me/