Page MenuHomePhabricator

PHPCS is broken
Closed, DuplicatePublic

Description

Since D9034 is landed there are several issues with PHPCS. See D9034 for details.

Revisions and Commits

Event Timeline

sascha-egerer assigned this task to epriestley.
sascha-egerer raised the priority of this task from to Needs Triage.
sascha-egerer updated the task description. (Show Details)
sascha-egerer added a project: Arcanist.
sascha-egerer added a subscriber: sascha-egerer.

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

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>] ...
....

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)

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)

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