-
Notifications
You must be signed in to change notification settings - Fork 18
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
Adding custom Fixers to PHP CS Fixer #132
Comments
Hi @superbiche, thank you for the feedback on these projects 🙌 There is https://github.com/tighten/duster/blob/2.x/RELEASE.md, which I rely on when releasing. I may need to link this in the readme. |
Hi @driftingly you're welcome, thanks for the work on this project, it's really helpful. Oh OK, I missed the I don't know Box / PHARs enough but maybe there's a way to configure some external autoloader or composer.json that could be loaded during runtime. Hopefully there's an easy way to solve this! |
I found this comment quite relevant to this issue: #86 (comment) Namespacing the project so the source code can be included like a regular Composer dependency - using source install - might be the shortest path to making custom fixers addition a breeze. |
Hi @superbiche, I'm not sure changing the namespace will work because I still rely on classes under Pint, which will keep the |
Thanks @driftingly, I'll have to wait until I work back on a Laravel 10 project later this week in order to test this. |
Hi @driftingly, update on the test. Installed the branch
<?php
use App\Fixer\ClassNotation\CustomControllerOrderFixer;
use App\Fixer\ClassNotation\CustomOrderedClassElementsFixer;
use App\Fixer\ClassNotation\CustomPhpUnitOrderFixer;
use App\Support\PhpCsFixer;
use Inly\DusterPresets\CustomLivewireOrderFixer;
use PhpCsFixer\Config;
return (new Config())
->setFinder(PhpCsFixer::getFinder())
->setUsingCache(false)
->registerCustomFixers([
new CustomControllerOrderFixer(),
new CustomLivewireOrderFixer(),
new CustomOrderedClassElementsFixer(),
new CustomPhpUnitOrderFixer(),
])
->setRules([
'Tighten/custom_controller_order' => true,
'Inly/custom_livewire_order' => true,
'Tighten/custom_ordered_class_elements' => [
'order' => [
'use_trait',
'case',
'property_public_static',
'property_protected_static',
'property_private_static',
'constant_public',
'constant_protected',
'constant_private',
'property_public',
'property_protected',
'property_private',
'construct',
'method:__invoke',
'method_public_static',
'method_protected_static',
'method_private_static',
'method_public',
'method_protected',
'method_private',
'magic',
],
],
'Tighten/custom_phpunit_order' => true,
]); |
Thanks for testing @Joel-Jensen |
Hi again,
Hopefully this time it's not just me missing something: when creating the
.php-cs-fixer.dist.php
file in my project, it's picked correctly by Duster.But I don't understand how to add custom rules: when adding Fixers following https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/custom_rules.rst, I get a
Class [class of custom fixer] not found
.This seems to be related to the packaging of Duster using Box, I guess it cannot use the global autoloader?
For now I forked the project, added the custom Fixers, and built it (btw a "How To Build" could help others) but I don't want to maintain a fork for just a couple custom Fixers.
Is there a way to "wire" local / project dependencies to the Duster binary ?
Thanks in advance
The text was updated successfully, but these errors were encountered: