PHP code example of matchory / coding-style

1. Go to this page and download the library: Download matchory/coding-style 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/ */

    

matchory / coding-style example snippets




declare(strict_types=1);

use Matchory\CodingStyle\Rector\Preset;
use Rector\Config\RectorConfig;

return Preset::laravel(RectorConfig::configure())
    ->withPaths([__DIR__ . '/app', __DIR__ . '/tests'])
    ->withCache(cacheDirectory: __DIR__ . '/.cache/rector/run')
    ->withSkip([
        // File-specific skips stay here; they do not generalise.
        SomeRector::class => [__DIR__ . '/app/Legacy'],
    ]);

return Preset::laravel(RectorConfig::configure())
    ->withSets([\Pest\Rector\Set\PestSetList::CODING_STYLE]);
json
{
    "scripts": {
        "fmt:config": "@php -r \"file_put_contents('.cache/pint.merged.json', json_encode(array_replace_recursive(json_decode(file_get_contents('vendor/matchory/coding-style/php/pint/base.json'), true), file_exists('pint.json') ? json_decode(file_get_contents('pint.json'), true) : [])));\"",
        "fmt": ["@fmt:config", "pint --config .cache/pint.merged.json --parallel"]
    }
}
neon
 - vendor/matchory/coding-style/php/phpstan/laravel.neon
    - vendor/matchory/coding-style/php/phpstan/pest.neon
    - vendor/matchory/coding-style/php/phpstan/complexity.neon

parameters:
    level: 5
    paths:
        - app/
        - tests/

    # Must be declared here; see the merge-order note below.
    cognitive_complexity:
        class: 50
        function: 15
json
{
  "extends": [
    "github>matchory/coding-style",
    "github>matchory/coding-style//renovate/php",
    "github>matchory/coding-style//renovate/javascript"
  ]
}
bash
php php/bin/generate-pint-presets.php --check   # pint/relaxed.json is derived from base.json
cd js && node scripts/generate.mjs --check      # generated/*.json are derived from src/