1. Go to this page and download the library: Download kgabryel/code-quality library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kgabryel / code-quality example snippets
// .php-cs-fixer.dist.php (Symfony)
declare(strict_types=1);
use Kgabryel\CodeQuality\Preset\CsFixer\SymfonyConfig as Preset;
$finder = new PhpCsFixer\Finder()
->in([
...Preset::getPaths(__DIR__), // katalogi analizowane dla frameworka
]);
return new PhpCsFixer\Config()
->setRiskyAllowed(Preset::isRiskyAllowed()) // zezwolenie na reguły risky
->setRules([
...Preset::getSets(), // kompletny zestaw reguł
])
->setFinder($finder)
->setCacheFile(__DIR__ . '/var/.php-cs-fixer.cache');
// rector.php (Laravel)
declare(strict_types=1);
use Kgabryel\CodeQuality\Preset\Rector\LaravelConfig as Preset;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\SetList;
return RectorConfig::configure()
->withPaths([
...Preset::getPaths(__DIR__), // katalogi analizowane dla frameworka
])
->withImportNames() // FQCN zamieniane na importy use
->withPhpSets(php84: true) // reguły dla wybranej wersji PHP
->withSets([
...Preset::getSets(), // zestawy reguł Rectora
])
->withComposerBased(
...Preset::getComposerBased(), // zestawy aktywowane na podstawie composer.json
)
->withAttributesSets(
...Preset::getAttributesSets(), // migracja adnotacji do atrybutów
)
->withCache(__DIR__ . '/.rector-cache/')
->withSkip([
...Preset::getsSkip(), // reguły wyłączone z analizy
]);
->withSkip([
...Preset::getsSkip(),
ReadonlyPropertyRector::class, // dodatkowa reguła do pominięcia
__DIR__ . '/src/Legacy', // katalog wyłączony z analizy
])
->withSets([
...Preset::getSets(),
SetList::NAMING, // nowy zestaw
])
bash
composer in/code-quality analysis
php vendor/bin/code-quality test