PHP code example of sllh / php-cs-fixer-styleci-bridge

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

    

sllh / php-cs-fixer-styleci-bridge example snippets




// Needed to get styleci-bridge loaded
 ConfigBridge::create();



LLH\StyleCIBridge\ConfigBridge;

return ConfigBridge::create(__DIR__.'/config', [__DIR__, __DIR__.'../lib']);



LLH\StyleCIBridge\ConfigBridge;

return ConfigBridge::create()
    ->setUsingCache(true)       // Enable the cache
;



LLH\StyleCIBridge\ConfigBridge;
use Symfony\CS\Config\Config;

$bridge = new ConfigBridge();

return Config::create()
    ->finder($bridge->getFinder())
    ->fixers(['dummy', 'foo', '-bar'])
    ->setUsingCache(true)
;



use SLLH\StyleCIBridge\ConfigBridge;

$config = ConfigBridge::create();

return $config
    ->setUsingCache(true)
    ->fixers(array_merge($config->getFixers(), ['-psr0', 'custom', 'foo', '-bar']))
;



LLH\StyleCIBridge\ConfigBridge;
use Symfony\CS\Fixer\Contrib\HeaderCommentFixer;

$header = <<<EOF
This file is part of the dummy package.

(c) John Doe <[email protected]>

This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
EOF;

HeaderCommentFixer::setHeader($header);

return ConfigBridge::create();



LLH\StyleCIBridge\ConfigBridge;

$header = <<<EOF
This file is part of the dummy package.

(c) John Doe <[email protected]>

This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
EOF;

$config = ConfigBridge::create();

return $config
    ->setRules(array_merge($config->getRules(), array(
        'header_comment' => array('header' => $header)
    )))
;



LLH\StyleCIBridge\ConfigBridge;
use Symfony\CS\Fixer\Contrib\HeaderCommentFixer;

$header = <<<EOF
This file is part of the dummy package.

(c) John Doe <[email protected]>

This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
EOF;

// PHP-CS-Fixer 1.x
if (method_exists('Symfony\CS\Fixer\Contrib\HeaderCommentFixer', 'getHeader')) {
    HeaderCommentFixer::setHeader($header);
}

$config = ConfigBridge::create();

// PHP-CS-Fixer 2.x
if (method_exists($config, 'setRules')) {
    $config->setRules(array_merge($config->getRules(), array(
        'header_comment' => array('header' => $header)
    )));
}

return $config;