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)    
Comments Add Comment Add patch

Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem : 21 - 13 = ?

 [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- 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


 [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: ee8ada65e7119