1
0
Fork 0
junkyard/2023/php-coding-standard
Krzysztof Sikorski c5f0fc164a
Add PHP coding standard
2023-10-28 22:54:17 +02:00
..
src Add PHP coding standard 2023-10-28 22:54:17 +02:00
tools Add PHP coding standard 2023-10-28 22:54:17 +02:00
.editorconfig Add PHP coding standard 2023-10-28 22:54:17 +02:00
.gitignore Add PHP coding standard 2023-10-28 22:54:17 +02:00
.php-cs-fixer.dist.php Add PHP coding standard 2023-10-28 22:54:17 +02:00
CHANGELOG.md Add PHP coding standard 2023-10-28 22:54:17 +02:00
LICENCE.txt Add PHP coding standard 2023-10-28 22:54:17 +02:00
Makefile Add PHP coding standard 2023-10-28 22:54:17 +02:00
README.md Add PHP coding standard 2023-10-28 22:54:17 +02:00
composer.json Add PHP coding standard 2023-10-28 22:54:17 +02:00

README.md

Coding standard

Helper classes for enforcing my personal coding standard in PHP code.

Licence

This mini-library is licensed under MIT License.

Full text of the licence is attached in LICENSE.txt file.

Installation

composer require --dev krzysztof-sikorski/coding-standard

Usage

Create or update a configuration file .php-cs-fixer.dist.php in the root of your project:

use KrzysztofSikorski\CodingStandard\PhpCsFixer\RulesFactory;
use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$configName = 'My personal coding standard';

$header = <<<'HEADER'
    My personal coding standard

    @author Krzysztof Sikorski
    @copyright 2023 Krzysztof Sikorski
    HEADER;

$finder = new Finder();
$finder->files();
$finder->in(dirs: __DIR__);
$finder->ignoreDotFiles(ignoreDotFiles: false);
$finder->ignoreVCSIgnored(ignoreVCSIgnored: true);

$finder->append(iterator: [__FILE__]);

$rules = PhpCsFixerRulesFactory::create(header: $header);

$config = new Config(name: $configName);
$config->setFinder(finder: $finder);
$config->setRiskyAllowed(isRiskyAllowed: true);
$config->setRules(rules: $rules);

return $config;

Source code

This repository is mirrored to multiple services for redundancy: