There should be PHP syntax checking before token will be added.
Currently I've got custom token which have value:
Parse error: syntax error, unexpected $end, expecting ',' or ';' in D:\bro\workspace\Websites\XComKids\trunk\sites\all\modules\contributions\token_custom\token_custom.module(31) : eval()'d code on line 1
Comments
Comment #1
hanoiiIt's not that straightforward to add syntax checking to PHP. This is after all and advance module and I believe that most parts where PHP code is accepted you can make mistakes in the syntax causing same errors like yours to happen. If you can come with a proper solution to do any good syntax checking, patch are welcome. I tried looking for eval() return code, but two things to mention there, PHP code is actually evaluated throwing the same errors again, and I can't just look for a FALSE value en eval, because PHP code might return that as well.
Comment #2
kenorb commentedYou can test this code with eval() during validation.
http://uk3.php.net/eval
Comment #3
hanoiiI tried that, I explained it in the above comment. By running eval() during validation, the code is actually ran and the warning will be thrown, and there's a chance that the evaluated code returns FALSE in which case testing eval() will fail but with a good PHP code.
Comment #4
seancr commentedAdding syntax checking to PHP is a rediculous idea. What I would like to see, however, is some more documentation on this module. Is there a way to evaluate a custom token, aside from placing it somewhere to be evaluated?