laravel / pint

Laravel Pint is an opinionated PHP code style fixer for minimalists.
https://laravel.com/docs/pint
MIT License
2.78k stars 144 forks source link

Different test results depending on environment #15

Closed chmoelders closed 2 years ago

chmoelders commented 2 years ago

Description:

I get different results depending on where I start pint.

Running in sail with PHP 8.0.19: ./vendor/bin/pint --test => PASS

Running on MacOS with PHP 8.0.13: : ./vendor/bin/pint --test => FAIL

I assume, formatting has nothing to do with the PHP version. Can someone explain this to me?

pint-output
nunomaduro commented 2 years ago

Can you share same output, with the option -v?

nunomaduro commented 2 years ago

Once you share more output, we will re-open the issue.

toyi commented 2 years ago

@nunomaduro It is pretty strange.

I had two environments with almost the same php version (8.1.3 vs 8.1.7). I experienced different test results, but the code was a little bit complicated and I tried to simplify so it is more readable.

Since then, everything works fine, even when I rolled back the changes.

Before making any changes, it was 100% reproductible and the problem was during a method_argument_space check, where a comma was separating two variables in a use clause. I don't have any log of this and now it's working without changing anything.

Fortunately, I reproduced the problem in another project.

At the moment, with two opened terminals, this is the result directly on the host machine:

┌──(toyi㉿toyi-MS-7D32)-[~/Projects/xxxxxx-api]
└─$ ./vendor/bin/pint --preset laravel --test -vvv

Box Requirements Checker
========================

> Using PHP 8.1.7
> PHP is using the following php.ini file:
  /etc/php/8.1/cli/php.ini

> Checking Box requirements:
  ✔ The application requires the version "^8.0" or greater.
  ✔ The application requires the extension "zlib".
  ✔ The application requires the extension "json".
  ✔ The application requires the extension "tokenizer".
  ✔ The application requires the extension "xml".

 [OK] Your system is ready to run the application.                                                                                                             

  ............................................................................................

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Laravel  
    PASS   ......................................................................................................................................... 92 files

and this is the result in a vagrant box:

vagrant@xxxxxx-api:~/code$ ./vendor/bin/pint --preset laravel --test -vvv

Box Requirements Checker
========================

> Using PHP 8.1.3
> PHP is using the following php.ini file:
  /etc/php/8.1/cli/php.ini

> Checking Box requirements:
  ✔ The application requires the version "^8.0" or greater.
  ✔ The application requires the extension "zlib".
  ✔ The application requires the extension "json".
  ✔ The application requires the extension "tokenizer".
  ✔ The application requires the extension "xml".

 [OK] Your system is ready to run the application.                                                                                                             

  ...........................................................................⨯................

  ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Laravel  
    FAIL   .......................................................................................................................... 92 files, 1 style issue  
  ⨯ app/Imports/VariantsImport.php                                                                                                      method_argument_space  
  @@ -19,7 +19,7 @@

  -        $collection->chunk($chunk_size)->each(function (Collection $chunk) use (&$references , &$not_ordered_job, &$selectable_job) {
  +        $collection->chunk($chunk_size)->each(function (Collection $chunk) use (&$references, &$not_ordered_job, &$selectable_job) {

               $variants = Variant::query()
jameswilddev commented 1 year ago

I'm seeing something vaguely similar to this as well - Pint passes on macOS, but raises a number of issues with a single file of 170 when ran within a GitHub Action running on ubuntu-latest. I can't post the file here unfortunately but I can't see anything obviously different/wrong about it compared to others.