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

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

    

opositatest / php-cs-fixer-config example snippets




$config = new Opositatest\PhpCsFixerConfig\OpositatestConfig();
$config->getFinder()
    ->in(__DIR__ . "/src")
    ->in(__DIR__ . "/tests");
return $config;

$config->getFinder()
    ->in(__DIR__ . "/src/Model");

$config->getFinder()
    ->in("/src")
    ->name("*Controller.php");

$config->getFinder()
    ->in("/src")
    ->exclude("third-party")

$ ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php

$ ./vendor/bin/php-cs-fixer fix --config=.php_cs.dist --verbose --diff --dry-run
bash
#!/usr/bin/env bash

echo "Running php-cs-fixer..."

CURRENT_DIRECTORY=`pwd`
GIT_HOOKS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

PROJECT_DIRECTORY="$GIT_HOOKS_DIR/../.."

cd $PROJECT_DIRECTORY;
PHP_CS_FIXER="vendor/bin/php-cs-fixer"

git status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | while read line; do
    ${PHP_CS_FIXER} fix --config=.php_cs --verbose ${line};
    git add "$line";
done

cd $CURRENT_DIRECTORY;
echo "Done."