Description
Description
Revisions and Commits
Revisions and Commits
Related Objects
Related Objects
- Mentioned Here
- D9034: PHPCS supports reading from stdin.
Event Timeline
Comment Actions
I am not able to replicate this. What version of phpcs are you using?
$ cat test.php $ arc lint test.php >>> Lint for test.php: Warning (PHPCS.W.Internal.NoCodeFound) 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. >>> 1
Comment Actions
And you have this still applied?
public function supportsReadDataFromStdin() { return true; }
$ vendor/bin/phpcs --version PHP_CodeSniffer version 2.2.0 (stable) by Squiz (http://www.squiz.net)
The problem is that phpcs is called like phpcs < foo.php and if foo.php is empty no code is piped to phpcs and it thinks that no filename has been given.
Can you reproduce this?
$ echo "" > foo.php $ vendor/bin/phpcs --report=xml --standard=PSR2 < foo.php ERROR: You must supply at least one file or directory to process. Usage: phpcs [-nwlsaepvi] [-d key[=value]] [--colors] [--no-colors] [--report=<report>] [--report-file=<reportFile>] [--report-<report>=<reportFile>] ... ....
Comment Actions
I can't reproduce that unfortunately:
$ echo "" > test.php $ phpcs --report=xml --standard=PSR2 < test.php <?xml version="1.0" encoding="UTF-8"?> <phpcs version="2.2.0"> <file name="STDIN" errors="0" warnings="1" fixable="0"> <warning line="1" column="1" source="Internal.NoCodeFound" severity="5" fixable="0">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.</warning> </file> </phpcs> $ phpcs --version PHP_CodeSniffer version 2.2.0 (stable) by Squiz (http://www.squiz.net)
Comment Actions
oh ok... i can reproduce that on 2 machines. What's your OS? What's your php version?
I'm on MacOS 10.9.5
$ php -v PHP 5.6.4 (cli) (built: Jan 13 2015 15:11:56)
Comment Actions
As far as i can see this can't work but is a bug in PHPCS. https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/CLI.php#L875
But i really don't understand why it works on your machine...