PHP code example of uuf6429 / elder-brother

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

    

uuf6429 / elder-brother example snippets




use uuf6429\ElderBrother\Action;
use uuf6429\ElderBrother\Event;
use uuf6429\ElderBrother\Change\GitChangeSet;

return [
    Event\Git::PRE_COMMIT => [
        1 => new Action\PhpLinter(
                GitChangeSet::getAddedCopiedModified()
                    ->name('/\\.php$/')
            ),
        2 => new Action\PhpCsFixer(
                GitChangeSet::getAddedCopiedModified()
                    ->name('/\\.php$/')
            ),
    ]
];

new ExecuteCode(
    string $description, // Description of the intention of the callback
    callable $callback // The callback to execute. It will receive $config, $input and $output as parameters
)

new ExecuteProgram(
    string $description, // Description of the intention of the program
    string $command, // Program command line (with parameters)
    bool $breakOnFailure, // (Optional, default is true) Stop execution if program returns non-0 exit code
    array|null $environment, // (Optional, default is null / current vars) Environment variables to pass to program
    string|null $currentDir, // The current directory to use for program
    int $timeout // (Optional, default is 60) The time to wait for program to finish (in seconds)
)

new ForbiddenFiles(
    \FileList $files,
    string $reason
)

new PhpCsFixer(
    \FileList $files, // The files to check
    int|null $level, // (Optional, defaults to NONE_LEVEL) Fixer level to use
    string[] $fixers, // (Optional, default is empty) Set the fixers to use
    bool $addAutomatically // (Optional, default is true) Whether to add modified files to commit or not
)

new PhpCsFixerOld(
    \FileList $files, // The files to check
    string|null $binFile, // (Optional, default is from vendor) File path to PHP-CS-Fixer binary
    string|null $configFile, // (Optional, default is project root) File path to PHP-CS-Fixer config
    bool $addAutomatically // (Optional, default is true) Whether to add modified files to commit or not
)

new PhpLinter(
    \FileList $files // The files to check
)

new RiskyFiles(
    \FileList $files,
    string $reason
)