Skip to content

Commit

Permalink
Merge pull request #1 from bolt/ecs
Browse files Browse the repository at this point in the history
Add Easy Coding Standard
  • Loading branch information
bobdenotter authored Sep 2, 2019
2 parents 61b275e + dcafdf7 commit f982b4b
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ appveyor.yml

vendor/
composer.lock
var/
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
"email": "[email protected]"
}
],
"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": {
Expand Down
100 changes: 100 additions & 0 deletions easy-coding-standard.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public function initialize(): void
{
$this->widgets->registerWidget(new NewsWidget());
}
}
}
1 change: 0 additions & 1 deletion src/NewsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Bolt\Widget\TwigAware;
use Symfony\Component\HttpClient\HttpClient;


class NewsWidget extends BaseWidget implements TwigAware, RequestAware, CacheAware, StopwatchAware
{
use CacheTrait;
Expand Down

0 comments on commit f982b4b

Please sign in to comment.