[TYPO3-team-core-v5] Sniff checking for PHP open tags - problem to solve

Tim Eilers tim.eilers at web.de
Fri Jun 6 20:33:06 CEST 2008


Karsten Dambekalns schrieb:
> Hi.

Hi Karsten,

at first (also an answer to  the other post of you): When i begin to 
develop my first step is to update the FLOW3 checkout. I wonder why not 
everyone is doing this.

Second: Malte is currently refactoring the whole FLOW3CGL package, so 
the code in the svn is a little bit outdated until he will commit. I am 
waiting for this refactoring, because i need to use some of the original 
codesniffer classes (or at least the "copies" Malte seems to create at 
the moment). I don't understand enough of the framework to help him :(
When he is finished i hope i am able to continue my sniffs and the 
errors you noticed...

Now to your post:

> I am currently looking at the FLOW3CGL code, and found there is a
> sniff to check there is only one PHP open tag in a file.
> 
> The fixture for the unit test for that sniff is
> F3_FLOW3CGL_Checks_FileStructure_FixturesOpenTagSniff_MoreThanOne,
> and contains one of "<?php" and "<?". The sniff does not detect the
> second PHP open tag on my machine - because I have short_open_tag set
> to off in php.ini.
> 
> This means the tokenizer doesn't see "<?" as a tag. And it means that
> if short_open_tag is off, we cannot check for "<?". I suggest to
> change the fixture to contain to long PHP open tags and just accept
> the risk of missing broken code with the sniff...
> 
> What do you think?

Phew, i never heard of that php.ini option until today... i have to 
check what token php recognizes instead of T_OPEN_TAG, and what it 
recognizes before and after. I will do that the next days. Perhaps i can 
  optimise the sniff somehow.

I agree to you suggestion to change the fixtures (which you already 
made, like i see in the svn repo). I believe that not much developers 
have set that option in php.ini, so the risk of broken code is very low.

> Regards, Karsten

Cheers,
Tim.


More information about the TYPO3-team-core-v5 mailing list