PHP code example of kreta / php-cs-fixer-config

1. Go to this page and download the library: Download kreta/php-cs-fixer-config 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/ */

    

kreta / php-cs-fixer-config example snippets




/*
 * This file is part of the Kreta package.
 *
 * (c) Beñat Espiña <[email protected]>
 * (c) Gorka Laucirica <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

use Kreta\PhpCsFixerConfig\KretaConfig;

$config = new KretaConfig();
$config->getFinder()->in(__DIR__ . '/src');

$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;

$config->setCacheFile($cacheDir . '/.php_cs.cache');

return $config;



/*
 * This file is part of the Kreta package.
 *
 * (c) Beñat Espiña <[email protected]>
 * (c) Gorka Laucirica <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

use Kreta\PhpCsFixerConfig\KretaConfig;

$config = new KretaConfig(true);
$config->getFinder()
    ->in(__DIR__ . '/tests/Spec')
    ->name('*Spec.php');

$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;

$config->setCacheFile($cacheDir . '/.php_cs.cache');

return $config;
bash
/vendor
/.php_cs.cache
json
(...)

"scripts": {
    (...)

    "cs": [
        "php-cs-fixer fix --config=.php_cs -v",
        "php-cs-fixer fix --config=.phpspec_cs -v"
    ]
},
yml
cache:
  directories:
    - $HOME/.php-cs-fixer
yml
script:
  - vendor/bin/php-cs-fixer fix --config=.php_cs --verbose --diff --dry-run
  - vendor/bin/php-cs-fixer fix --config=.phpspec_cs --verbose --diff --dry-run