tighten / duster

Automatic configuration for Laravel apps to apply Tighten's standard linting & code standards.
MIT License
464 stars 13 forks source link

Cannot use standards/.php-cs-fixer.dist.php as base config : source code missing from Composer package. #131

Closed superbiche closed 10 months ago

superbiche commented 10 months ago

Hey there,

Thanks for the package! Filling the gaps between the linters & fixers, that's exactly what we needed.

When trying to customize PHP CS Fixer, following the README won't work.
image

The .php-cs-fixer.dist.php file contains reference to the package source code :

use App\Fixer\ClassNotation\CustomControllerOrderFixer;
use App\Fixer\ClassNotation\CustomOrderedClassElementsFixer;
use App\Fixer\ClassNotation\CustomPhpUnitOrderFixer;
use App\Support\PhpCsFixer;

But this source is not included in releases, thus it's not included in a regular composer require --dev tightenco/duster

A workaround is to force a source install (composer.json relevant section):

    "config": {
        "preferred-install": {
            "tightenco/duster": "source",
            "*": "dist"
        },
    },

And / or require it with the --prefer-source flag, eg composer require --dev --prefer-source tightenco/duster (I did both just to be sure).

But source installs seem to have some caveats. Do you think you could publish the releases with the source code, or this is too much hassle for users who don't want to customize, and source install is the way to go?

Cheers!

superbiche commented 10 months ago

Well, installing from source doesn't work either, as the root namespace is App, so we cannot autoload it easily.
Going with a fork for now, but it would be nice to find a way to handle this.

superbiche commented 10 months ago

OK, closing as I didn't even think of ignoring the warnings from my IDE and trying it anyway...
Guess I need some sleep.

Sorry for the noise.