Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.2

Request #12952 short open tags = nothing happens
Submitted: 2008-01-21 22:00 UTC
From: fmpwizard Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.0.0)
PHP Version: 5.2.5 OS: Linux (Fedora 8)
Roadmaps: (Not assigned)    
Subscription  


 [2008-01-21 22:00 UTC] fmpwizard (Diego Medina)
Description: ------------ If the php file you send to phpcs has short open tags (<?) instead of the normal (<?php) there is no output. Test script: --------------- <? echo "hi"; ?> Expected result: ---------------- Warning/Error (up to you) use of short open tags. Actual result: -------------- nothing happens. The file seems not to be processed.

Comments

 [2008-01-21 22:20 UTC] squiz (Greg Sherwood)
This would happen if your PHP CLI has disabled the use of short open tags. Testing on a PHP CLI that allows them works for me. You can check this by looking at the CLI php.ini and seeing if short_open_tag is set to 0, or by just trying to run the PHP script directly.
 [2008-01-25 21:57 UTC] squiz (Greg Sherwood)
Can you please let me know if the php.ini setting was the problem.
 [2008-01-26 00:50 UTC] fmpwizard (Diego Medina)
Hi, Sorry for the delay, but yes, the php.ini settings were the problem. Now, could it be a "feature request" to have it return an error if the php.ini settings do not allow short tag and the script does use them? Regards,
 [2008-01-26 03:51 UTC] squiz (Greg Sherwood)
Thanks for getting back to me. I'll leave this as a feature request.
 [2009-07-02 13:07 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. You now get a message like this: FILE: /Users/gsherwood/PHP_CodeSniffer/temp.php -------------------------------------------------------------------------------- FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S) -------------------------------------------------------------------------------- 1 | WARNING | No PHP code was found in this file and short open tags are not | | allowed by this install of PHP. This file may be using short | | open tags but PHP does not allow them. --------------------------------------------------------------------------------
 [2010-02-02 20:26 UTC] lcoffincec (Lawrence Coffin)
Is there a way to disable this check/warning? If there's no PHP code, why throw this error? We use .html endings whether or not there is PHP code in the file -- yes, that means that all plain HTML files are run the through the PHP parser, but that's a small overhead we are ok with. (We also have only two or three files that *don't* have PHP in them.) So we run all .html files through phpcs. We just upgraded and now we're getting these error messages and it is stopping our automated builds.
 [2010-02-02 21:33 UTC] lcoffincec (Lawrence Coffin)
A few more comments about this check: A) This warning should be off by default, with the option to turn the warning on if the user specifies B) This is *valid* PHP "code": <h1>Hello World!</h1> ... i.e. it's valid contents for a PHP file and shouldn't throw an error. C) Your check won't catch the short tag usage in this file: <?php echo "Hello "; ?> <? echo "World\n"; ?> D) If you really want to check for short PHP tags when the parser is skipping over them, why not explicitly check for them? I.e. do a stristr or preg match on the file contents (or just the non-parsed parts if those are available) for your short open tags? That way you won't be throwing a warning about something that might or might *not* be there... If it's not there, don't throw the warning... -L
 [2010-02-03 04:07 UTC] squiz (Greg Sherwood)
You can't disable this message currently, but you will be able to disable individual messages in PHP_CodeSniffer 1.3.0, which is currently in development. It will probably be a couple of weeks before the SVN version allows this.