eonx-com/easy-standard

This package is abandoned and no longer maintained. No replacement package was suggested.

Centralised source of coding standard classes

3.0.24 2021-04-15 13:03 UTC

This package is auto-updated.

Last update: 2021-12-30 07:23:11 UTC


README

---eonx_docs--- title: Introduction weight: 0 ---eonx_docs---

This package is a way to centralise reusable classes used for coding standards. It contains:


Require package (Composer)

We recommend using Composer to manage your dependencies. You can require this package as follows:

$ composer require --dev eonx/easy-standard

Prepare configuration file for ECS (Easy Coding Standard) Sniffs

You can use one of the following names for a configuration file: ecs.php, ecs.yml, ecs.yaml, easy-coding-standard.yml, or easy-coding-standard.yaml. Create this file in the root folder of the project.

Note: The YAML configuration is deprecated in the new ECS versions. Use the PHP configuration if possible.

The basic structure of the configuration file follows:

// ecs.php
declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
    $parameters = $containerConfigurator->parameters();
    /*
     * List of parameters
     */

    $services = $containerConfigurator->services();
    /*
     * List of services
     */
};
# ecs.yml
parameters:
    # List of parameters

services:
    # List of services

Run ECS check

Go to the root folder of the project and run

vendor/bin/ecs check

Expected output:

[OK] No errors found. Great job - your code is shiny in style!

Prepare configuration file for Rector

You can use one of the following names for a configuration file: rector.php, rector.yml or rector.yaml. Create this file in the root folder of the project.

Note: The YAML configuration is deprecated in the new Rector versions. Use the PHP configuration if possible.

The basic structure of the configuration file follows:

// rector.php
declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
    $parameters = $containerConfigurator->parameters();
    /*
     * List of parameters
     */

    $services = $containerConfigurator->services();
    /*
     * List of services
     */
};
# rector.yml
parameters:
    # List of parameters

services:
    # List of services

Run Rector check

Go to the root folder of the project and run

touch `php -r "echo sys_get_temp_dir() . '/_rector_type_probe.txt';"` && vendor/bin/rector process --dry-run

Expected output:

[OK] Rector is done!