Skip to content

STDIN file contents not being populated in some cases #1340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
david-binda opened this issue Feb 7, 2017 · 0 comments · Fixed by #1341
Closed

STDIN file contents not being populated in some cases #1340

david-binda opened this issue Feb 7, 2017 · 0 comments · Fixed by #1341

Comments

@david-binda
Copy link
Contributor

In case the PHP Code Sniffer's CLI falls back to re-reading the STDIN in https://github.com/squizlabs/PHP_CodeSniffer/blob/ee3ce4b8ab6b5c815a06fea52ab480a69343134e/CodeSniffer/CLI.php#L1002,L1007 the value is not saved to the CLI values as stdin and thus the $fileContents is not reachable from within the Sniffs as if it would be in case the initial reading succeeded: https://github.com/squizlabs/PHP_CodeSniffer/blob/ee3ce4b8ab6b5c815a06fea52ab480a69343134e/CodeSniffer/CLI.php#L405,L418

I'm hitting the issue when passing an output of the svn can command to the PHPCS using pipes. When using the cat for outputting the file and piping it to PHPCS, everything seems to be working fine. This is, imho, related to the fact the initial stream reading is not blocking (which can't be changed to blocking).

Looks like saving the value to CLI values before it's passed to $phpcs->processFile() method might resolve the issue.

david-binda added a commit to david-binda/PHP_CodeSniffer that referenced this issue Feb 7, 2017
…>processFile()` method in case the input is obtained during the re-read in `PHP_CodeSniffer_CLI::process` method

fixes squizlabs#1340
@gsherwood gsherwood changed the title stdin CLI value not being populated STDIN fiule contents not being populated in some cases Feb 12, 2017
@gsherwood gsherwood changed the title STDIN fiule contents not being populated in some cases STDIN file contents not being populated in some cases Feb 12, 2017
gsherwood added a commit that referenced this issue Feb 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants