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

Request #20481 detect/ignore shebang as first line
Submitted: 2015-01-08 06:14 UTC
From: flyingmana Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version Unknown)
PHP Version: 5.5.20 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2015-01-08 06:14 UTC] flyingmana (Daniel Fahlke)
Description: ------------ the detection for a php opening tag as first content is not complete , as a shebang is valid content here in general (I dont know actual versions, as I got this error on scrutinizer- ci.com and assumed its a general problem) Test script: --------------- #!/usr/bin/env php <?php //some code Actual result: -------------- The opening PHP tag must be the first content in the file

Comments

 [2015-01-09 04:30 UTC] squiz (Greg Sherwood)
-Assigned To: +Assigned To: squiz
The sniffs that would report this error are not included in any of the standards that come with PHP_CodeSniffer; they are only in the Generic sniff collection. Are you using a custom standard with scrutinizer-ci or is it a generic check they are doing? Never the less, there are 2 sniffs that report errors with code like that: PHP files must only contain PHP code (Generic.Files.InlineHTML.Found); and The opening PHP tag must be the first content in the file (Generic.PHP.CharacterBeforePHPOpeningTag.Found) I'll look into getting those sniffs to allow shebang lines in case you are using one of those. If it is another, please let me know the error message and the sniff code (use the -s command line argument to see the code).
 [2015-01-09 04:59 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
I've made the change for both sniffs here: https://github.com/squizlabs/PHP_CodeSniffer/commit/96c83a2437c41c8d196090cd6fa ee8ada65e7119