phpro / grumphp

A PHP code-quality tool
MIT License
4.15k stars 431 forks source link

php8 on windows error(amphp not compatibility php8?) #878

Closed haohetao closed 3 years ago

haohetao commented 3 years ago
Q A
Version 1.3.0
Bug? yes
New feature? no
Question? no
Documentation? no
Related tickets comma-separated list of related tickets\

grumphp.yml

    shell:
      scripts:
        - ["-c", "./yii api validate"]
      triggered_by: [php]

D:\sites\git\epmms2-award>vendor\bin\grumphp.bat run GrumPHP is sniffing your code! Running tasks with priority 0!

Running task 1/5: phpcs... Running task 2/5: phpcsfixer... Running task 3/5: shell... ✘ Running task 4/5: composer... Running task 5/5: yamllint... ✔ Aborted ... ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌ ▄███▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌ █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌ ▐█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌ ▀█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌ ▀▀▓▓▓▓▓▓▓▓▓▓▓▓█▀▀▀▀▀▀▀▀▀▀▀▀▀▀████████████▄ ▄███████ ██████████ ███████▀ ▀▀▀▀▀▄ ▄▀▀▀▀▀ █████ ▀ ▐████ ▐██ ▐██ ████▌ ████▌ ███ ▌██▌ ▄▄ ▄▄ ▐███ ███ ▄▄▄▄▄▄▄▄▄▄▄▄ ▐███ ██▄ ▐███████████████████████████ █▀███████████▀ ▀▀███████████ ██████████▄███████▄███████████ ▐█████████████████████████████ █████████████████████████████ ██ █████████████████████▐██▀ ▀ ▐███████████████████▌ ▐▀ ████▀████████▀▐███ ▀█▌ ▐█████ ██▌ ██▀ ▐▀

   ██████████████████████████████████
   █░░░░░░▀█▀░░░░░░▀█░░░░░░▀█▀░░░░░▀█
   █░░▐█▌░░█░░░██░░░█░░██░░░█░░░██░░█
   █░░▐█▌░░█░░░██░░░█░░██░░░█░░░██░░█
   █░░▐█▌░░█░░░██░░░█░░░░░░▄█░░▄▄▄▄▄█
   █░░▐█▌░░█░░░██░░░█░░░░████░░░░░░░█
   █░░░█░░░█▄░░░░░░▄█░░░░████▄░░░░░▄█
   ██████████████████████████████████

shell

The executable for "sh" could not be found. To skip commit checks, add -n or --no-verify flag to commit command PHP Fatal error: Uncaught TypeError: fclose(): supplied resource is not a valid stream resource in D:\sites\git\epmms2-award\vendor\amphp\process\lib\Internal\Windows\Runner.php:221 Stack trace:

0 D:\sites\git\epmms2-award\vendor\amphp\process\lib\Internal\Windows\Runner.php(221): fclose(Resource id #530)

1 D:\sites\git\epmms2-award\vendor\amphp\process\lib\Internal\Windows\Runner.php(201): Amp\Process\Internal\Windows\Runner->free(Object(Amp\Process\Internal\Windows\Handle))

2 D:\sites\git\epmms2-award\vendor\amphp\process\lib\Process.php(85): Amp\Process\Internal\Windows\Runner->destroy(Object(Amp\Process\Internal\Windows\Handle))

3 [internal function]: Amp\Process\Process->__destruct()

4 {main}

thrown in D:\sites\git\epmms2-award\vendor\amphp\process\lib\Internal\Windows\Runner.php on line 221

Fatal error: Uncaught TypeError: fclose(): supplied resource is not a valid stream resource in D:\sites\git\epmms2-award\vendor\amphp\process\lib\Internal\Windows\Runner.php:221 Stack trace:

0 D:\sites\git\epmms2-award\vendor\amphp\process\lib\Internal\Windows\Runner.php(221): fclose(Resource id #530)

1 D:\sites\git\epmms2-award\vendor\amphp\process\lib\Internal\Windows\Runner.php(201): Amp\Process\Internal\Windows\Runner->free(Object(Amp\Process\Internal\Windows\Handle))

2 D:\sites\git\epmms2-award\vendor\amphp\process\lib\Process.php(85): Amp\Process\Internal\Windows\Runner->destroy(Object(Amp\Process\Internal\Windows\Handle))

3 [internal function]: Amp\Process\Process->__destruct()

4 {main}

thrown in D:\sites\git\epmms2-award\vendor\amphp\process\lib\Internal\Windows\Runner.php on line 221

bally86 commented 3 years ago

Any solution yet?

veewee commented 3 years ago

No, feel free to provide more information or a bug fix. It makes sense that she'll is not available on windows. Amp should not crash because of that though.

haohetao commented 3 years ago

@bally86 use php7.4

bally86 commented 3 years ago

@bally86 use php7.4

That's not an option. All my systems and packages are based on PHP 8 now.

haohetao commented 3 years ago

@bally86 amphp has a lot of code that doesn't work on php8,I submitted the PR, but no one merged

veewee commented 3 years ago

@haohetao

Is this still an issue? Is it related to amphp or is it specific to our implementation of it?

Since the error is triggered in a stream that is being opened by amphp process, I assume that the issue lies in amphp.

haohetao commented 3 years ago

@veewee I send report involves multiple problems, including amphp related problems have been solved (https://github.com/amphp/process/pull/46). Problems with “shell task” should remain. For example, the following sentence is wrong.

The executable for "sh" could not be found.

veewee commented 3 years ago

Glad to hear the amphp issue got resolved!

If shell is not installed on the environment you are running GrumPHP, we won't be able to fix it from this package. If you do have a sh exectuable, it might not be in the PATH. But since it is windows, I assume the error message is as expected.

I am closing this one for now. Feel free to reopen an issue if there is still something going wrong.

underdpt commented 3 years ago

Hello,

I think we would need a new release for grumphp-shim. The phar install doesn't include latest amphp so it's still unusable in windows.

So far, I've done some quick tests with only a few tasks (composer, phpcs) and it's working fine once installed the package with dependencies.

veewee commented 3 years ago

Good point. I'll try to publish a new version somewhere next week!

veewee commented 3 years ago

@underdpt Tagged a new release with

  - Installing amphp/process (v1.1.1): Extracting archive

Should work fine on Windows now.