PHP code example of nowo-tech / php-quality-tools
1. Go to this page and download the library: Download nowo-tech/php-quality-tools 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/ */
nowo-tech / php-quality-tools example snippets
return [
'paths' => [
__DIR__ . '/src',
__DIR__ . '/tests',
],
'skip' => [
__DIR__ . '/src/Legacy/*',
\Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector::class,
],
'php_version' => 'php84',
'symfony_version' => 74, // For Symfony projects
'features' => [
'type_declarations' => true,
'dead_code' => true,
'code_quality' => true,
'early_return' => true,
'naming' => true,
'privatization' => true,
],
];
return [
// ... other settings ...
'project_custom_fixers' => [
\App\Fixer\Custom\MyCustomFixer::class,
// Add more custom fixers here
],
];
return [
'paths' => [
__DIR__ . '/src',
__DIR__ . '/tests',
],
'exclude' => [
'vendor',
'var',
'src/Legacy',
],
'rules' => [
// Override or add rules
'concat_space' => ['spacing' => 'none'],
'yoda_style' => true,
],
];
return [
'paths' => [
__DIR__ . '/templates',
__DIR__ . '/src/Resources/views',
],
'exclude' => [
'vendor',
],
'disabled_rules' => [
// Disable specific rules
],
];
bash
composer
php-quality-tools: Detected framework: symfony
php-quality-tools: Installing .rector.php
php-quality-tools: Installing .rector.custom.php
php-quality-tools: Installing .php-cs-fixer.php
php-quality-tools: Installing .php-cs-fixer.custom.php
php-quality-tools: Installing .twig-cs-fixer.php
php-quality-tools: Installing .twig-cs-fixer.custom.php
php-quality-tools: Installed 6 file(s) for symfony
php-quality-tools: Twig not detected, skipping Twig-CS-Fixer configuration
php-quality-tools: Missing suggested dependencies detected:
- rector/rector: Rector for automated code refactoring
- rector/rector-symfony: Rector rules for Symfony (only for Rector 1.x)
- rector/rector-doctrine: Rector rules for Doctrine (only for Rector 1.x)
- rector/rector-phpunit: Rector rules for PHPUnit (only for Rector 1.x)
- friendsofphp/php-cs-fixer: PHP-CS-Fixer for code style fixing
- vincentlanglet/twig-cs-fixer: Twig-CS-Fixer for Twig template style fixing
Would you like to install these dependencies now? (yes/no) [yes]: yes
php-quality-tools: Installing dependencies...
php-quality-tools: Dependencies installed successfully!
bash
# Preview changes
./vendor/bin/php-cs-fixer fix --dry-run --diff
# Apply changes
./vendor/bin/php-cs-fixer fix
bash
# Format Blade templates ( resources/views --dry-run --diff
./vendor/bin/php-cs-fixer fix resources/views
json
{
"extra": {
"php-quality-tools": {
"auto_add_scripts": true
}
}
}
json
{
"scripts": {
"fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --config=.php-cs-fixer.php --allow-risky=yes",
"fix:check": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --config=.php-cs-fixer.php --dry-run --diff --allow-risky=yes",
"rector": "rector process -c .rector.php",
"rector:check": "rector process -c .rector.php --dry-run",
"twig:fix": "twig-cs-fixer fix --config=.twig-cs-fixer.php",
"twig:lint": "twig-cs-fixer lint --config=.twig-cs-fixer.php",
"twig:fix:check": "twig-cs-fixer lint --config=.twig-cs-fixer.php --fix",
"blade-check": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix resources/views --config=.php-cs-fixer.php --dry-run --diff --allow-risky=yes",
"blade-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix resources/views --config=.php-cs-fixer.php --allow-risky=yes"
}
}
bash
composer update nowo-tech/php-quality-tools
bash
rm .rector.php .php-cs-fixer.php .twig-cs-fixer.php
composer install