1. Go to this page and download the library: Download lmc/coding-standard 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/ */
lmc / coding-standard example snippets
declare(strict_types=1);
use Symplify\EasyCodingStandard\Config\ECSConfig;
return ECSConfig::configure()
->withPaths([__DIR__ . '/src', __DIR__ . '/tests']) // optionally add 'config' or other directories with PHP files
->withRootFiles() // to also check ecs.php and all other php files in the root directory
->withSets(
[
__DIR__ . '/vendor/lmc/coding-standard/ecs.php',
]
);
declare(strict_types=1);
use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
return ECSConfig::configure()
/* (...) */
->withSets(
[
__DIR__ . '/vendor/lmc/coding-standard/ecs.php',
]
)
->withRules(
[
// PHPUnit attributes must be used over their respective PHPDoc-based annotations. (Use with PHPUnit 10+.)
PhpUnitAttributesFixer::class,
// Single-line comments must have proper spacing (one space after `//`).
SingleLineCommentSpacingFixer::class,
// Convert multiline string to heredoc or nowdoc.
MultilineStringToHeredocFixer::class,
]
)
// Enforce line-length to 120 characters.
->withConfiguredRule(LineLengthSniff::class, ['absoluteLineLimit' => 120])
// Tests must have @test annotation.
->withConfiguredRule(PhpUnitTestAnnotationFixer::class, ['style' => 'annotation'])
// Specify elements separation.
->withConfiguredRule(ClassAttributesSeparationFixer::class, ['elements' => ['const' => 'none', 'method' => 'one', 'property' => 'none']])
/* (...) */
declare(strict_types=1);
use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff;
use PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays\ArrayDeclarationSniff;
use Symplify\EasyCodingStandard\Config\ECSConfig;
return ECSConfig::configure()
/* (...) */
->withSkip(
[
// Ignore specific check only in specific files
ForbiddenFunctionsSniff::class => [__DIR__ . '/src-tests/bootstrap.php'],
// Disable check entirely
ArrayDeclarationSniff::class,
// Skip one file
__DIR__ . '/file/to/be/skipped.php',
// Skip entire directory
__DIR__ . '/ignored/directory/*',
]
)
/* (...) */
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.