Skip to content
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

phpcs reads from stdin which requires a terminal, and hangs if there are none. #993

Closed
masterzen opened this issue May 5, 2016 · 23 comments · Fixed by #1064
Closed

phpcs reads from stdin which requires a terminal, and hangs if there are none. #993

masterzen opened this issue May 5, 2016 · 23 comments · Fixed by #1064
Milestone

Comments

@masterzen
Copy link

With version 2.6.0, phpcs now tries to read content from stdin.

This of course either requires a terminal or an incoming stream from another process.
When running phpcs as part of a git pre-commit hook in git gui or any other GUI around git which doesn't allocate a terminal, this completely blocks the pre-commit process and and the GUI itself, the process is stuck in T state on linux or osx.

@gsherwood
Copy link
Member

As discussed on the linked PR, I've tried to replicate this issue using a pre-commit hook and git gui, but I'm not having any problems on 2.6.0.

Here is a quick recording of what I was doing on OS X:
git gui

So presumably, STDIN is available for my GUI but possibly not for yours.

Are you able to debug the code and see if there is an easy way to detect the difference between your command line and the GUI? Maybe something as simple as fopen() returning false?

@masterzen
Copy link
Author

Many thanks @gsherwood for your efforts trying to reproduce the issue.

The bash script I'm using is doing:

...
OUTPUT=$($PHPCS_BIN -s --standard=$PHPCS_CODING_STANDARD $EXTENSIONS $ENCODING $IGNORE $STAGED_FILES)
RETVAL=$?
...
if [ $RETVAL -ne 0 ]; then
    echo "$OUTPUT" | less
fi
exit $RETVAL

This might be the reason.
I'm going to change the script to not run in a subshell.

@masterzen
Copy link
Author

To make this script working one need to use:

OUTPUT=$(echo '' | $PHPCS_BIN -s --standard=$PHPCS_CODING_STANDARD $EXTENSIONS $ENCODING $IGNORE $STAGED_FILES)
...

To force the existence of stdin (at least that we can open it).

@gsherwood
Copy link
Member

Strange. I was using the exact same script you just linked to (you linked it in the PR as well) and was getting the result I posted. I also didn't think STDIN disappears when using subshells.

@nnnikolay
Copy link

Just want to share my case

I recently update phpcs to 2.6 and I've started to have the same problem with STDIN. I've never had it before.

I'm using phing to automate some build steps, and I'm running it from pre-push hook like this

#!/bin/bash

vendor/bin/phing verify-dev

I've following problem

FILE: STDIN
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 1 | WARNING | 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.
----------------------------------------------------------------------

Meanwhile if I'm running phpcs or with help phing vendor/bin/phing verify-dev from terminal it works fine

here is my phpcs-dev target which I have in build.xml

        <target name="phpcs-dev"
                description="Generate CodeSniffer report for Developer"
                depends="init">
            <exec spawn="false" executable="${php.bin.path}/phpcs" checkreturn="true" passthru="true">
                <arg line="--report=full" />
                <arg line="--standard=${project.basedir}/phpcs-ruleset.xml" />
                <arg line="${project.basedir}/App" />
            </exec>
        </target>

and it seems that chnages in my build.xml like this spawn="true" - solves the problem

@adamlc
Copy link

adamlc commented May 20, 2016

We're also having the same issue in our CI server which uses docker images. The blank echo above seemed to fix it too!

@gsherwood
Copy link
Member

I've tried replicating this again (with phing this time) and still can't.

It would be great if someone who can replicate it would change their PHPCS command to include "-vv" and grab the output. There is already code that checks if STDIN is just whitespace and ignores it if so, so I'm keen to see what content is actually in STDIN when this happens. It's obviously not whitespace.

@masterzen
Copy link
Author

@gsherwood I'm going to try using -vv and report.
BTW, on what version are you performing your tests?
I did my test with the release 2.6.0, but I will try with latest master in case there had been some changes.

@masterzen
Copy link
Author

-vv didn't bring any new information (I can't copy paste because git gui on my mac doesn't allow copy pasting of window content :().

So I added some echo around the fopen('php://stdin', 'r') block, and the freeze happens at the fgets(STDIN) line. Even rewriting it to fgets($handle) doesn't help.

Note that when git gui freezes it prints on the terminal:

[1]  + 6739 suspended (tty input)  hub gui

If I fg %1 this job from the terminal, it unblocks the whole git gui process and displays the phpcs output in the git gui window.

BTW, this is on osx, with PHP 5.6.18 (custom built), but I observed the same issue on a linux box (which I don't have access to right now).

@gsherwood
Copy link
Member

@masterzen Thanks for testing. I've been testing with the 2.6.0 version on OS X, and still can't get git gui to fail. I'm not sure what is different between our installs.

Your problem is obviously different from the one reported by @nnnikolay as your one is stuck waiting for input and their one is complaining that it got non-PHP input. So -vv probably isn't going to help you at all anyway.

I just wish I could replicate this problem so I could try some fixes.

addaleax added a commit to addaleax/PHP_CodeSniffer that referenced this issue Jul 11, 2016
Read stdin from the handle opened via `fopen('php://stdin')`, not
the original `STDIN` handle which may not have been affected
by the `stream_set_blocking()` call.

Fixes: squizlabs#993
@gsherwood
Copy link
Member

Is anyone here able to try the fix in @addaleax has provided in PR #1064 and see if that resolves your issues? I can't replicate any of the reported problems so I'm going to need help testing this one.

@masterzen
Copy link
Author

@gsherwood this unfortunately doesn't work (and I had tested this before).

The problem is that fgets blocks, probably because STDIN is not a real STDIN but a pipe to the bash process.

Here are the fd from the phpcs process:

php     66898 brice    0u   CHR               16,4 0t2940851     719 /dev/ttys004
php     66898 brice    1   PIPE 0xcf953a6717986d95     16384         ->0xcf953a672d473455
php     66898 brice    2   PIPE 0xcf953a672d472e55     16384         ->0xcf953a672d472915
php     66898 brice    3u   CHR               16,4 0t2940851     719 /dev/ttys004
php     66898 brice    4   PIPE 0xcf953a671640f1d5     16384         ->0xcf953a67164100d5
php     66898 brice    5   PIPE 0xcf953a67164100d5     16384         ->0xcf953a671640f1d5

stdin is a pipe that is connected to a bash process:

bash    66885 brice    0u   CHR               16,4 0t2944492     719 /dev/ttys004
bash    66885 brice    1   PIPE 0xcf953a672d472e55     16384         ->0xcf953a672d472915
bash    66885 brice    2   PIPE 0xcf953a672d472e55     16384         ->0xcf953a672d472915
bash    66885 brice    3   PIPE 0xcf953a672d473455     16384         ->0xcf953a6717986d95
bash    66885 brice    4   PIPE 0xcf953a671640f1d5     16384         ->0xcf953a67164100d5
bash    66885 brice    5   PIPE 0xcf953a67164100d5     16384         ->0xcf953a671640f1d5

which itself seems to be connected to the git gui process:

Wish    66824 brice    0u     CHR               16,4 0t2947173     719 /dev/ttys004
Wish    66824 brice    1u     CHR               16,4 0t2947173     719 /dev/ttys004
Wish    66824 brice    2u     CHR               16,4 0t2947173     719 /dev/ttys004
Wish    66824 brice    4     PIPE 0xcf953a671640f1d5     16384         ->0xcf953a67164100d5
Wish    66824 brice    5     PIPE 0xcf953a67164100d5     16384         ->0xcf953a671640f1d5
Wish    66824 brice   12     PIPE 0xcf953a672d472915     16384         ->0xcf953a672d472e55

I think that's the issue (probably that one of those pipe is blocking).

Now if I use the workaround (ie do $(echo '' | phpcs ...)):

phpcs:

php     69918 brice    0   PIPE 0xcf953a671640f1d5     16384
php     69918 brice    1   PIPE 0xcf953a672d473095     16384         ->0xcf953a6717984f95
php     69918 brice    2   PIPE 0xcf953a67164100d5     16384         ->0xcf953a672d472315
php     69918 brice    3   PIPE 0xcf953a671640f1d5     16384
php     69918 brice    4   PIPE 0xcf953a671640f295     16384         ->0xcf953a6717986d95
php     69918 brice    5   PIPE 0xcf953a6717986d95     16384         ->0xcf953a671640f295

bash child (echo ''):

bash    69916 brice    0u   CHR               16,4 0t2999785     719 /dev/ttys004
bash    69916 brice    1   PIPE 0xcf953a672d473095     16384         ->0xcf953a6717984f95
bash    69916 brice    2   PIPE 0xcf953a67164100d5     16384         ->0xcf953a672d472315
bash    69916 brice    4   PIPE 0xcf953a671640f295     16384         ->0xcf953a6717986d95
bash    69916 brice    5   PIPE 0xcf953a6717986d95     16384         ->0xcf953a671640f295

bash parent (the script that launches phpcs):

bash    69902 brice    0u   CHR               16,4 0t3002210     719 /dev/ttys004
bash    69902 brice    1   PIPE 0xcf953a67164100d5     16384         ->0xcf953a672d472315
bash    69902 brice    2   PIPE 0xcf953a67164100d5     16384         ->0xcf953a672d472315
bash    69902 brice    3   PIPE 0xcf953a6717984f95     16384         ->0xcf953a672d473095
bash    69902 brice    4   PIPE 0xcf953a671640f295     16384         ->0xcf953a6717986d95
bash    69902 brice    5   PIPE 0xcf953a6717986d95     16384         ->0xcf953a671640f295

git gui itself:

Wish    69475 brice    0u     CHR               16,4 0t3005503     719 /dev/ttys004
Wish    69475 brice    1u     CHR               16,4 0t3005503     719 /dev/ttys004
Wish    69475 brice    2u     CHR               16,4 0t3005503     719 /dev/ttys004
Wish    69475 brice    4     PIPE 0xcf953a671640f295     16384         ->0xcf953a6717986d95
Wish    69475 brice    5     PIPE 0xcf953a6717986d95     16384         ->0xcf953a671640f295
Wish    69475 brice   15     PIPE 0xcf953a672d472315     16384         ->0xcf953a67164100d5

First thing that is noticeable: phpcs STDOUT with the workaround is a PIPE and not directly a terminal. I'm not able to fully understand the way the pipes are connected together in the second tests, but it seems both phpcs and echo '' share the same pipe to the parent process.

I don't really understand the issue, but maybe that could help anyone here find a fix :)

@nnnikolay
Copy link

@gsherwood sorry for long silent.

the thing is, the problem is really strange, it's not appear every time, it looks like that it depends from your file state or something similar, it might be connected with changes in the shell or the git or both. But if you want I can try to explain with all all details... hopefully today will write it down

@gsherwood
Copy link
Member

Sorry, no idea how this got auto-closed when I merged the other PR.

@nnnikolay
Copy link

Clone please the following repo
https://github.com/nnnikolay/test-cs.git

  • run composer install
  • checkout to new branch
  • Then link the file pre-push from the source tree with the .git/hooks/pre-push hook
  • Then uncomment in the pre-push file the one single line and run git push -u origin your-branch

You'll see that

test > phpcs-dev:


FILE: STDIN
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 1 | WARNING | 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.
----------------------------------------------------------------------

Time: 48ms; Memory: 4Mb

My shell version is:

/bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.

And git is

git --version
git version 2.9.0
hub version 2.2.3

@gsherwood
Copy link
Member

@nnnikolay Thanks for posting that info. Unfortunately, I can't replicate any problems using either master or a new branch. I get good build results each time.

@nnnikolay
Copy link

@gsherwood Sad :-) But suggest then please how I can debug more here? Thanks

@gsherwood
Copy link
Member

Sad :-) But suggest then please how I can debug more here? Thanks

You could try adding -vv the PHPCS command and seeing what comes out. You should get info about the parsing and the entire file contents broken into tokens. That will show you what file is being checked and hopefully why PHPCS didn't see any content in it.

@alexander-akait
Copy link

@gsherwood have same error
Command lib/vendor/bin/phpcs . --standard=./ruleset.xml -vv
Run on git push hook. BTW work fine in git commit hook.

...
[lint:phpcs    ]        Process token 302 on line 35 [col:5;len:15;lvl:0;]: T_VARIABLE => $renderTemplate
[lint:phpcs    ]        Process token 303 on line 35 [col:20;len:1;lvl:0;]: T_CLOSE_PARENTHESIS => )
[lint:phpcs    ]        Process token 304 on line 35 [col:21;len:1;lvl:0;]: T_WHITESPACE => ·
[lint:phpcs    ]        Process token 305 on line 35 [col:22;len:1;lvl:0;]: T_OPEN_CURLY_BRACKET => {
[lint:phpcs    ]        => Found scope opener for 299:T_IF
[lint:phpcs    ]                * level increased *
[lint:phpcs    ]                * token 299:T_IF added to conditions array *
[lint:phpcs    ]                Process token 306 on line 35 [col:23;len:0;lvl:1;conds;T_IF;]: T_WHITESPACE => \n
[lint:phpcs    ]                Process token 307 on line 36 [col:1;len:4;lvl:1;conds;T_IF;]: T_WHITESPACE => ····
[lint:phpcs    ]                Process token 308 on line 36 [col:5;len:15;lvl:1;conds;T_IF;]: T_STRING => endTemplatePage
[lint:phpcs    ]                Process token 309 on line 36 [col:20;len:1;lvl:1;conds;T_IF;]: T_OPEN_PARENTHESIS => (
[lint:phpcs    ]                Process token 310 on line 36 [col:21;len:1;lvl:1;conds;T_IF;]: T_CLOSE_PARENTHESIS => )
[lint:phpcs    ]                Process token 311 on line 36 [col:22;len:1;lvl:1;conds;T_IF;]: T_SEMICOLON => ;
[lint:phpcs    ]                Process token 312 on line 36 [col:23;len:0;lvl:1;conds;T_IF;]: T_WHITESPACE => \n
[lint:phpcs    ]                Process token 313 on line 37 [col:1;len:1;lvl:1;conds;T_IF;]: T_CLOSE_CURLY_BRACKET => }
[lint:phpcs    ]                => Found scope closer for 305:T_OPEN_CURLY_BRACKET
[lint:phpcs    ]                * token T_IF removed from conditions array *
[lint:phpcs    ]                * level decreased *
[lint:phpcs    ]        Process token 314 on line 37 [col:2;len:0;lvl:0;]: T_WHITESPACE => \n
[lint:phpcs    ]        Process token 315 on line 38 [col:1;len:2;lvl:0;]: T_CLOSE_TAG => ?>\n
[lint:phpcs    ]        *** END LEVEL MAP ***
[lint:phpcs    ]        *** START ADDITIONAL PHP PROCESSING ***
[lint:phpcs    ]        * token 276 on line 28 changed from T_OPEN_SQUARE_BRACKET to T_OPEN_SHORT_ARRAY
[lint:phpcs    ]        * token 290 on line 31 changed from T_CLOSE_SQUARE_BRACKET to T_CLOSE_SHORT_ARRAY
[lint:phpcs    ]        * token 224 on line 20 changed from T_OPEN_SQUARE_BRACKET to T_OPEN_SHORT_ARRAY
[lint:phpcs    ]        * token 235 on line 20 changed from T_CLOSE_SQUARE_BRACKET to T_CLOSE_SHORT_ARRAY
[lint:phpcs    ]        * token 156 on line 17 changed from T_OPEN_SQUARE_BRACKET to T_OPEN_SHORT_ARRAY
[lint:phpcs    ]        * token 161 on line 17 changed from T_CLOSE_SQUARE_BRACKET to T_CLOSE_SHORT_ARRAY
[lint:phpcs    ]        *** END ADDITIONAL PHP PROCESSING ***
[lint:phpcs    ] [PHP => 316 tokens in 38 lines]... 
[lint:phpcs    ] Processing STDIN 
[lint:phpcs    ]        *** START PHP TOKENIZING ***
[lint:phpcs    ]        Process token [0]: T_INLINE_HTML => refs/heads/master·790d008c03fa4f0d3032c1eea86d354d2fed2798·refs/heads/master·69d3c2c763012008481956301fc1d67ead83c39c\n
[lint:phpcs    ]        *** END PHP TOKENIZING ***
[lint:phpcs    ]        *** START TOKEN MAP ***
[lint:phpcs    ]        *** END TOKEN MAP ***
[lint:phpcs    ]        *** START SCOPE MAP ***
[lint:phpcs    ]        *** END SCOPE MAP ***
[lint:phpcs    ]        *** START LEVEL MAP ***
[lint:phpcs    ]        Process token 0 on line 1 [col:1;len:117;lvl:0;]: T_INLINE_HTML => refs/heads/master·790d008c03fa4f0d3032c1eea86d354d2fed2798·refs/heads/master·69d3c2c763012008481956301fc1d67ead83c39c\n
[lint:phpcs    ]        *** END LEVEL MAP ***
[lint:phpcs    ]        *** START ADDITIONAL PHP PROCESSING ***
[lint:phpcs    ]        *** END ADDITIONAL PHP PROCESSING ***
[lint:phpcs    ] [PHP => 1 tokens in 1 lines]... 
[lint:phpcs    ] DONE in 0ms (0 errors, 1 warnings)
[lint:phpcs    ] 
[lint:phpcs    ] FILE: STDIN
[lint:phpcs    ] ----------------------------------------------------------------------
[lint:phpcs    ] FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
[lint:phpcs    ] ----------------------------------------------------------------------
[lint:phpcs    ]  1 | WARNING | No PHP code was found in this file and short open tags are
[lint:phpcs    ]    |         | not allowed by this install of PHP. This file may be using
[lint:phpcs    ]    |         | short open tags but PHP does not allow them.
[lint:phpcs    ]    |         | (Internal.NoCodeFound)
[lint:phpcs    ] ----------------------------------------------------------------------
[lint:phpcs    ] 
[lint:phpcs    ] Time: 1 mins, 49.89 secs; Memory: 46Mb

@nnnikolay
Copy link

For us as a solution was these lines in ruleset file

<rule ref="Internal.NoCodeFound">
        <severity>0</severity>
</rule>

@alexander-akait
Copy link

@nnnikolay thanks! I am wait that says @gsherwood

@gsherwood
Copy link
Member

gsherwood commented Dec 22, 2016

@gsherwood have same error

The content being passed to PHPCS on STDIN is:

refs/heads/master 790d008c03fa4f0d3032c1eea86d354d2fed2798 refs/heads/master 69d3c2c763012008481956301fc1d67ead83c39c

Which appears to be the documented STDIN for the pre-push hook. Adding that change to silence the Internal.NoCodeFound error would work in this specific case, but it would be nice if PHPCS could detect that STDIN is filled with Git hook info and can be ignored. I'll see if that is possible.

Edit: The STDIN formats for the hooks are too different to be accurate. It's probably easier if PHPCS just stops generating Internal.NoCodeFound for STDIN content, which will effectively ignore this kind of thing.

gsherwood added a commit that referenced this issue Dec 22, 2016
@gsherwood
Copy link
Member

@nnnikolay @evilebottnawi I've pushed a change which should make it unnecessary to mute the Internal.NoCodeFound error message in your ruleset from the next version.

This doesn't solve the original issue with PHPCS hanging while looking for STDIN, so I'll need to keep waiting and see if anyone else is able to replicate and debug the issue.

rjkip pushed a commit to ibuildingsnl/qa-tools that referenced this issue Feb 9, 2017
Blank line is needed to provide STDIN input to phpcs when phpcs is called from the Git pre-push hook context. See squizlabs/PHP_CodeSniffer#993.

Otherwise, phpcs outputs the following:

    vendor/bin/phpcs --standard=phpcs.xml --extensions=php --report=full ./src

    FILE: STDIN
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------
     1 | WARNING | 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.
    ----------------------------------------------------------------------
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue May 18, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()` and `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue May 18, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()` and `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue May 27, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()` and `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
@gsherwood gsherwood added this to the 3.2.0 milestone Jun 13, 2017
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue Jul 18, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()` and `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue Aug 18, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()` and `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue Sep 4, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()` and `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue Sep 21, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()` and `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue Sep 26, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()` and `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue Oct 12, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()` and `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue Oct 22, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()` and `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue Oct 28, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()` and `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue Oct 28, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()` and `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue Oct 28, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()`, `tty`, and, `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue Oct 28, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()`, `tty`, and, `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue Oct 28, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()`, `tty`, and, `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
arnested added a commit to arnested/PHP_CodeSniffer that referenced this issue Nov 2, 2017
Non-blocking reading from stdin was introduced in
80b156d because we had problems with
auto detecting whether we should read from stdin or not. Combining
`posix_isatty()`, `tty`, and, `feof()` can get us back to blocking read.

By going back to blocking read from stdin we can avoid the extra check
introduced in 23bd023 for Windows.

We can also avoid the "read by line" and "usleep" introduced
8d669c5 and
63fafe0. They where introduced trying
to solve what is possible the same problem still reported in squizlabs#1472.

Fixes squizlabs#993.
Fixes squizlabs#1472.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants