From dcafdf76ee1d36fbc978a24d346491bb313d7041 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Tue, 27 Aug 2019 16:36:19 +0200 Subject: [PATCH] Add Easy Coding Standard --- .gitignore | 1 + README.md | 20 ++++++++ composer.json | 6 ++- easy-coding-standard.yml | 100 +++++++++++++++++++++++++++++++++++++++ src/Extension.php | 2 +- src/NewsWidget.php | 1 - 6 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 easy-coding-standard.yml diff --git a/.gitignore b/.gitignore index 1ba9ab6..437662d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ appveyor.yml vendor/ composer.lock +var/ diff --git a/README.md b/README.md index e7f7380..47e60f5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,23 @@ # 📰 Bolt News Widget A simple Widget Extension to display the latest Bolt news on the dashboard. +Installation: + +```bash +composer require bolt/newswidget +``` + + +## Running PHPStan and Easy Codings Standard + +First, make sure dependencies are installed: + +``` +COMPOSER_MEMORY_LIMIT=-1 composer update +``` + +And then run ECS: + +``` +vendor/bin/ecs check src +``` diff --git a/composer.json b/composer.json index 253751a..5893d8f 100644 --- a/composer.json +++ b/composer.json @@ -9,8 +9,12 @@ "email": "bob@twokings.nl" } ], + "require": { + "php": ">=7.1.3" + }, "require-dev": { - "bolt/core": "^4.0.0" + "bolt/core": "^4.0.0", + "symplify/easy-coding-standard": "^6.0" }, "autoload": { "psr-4": { diff --git a/easy-coding-standard.yml b/easy-coding-standard.yml new file mode 100644 index 0000000..6e0ef26 --- /dev/null +++ b/easy-coding-standard.yml @@ -0,0 +1,100 @@ +imports: + - { resource: 'vendor/symplify/easy-coding-standard/config/set/clean-code.yaml' } + - { resource: 'vendor/symplify/easy-coding-standard/config/set/common.yaml' } + - { resource: 'vendor/symplify/easy-coding-standard/config/set/php70.yaml' } + - { resource: 'vendor/symplify/easy-coding-standard/config/set/php71.yaml' } + - { resource: 'vendor/symplify/easy-coding-standard/config/set/psr2.yaml' } + - { resource: 'vendor/symplify/easy-coding-standard/config/set/psr12.yaml' } + - { resource: 'vendor/symplify/easy-coding-standard/config/set/symfony.yaml' } + - { resource: 'vendor/symplify/easy-coding-standard/config/set/symfony-risky.yaml' } + +services: + # most of these services are taken from symplify.yml + # see https://github.com/Symplify/Symplify/blob/master/ecs.yml + + # PHP 5.5 + Symplify\CodingStandard\Fixer\Php\ClassStringToClassConstantFixer: ~ + + # Control Structures + Symplify\CodingStandard\Fixer\Property\ArrayPropertyDefaultValueFixer: ~ + Symplify\CodingStandard\Fixer\ArrayNotation\StandaloneLineInMultilineArrayFixer: ~ + Symplify\CodingStandard\Fixer\ControlStructure\RequireFollowedByAbsolutePathFixer: ~ + + # Spaces + Symplify\CodingStandard\Fixer\Strict\BlankLineAfterStrictTypesFixer: ~ + + # Comments + Symplify\CodingStandard\Fixer\Commenting\RemoveSuperfluousDocBlockWhitespaceFixer: ~ + + # Naming + PhpCsFixer\Fixer\PhpUnit\PhpUnitMethodCasingFixer: ~ + + # Debug + Symplify\CodingStandard\Sniffs\Debug\DebugFunctionCallSniff: ~ + Symplify\CodingStandard\Sniffs\Debug\CommentedOutCodeSniff: ~ + + # final classes + PhpCsFixer\Fixer\ClassNotation\FinalInternalClassFixer: ~ + + # multibyte + PhpCsFixer\Fixer\Alias\MbStrFunctionsFixer: ~ + + # psr + PhpCsFixer\Fixer\Basic\Psr0Fixer: ~ + PhpCsFixer\Fixer\Basic\Psr4Fixer: ~ + + PhpCsFixer\Fixer\CastNotation\LowercaseCastFixer: ~ + PhpCsFixer\Fixer\CastNotation\ShortScalarCastFixer: ~ + PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer: ~ + PhpCsFixer\Fixer\Import\NoLeadingImportSlashFixer: ~ + PhpCsFixer\Fixer\Import\OrderedImportsFixer: + importsOrder: + - 'class' + - 'const' + - 'function' + PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer: + space: 'none' + PhpCsFixer\Fixer\Operator\NewWithBracesFixer: ~ + PhpCsFixer\Fixer\Basic\BracesFixer: + 'allow_single_line_closure': false + 'position_after_functions_and_oop_constructs': 'next' + 'position_after_control_structures': 'same' + 'position_after_anonymous_constructs': 'same' + + PhpCsFixer\Fixer\ClassNotation\NoBlankLinesAfterClassOpeningFixer: ~ + PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer: + elements: + - 'const' + - 'method' + - 'property' + PhpCsFixer\Fixer\Operator\TernaryOperatorSpacesFixer: ~ + PhpCsFixer\Fixer\FunctionNotation\ReturnTypeDeclarationFixer: ~ + PhpCsFixer\Fixer\Whitespace\NoTrailingWhitespaceFixer: ~ + + PhpCsFixer\Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer: ~ + PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer: ~ + PhpCsFixer\Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer: ~ + + #remove useless phpdoc + PhpCsFixer\Fixer\FunctionNotation\PhpdocToReturnTypeFixer: ~ + PhpCsFixer\Fixer\Import\FullyQualifiedStrictTypesFixer: ~ + PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer: ~ + + #please yoda no + SlevomatCodingStandard\Sniffs\ControlStructures\DisallowYodaComparisonSniff: ~ + +parameters: + cache_directory: var/cache/ecs + skip: + PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer: ~ + PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer: ~ + PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer: ~ + PhpCsFixer\Fixer\Operator\ConcatSpaceFixer: ~ + PhpCsFixer\Fixer\Operator\IncrementStyleFixer: ~ + PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer: ~ + PhpCsFixer\Fixer\Phpdoc\PhpdocAnnotationWithoutDotFixer: ~ + PhpCsFixer\Fixer\Phpdoc\PhpdocSummaryFixer: ~ + PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer: ~ + SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff: ~ + Symplify\CodingStandard\Sniffs\Debug\CommentedOutCodeSniff: ~ #to be removed before beta release + Symplify\CodingStandard\Sniffs\Debug\DebugFunctionCallSniff: ~ #to be removed before beta release diff --git a/src/Extension.php b/src/Extension.php index 7377c87..6a14905 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -17,4 +17,4 @@ public function initialize(): void { $this->widgets->registerWidget(new NewsWidget()); } -} \ No newline at end of file +} diff --git a/src/NewsWidget.php b/src/NewsWidget.php index eb702c8..b5186ba 100644 --- a/src/NewsWidget.php +++ b/src/NewsWidget.php @@ -18,7 +18,6 @@ use Bolt\Widget\TwigAware; use Symfony\Component\HttpClient\HttpClient; - class NewsWidget extends BaseWidget implements TwigAware, RequestAware, CacheAware, StopwatchAware { use CacheTrait;