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

imp: install PHP-CS-Fixer locally, allowing us to run in locally #617

Merged
merged 1 commit into from
Jan 8, 2023

Conversation

Kocal
Copy link
Member

@Kocal Kocal commented Dec 18, 2022

Q A
Bug fix? no
New feature? no
Tickets Fix #...
License MIT

After opening #616, the CI showed me a lot of style issues in the PHP code:
image

I don't have PHP CS Fixer globally installed on my machine because that's a bad practice, and I don't want to fix those errors manually (the time is precious).

So, this PR adds PHP CS Fixer locally.

Copy link
Member

@kbond kbond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

@Kocal Kocal force-pushed the imp/install-php-cs-fixer-locally branch from ccf5d94 to 514a7ce Compare December 18, 2022 23:13
@weaverryan
Copy link
Member

I think the recommended way is to install it into a tools/ directory, right? https://github.com/PHP-CS-Fixer/PHP-CS-Fixer#installation

@kbond
Copy link
Member

kbond commented Dec 20, 2022

The shim is new maybe? I only learned of it from the recipe (symfony/recipes#1112) that was merged yesterday.

@weaverryan
Copy link
Member

This was the first I had heard of it. It seems like a good idea - is there some docs or mention of using this? And how it fits into best-practices?

@Kocal
Copy link
Member Author

Kocal commented Dec 20, 2022

As you know, installing this kind of tools into a separate composer.json (ie: in tools/... directory) allows to not pollute your app's deps/dev-deps with the tool's dependencies.

However I'm not a big fan of having multiple composer.json in a single project, and you can face some problems if you try to load/interpret your code with the tool (I remember to face this kind of issue because the are two autoloaders, but I may be wrong).

This is something that can be easily fixed by using a .phar, which can be installed through a shim-version of the package.

To me the given installation methods for PHP-CS-Fixer are "wrong", composer require --dev friendsofphp/php-cs-fixer should download a .phar and that's all, no other dependencies, like PHPStan and Rector do since a long time.

@Kocal
Copy link
Member Author

Kocal commented Dec 29, 2022

Hi @weaverryan @kbond, is installing the shim still okay?

Copy link
Member

@kbond kbond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me.

@weaverryan
Copy link
Member

This does make a lot of sense - thanks Hugo!

@weaverryan weaverryan merged commit a76534b into symfony:2.x Jan 8, 2023
@Kocal Kocal deleted the imp/install-php-cs-fixer-locally branch January 8, 2023 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants