We use a tokenizer to analyze the code statically, as well as to change the code to perform runtime checks for certain things. This is done with the help of a tokenizer and scripts based on a tokenizer. Since the tokenizer is the same that PHP uses, it improves your luck in writing your own.
I have seen people who use regular expressions to try to parse a language. This is a really bad idea.
But...
Since PHP is a rather stupid-simple grammar, and you have access to the tokenizer, you can actually stop most of the bad state by discarding variable functions and allowing only a small number of white functions. If you don't need OOP, even better.
However, we do not feel confident enough that we have nailed 100% of the problems, and we use this to power the sandbox for backend users who pay customers, and not every user on planet Earth, using the keyboard and, possibly, anger.
I also think that people who poo-poo the idea of ββ100% as "bad practice" should get the key. There are reasons for this.
source share