Skip to content

Commit

Permalink
The Internal.NoCodeFound error is no longer generated for content sou…
Browse files Browse the repository at this point in the history
…rced from STDIN (ref #993)
  • Loading branch information
gsherwood committed Dec 22, 2016
1 parent d0b5ec7 commit 5605491
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CodeSniffer/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,10 @@ public function start($contents=null)
// If short open tags are off but the file being checked uses
// short open tags, the whole content will be inline HTML
// and nothing will be checked. So try and handle this case.
if ($foundCode === false && $this->tokenizerType === 'PHP') {
// We don't show this error for STDIN because we can't be sure the content
// actually came directly from the user. It could be something like
// refs from a Git pre-push hook.
if ($foundCode === false && $this->tokenizerType === 'PHP' && $this->_file !== 'STDIN') {
$shortTags = (bool) ini_get('short_open_tag');
if ($shortTags === false) {
$error = '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.';
Expand Down
2 changes: 2 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
</stability>
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD 3-Clause License</license>
<notes>
- The Internal.NoCodeFound error is no longer generated for content sourced from STDIN
-- This should stop some Git hooks generating errors because PHPCS is trying to process the refs passed on STDIN
- Squiz.Commenting.DocCommentAlignment now checks comments on class properties defined using the VAR keyword
-- Thanks to Klaus Purer for the patch
- Fixed bug #1230 : JS tokeniser incorrectly tokenises bitwise shifts as comparison
Expand Down

0 comments on commit 5605491

Please sign in to comment.