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

Rector reports spaces as error on Windows #5444

Closed
nelson6e65 opened this issue Feb 7, 2021 · 11 comments
Closed

Rector reports spaces as error on Windows #5444

nelson6e65 opened this issue Feb 7, 2021 · 11 comments
Labels

Comments

@nelson6e65
Copy link

nelson6e65 commented Feb 7, 2021

Bug Report

Subject Details
Rector version 0.8.56
Installed as composer dependency
OS Windows
PHP 7.2+

I run a composer script to perform linting with Rector and is reporting error. The same codebase is failing on Windows but works fine on Linux.

alt text

Post: how-to-delegate-code-reviews-to-ci

CI Workflow run:
https://github.com/nelson6e65/rector-issue-ex/actions/runs/544525144

Minimal PHP Code Causing Issue

Minimal reproduction repo: https://github.com/nelson6e65/rector-issue-ex/tree/4b6ab04b4d614579d37407a58842f57a35a07c2e

Expected Behaviour

Simple spaces/lines should not be reported as error.

@nelson6e65 nelson6e65 added the bug label Feb 7, 2021
@nelson6e65 nelson6e65 changed the title Rector report spaces as error on Windows Rector reports spaces as error on Windows Feb 7, 2021
@TomasVotruba
Copy link
Member

Hi,

the 0.8 is quite old. It's recommended to use 0.9 now. Be sure to upgrade first.
As for Windows, we don't have much Windows contributors, so we can't help with this. Are you willing to help with the bug?

@nelson6e65
Copy link
Author

There is another way to install it? Or is required to be in the composer.json? Can I use it as a global installation?

I still use PHP 7.2, to generate documentation only, so I can't update rector 0.9 in my composer.json.

If this is an issue with WIndows only I can ignore it for now.


Are you willing to help with the bug?

I don't know how to start 😅

@samsonasik
Copy link
Member

@nelson6e65 you may can try with --ignore-platform-reqs:

composer update rector/rector:^0.9 --ignore-platform-reqs

and verify if it fixed in 0.9 version. If 0.9 fixed the issue, you may need to upgrade your php version to php 7.3+.

@nelson6e65
Copy link
Author

@samsonasik I only use PHP 7.2 on CI to build the documentation for my library. I'm had not migrated to phpDocumentor 3, I'm still using 3.9, which is not compatible with PHP 7.3+.

Locally, I use PHP 7.4 (as the first image I attached).

I'll try to upgrade to Rector 0.9 and use composer install --ignore-platform-req=php in my CI when PHP < 7.3.

@TomasVotruba
Copy link
Member

Btw, there is PHP 7.1 compatible version: https://github.com/rectorphp/rector-php71

@nelson6e65
Copy link
Author

This does not applies to 0.9. All works fine after the upgrade.

Ignoring platform allows me to run composer install on PHP 7.2, but not using Rector, which is fine. I just need to run phpdoc. Now I have to figure out how to customize the install command on Netlify. 😅

Thanks for your help. I was just using an old version.

@nelson6e65
Copy link
Author

By the way:

There is another way to install it? Or is required to be in the composer.json? Can I use it as a global installation?

@TomasVotruba
Copy link
Member

There is another way to install it? Or is required to be in the composer.json? Can I use it as a global installation?

Global installation or any other proven to be very problematic. Rector is trying to work with the worst code possible, so the least requirement is to be installed as dependency with full access to autoloader.

So composer install is the only way to install it (reliably) :)


I hope you manage to resolve your dependendencies to get to PHP 7.3.

Btw, there is PHP 7.1 compatible version: rectorphp/rector-php71

How does this version work?

@nelson6e65
Copy link
Author

Btw, there is PHP 7.1 compatible version: rectorphp/rector-php71
How does this version work?

It's the same problem. My library (https://github.com/nelson6e65/php_nml) is compatible with 7.2+. So I have will need to add rectorphp/rector-php71 to my composer.json which will works on PHP 7.1 but will be unable to install on PHP 7.2+. So, I also require rector/rector:^0.9 when running PHP 7.3. Does not conflict?

I just want to skip installation of Rector when using PHP 7.2 to build my documentation.

Global installation or any other proven to be very problematic. So composer install is the only way to install it (reliably) :)

😓😓😓

Thanks for your help.

@TomasVotruba
Copy link
Member

Oh, rector-php71 work on PHP 7.1-7.4

@nelson6e65
Copy link
Author

I ended up by allowing Rector 0.8:

https://github.com/nelson6e65/php_nml/blob/d060bf759a1591554234b93c801b32409796bd8c/composer.json#L33-L35

This allows me to use 0.9 to check problems on my supported PHP versions and build the documentation with PHP 7.2 on Netlify without failing due to incompatible version (Rector is not necessary for this).

Thanks for your support! 😀

TomasVotruba added a commit that referenced this issue Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants