Skip to content

Commit

Permalink
Merge pull request #72 from object-calisthenics/cleanup
Browse files Browse the repository at this point in the history
Cleanup and dependency updates
  • Loading branch information
Tomáš Votruba committed Oct 19, 2017
2 parents 9bbf7c1 + 399e1fb commit c657e90
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 260 deletions.
21 changes: 9 additions & 12 deletions .travis.yml
Expand Up @@ -2,33 +2,30 @@ language: php

sudo: false

matrix:
include:
- php: 7.1
# add variables to enable coverage, coding standard check and static analysis
env: PHPUNIT_FLAGS="--coverage-clover coverage.xml" CHECK_CS=1 RUN_PHPSTAN=1
php:
- 7.1

install:
# install composer dependencies
- composer install

script:
# run tests
- vendor/bin/phpunit $PHPUNIT_FLAGS
- vendor/bin/phpunit --coverage-clover coverage.xml
# turn off XDebug
- phpenv config-rm xdebug.ini || return 0
# check coding standard (defined in composer.json "scripts" section)
- if [[ $CHECK_CS = 1 ]]; then composer check-cs; fi
- composer check-cs
# check with phpstan (defined in composer.json "scripts" section)
- if [[ $RUN_PHPSTAN = 1 ]]; then composer phpstan; fi
- composer phpstan
# run PHP_CodeSniffer with ruleset
- vendor/bin/phpcs src tests -sp --standard=src/ObjectCalisthenics/ruleset.xml --extensions=php

after_script:
# upload coverage.xml file to Coveralls to analyze it
- |
if [[ PHPUNIT_FLAGS != "" ]]; then
wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar
php coveralls.phar --verbose
fi
wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar
php coveralls.phar --verbose
# do not send success notifications, they have no value
notifications:
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Expand Up @@ -5,16 +5,16 @@
"type": "phpcodesniffer-standard",
"require": {
"php": "^7.1",
"squizlabs/php_codesniffer": "^3.0.1",
"squizlabs/php_codesniffer": "^3.1",
"nette/utils": "^2.4"
},
"require-dev": {
"phpunit/phpunit": "^6.0",
"phpstan/phpstan": "^0.7",
"phpunit/phpunit": "^6.4",
"phpstan/phpstan": "^0.8",
"tracy/tracy": "^2.4",
"symplify/easy-coding-standard": "^2.0",
"symplify/coding-standard": "^2.0",
"slevomat/coding-standard": "^3.0"
"symplify/easy-coding-standard": "^2.5",
"symplify/coding-standard": "^2.5",
"slevomat/coding-standard": "^4.0"
},
"autoload": {
"psr-4": {
Expand All @@ -28,8 +28,8 @@
},
"scripts": {
"complete-check": ["@phpstan", "@check-cs", "phpunit"],
"phpstan": "phpstan analyze src --level 7 --configuration phpstan.neon",
"check-cs": "easy-coding-standard check src tests",
"fix-cs": "easy-coding-standard check src tests --fix"
"phpstan": "phpstan analyze src --level max --configuration phpstan.neon",
"check-cs": "ecs check src tests",
"fix-cs": "ecs check src tests --fix"
}
}
260 changes: 31 additions & 229 deletions easy-coding-standard.neon
@@ -1,3 +1,14 @@
includes:
- vendor/symplify/easy-coding-standard/config/symfony-checkers.neon
- vendor/symplify/easy-coding-standard/config/php54-checkers.neon
- vendor/symplify/easy-coding-standard/config/php70-checkers.neon
- vendor/symplify/easy-coding-standard/config/php71-checkers.neon
# custom
- vendor/symplify/easy-coding-standard/config/symplify-checkers.neon
- vendor/symplify/easy-coding-standard/config/common.neon
- vendor/symplify/easy-coding-standard/config/spaces.neon


checkers:
# All rules with default values

Expand Down Expand Up @@ -33,244 +44,35 @@ checkers:
- ObjectCalisthenics\Sniffs\Classes\ForbiddenPublicPropertySniff
- ObjectCalisthenics\Sniffs\NamingConventions\NoSetterSniff

# Classes
- PHP_CodeSniffer\Standards\Generic\Sniffs\Classes\DuplicateClassNameSniff
- PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\PropertyDeclarationSniff
- PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ValidClassNameSniff
- PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\LowercaseClassKeywordsSniff

# Code Analysis
- PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff
- PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\JumbledIncrementerSniff
- PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnconditionalIfStatementSniff
- PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UselessOverridingMethodSniff
PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer:
equal: false
identical: false
less_and_greater: false

# Control Structures
- PHP_CodeSniffer\Standards\Generic\Sniffs\ControlStructures\InlineControlStructureSniff
- PHP_CodeSniffer\Standards\PEAR\Sniffs\ControlStructures\MultiLineConditionSniff
- PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ControlSignatureSniff
- PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ElseIfDeclarationSniff
- PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ForEachLoopDeclarationSniff
- PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ForLoopDeclarationSniff
- PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\LowercaseDeclarationSniff

# Files
- PHP_CodeSniffer\Standards\Generic\Sniffs\Files\ByteOrderMarkSniff
# Metrics
PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff:
lineLimit: 120
absoluteLineLimit: 120
- PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneClassPerFileSniff
- PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneInterfacePerFileSniff
- PHP_CodeSniffer\Standards\PSR2\Sniffs\Files\EndFileNewlineSniff
- PHP_CodeSniffer\Standards\Zend\Sniffs\Files\ClosingTagSniff

# Formatting
- PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterCastSniff

- PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\FunctionCallArgumentSpacingSniff
- PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions\ValidDefaultValueSniff
- PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\FunctionDeclarationSniff
- PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\MultiLineFunctionDeclarationSniff
- PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\LowercaseFunctionKeywordsSniff

# Metrics
- PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\CyclomaticComplexitySniff
- PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\MethodDeclarationSniff

# Naming Conventions
- PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\UpperCaseConstantNameSniff
- PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff

# PHP
- PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowShortOpenTagSniff
- PHP_CodeSniffer\Standards\MySource\Sniffs\PHP\EvalObjectFactorySniff
- PHP_CodeSniffer\Standards\MySource\Sniffs\PHP\GetRequestDataSniff
- PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\NonExecutableCodeSniff

# WhiteSpace
- PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\DisallowTabIndentSniff
- PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\LanguageConstructSpacingSniff
- PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ScopeKeywordSpacingSniff
PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\SuperfluousWhitespaceSniff:
ignoreBlankLines: false

# Commenting
- Symplify\CodingStandard\Sniffs\Commenting\VarPropertyCommentSniff

# Control Structures
- Symplify\CodingStandard\Sniffs\ControlStructures\NewClassSniff

# Debug
- Symplify\CodingStandard\Sniffs\Debug\DebugFunctionCallSniff

# Namespaces
- Symplify\CodingStandard\Sniffs\Namespaces\ClassNamesWithoutPreSlashSniff
- PhpCsFixer\Fixer\NamespaceNotation\SingleBlankLineBeforeNamespaceFixer

# Naming
- Symplify\CodingStandard\Sniffs\Naming\AbstractClassNameSniff
- Symplify\CodingStandard\Sniffs\Naming\InterfaceNameSniff
- Symplify\CodingStandard\Sniffs\Naming\TraitNameSniff
PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\CyclomaticComplexitySniff:
absoluteComplexity: 4
PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\NestingLevelSniff:
absoluteNestingLevel: 2

# Slevomat
- SlevomatCodingStandard\Sniffs\Classes\ClassConstantVisibilitySniff
- SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff
- SlevomatCodingStandard\Sniffs\Commenting\ForbiddenAnnotationsSniff
- SlevomatCodingStandard\Sniffs\ControlStructures\DisallowEqualOperatorsSniff
- SlevomatCodingStandard\Sniffs\ControlStructures\YodaComparisonSniff
- SlevomatCodingStandard\Sniffs\Exceptions\DeadCatchSniff
- SlevomatCodingStandard\Sniffs\Exceptions\ReferenceThrowableOnlySniff
- SlevomatCodingStandard\Sniffs\TypeHints\LongTypeHintsSniff
- SlevomatCodingStandard\Sniffs\TypeHints\ParameterTypeHintSpacingSniff
- SlevomatCodingStandard\Sniffs\TypeHints\NullableTypeForNullDefaultValueSniff
- SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSpacingSniff
# disable for temp bug in Symplify\EasyCodingStandard
SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff:
usefulAnnotations:
- @todo
- @dataProvider
- @expectedException
- SlevomatCodingStandard\Sniffs\Namespaces\AlphabeticallySortedUsesSniff
- SlevomatCodingStandard\Sniffs\Namespaces\DisallowGroupUseSniff
- SlevomatCodingStandard\Sniffs\Namespaces\MultipleUsesPerLineSniff
- SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff
- SlevomatCodingStandard\Sniffs\Namespaces\UseDoesNotStartWithBackslashSniff
- SlevomatCodingStandard\Sniffs\Namespaces\UseFromSameNamespaceSniff

PhpCsFixer\Fixer\Operator\ConcatSpaceFixer:
spacing: one
PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer:
syntax: short
- PhpCsFixer\Fixer\Basic\Psr4Fixer
- PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer
- PhpCsFixer\Fixer\LanguageConstruct\DirConstantFixer
- PhpCsFixer\Fixer\CastNotation\ModernizeTypesCastingFixer
- PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer
- PhpCsFixer\Fixer\Semicolon\SemicolonAfterInstructionFixer
- PhpCsFixer\Fixer\ReturnNotation\SimplifiedNullReturnFixer
- PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer
- PhpCsFixer\Fixer\ControlStructure\NoUselessElseFixer
- PhpCsFixer\Fixer\ReturnNotation\NoUselessReturnFixer
- PhpCsFixer\Fixer\Import\OrderedImportsFixer
- PhpCsFixer\Fixer\LanguageConstruct\CombineConsecutiveUnsetsFixer
- PhpCsFixer\Fixer\Strict\StrictComparisonFixer
- PhpCsFixer\Fixer\PhpTag\NoShortEchoTagFixer
- PhpCsFixer\Fixer\Alias\EregToPregFixer
- PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer

# PHPUnit
- PhpCsFixer\Fixer\PhpUnit\PhpUnitStrictFixer

# PSR1 (official)
- PhpCsFixer\Fixer\Basic\EncodingFixer
- PhpCsFixer\Fixer\PhpTag\FullOpeningTagFixer

# PSR2 (official)
- PhpCsFixer\Fixer\NamespaceNotation\BlankLineAfterNamespaceFixer
- PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer
- PhpCsFixer\Fixer\ControlStructure\ElseifFixer
- PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer
- PhpCsFixer\Fixer\Whitespace\IndentationTypeFixer
- PhpCsFixer\Fixer\Whitespace\LineEndingFixer
- PhpCsFixer\Fixer\Casing\LowercaseKeywordsFixer
- PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer
- PhpCsFixer\Fixer\PhpTag\NoClosingTagFixer
- PhpCsFixer\Fixer\FunctionNotation\NoSpacesAfterFunctionNameFixer
- PhpCsFixer\Fixer\Whitespace\NoSpacesInsideParenthesisFixer
- PhpCsFixer\Fixer\Whitespace\NoTrailingWhitespaceFixer
- PhpCsFixer\Fixer\Comment\NoTrailingWhitespaceInCommentFixer
- PhpCsFixer\Fixer\Whitespace\SingleBlankLineAtEofFixer
- PhpCsFixer\Fixer\Import\SingleImportPerStatementFixer
- PhpCsFixer\Fixer\Import\SingleLineAfterImportsFixer
- PhpCsFixer\Fixer\ControlStructure\SwitchCaseSemicolonToColonFixer
- PhpCsFixer\Fixer\ControlStructure\SwitchCaseSpaceFixer

# Symfony (official)
PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer:
align_double_arrow: false
align_equals: false
- PhpCsFixer\Fixer\ReturnNotation\BlankLineBeforeReturnFixer
PhpCsFixer\Fixer\Basic\BracesFixer:
allow_single_line_closure: true
- PhpCsFixer\Fixer\CastNotation\CastSpacesFixer
- PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer
- PhpCsFixer\Fixer\FunctionNotation\FunctionTypehintSpaceFixer
- PhpCsFixer\Fixer\Comment\HashToSlashCommentFixer
- PhpCsFixer\Fixer\ControlStructure\IncludeFixer
- PhpCsFixer\Fixer\CastNotation\LowercaseCastFixer
- PhpCsFixer\Fixer\ClassNotation\MethodSeparationFixer
- PhpCsFixer\Fixer\Casing\NativeFunctionCasingFixer
- PhpCsFixer\Fixer\ClassNotation\NoBlankLinesAfterClassOpeningFixer
- PhpCsFixer\Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer
- PhpCsFixer\Fixer\Comment\NoEmptyCommentFixer
- PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer
- PhpCsFixer\Fixer\Semicolon\NoEmptyStatementFixer
PhpCsFixer\Fixer\Whitespace\NoExtraConsecutiveBlankLinesFixer:
- curly_brace_block
- extra
- parenthesis_brace_block
- square_brace_block
- throw
- use
- PhpCsFixer\Fixer\Import\NoLeadingImportSlashFixer
- PhpCsFixer\Fixer\NamespaceNotation\NoLeadingNamespaceWhitespaceFixer
- PhpCsFixer\Fixer\Alias\NoMixedEchoPrintFixer
- PhpCsFixer\Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer
- PhpCsFixer\Fixer\CastNotation\NoShortBoolCastFixer
- PhpCsFixer\Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer
- PhpCsFixer\Fixer\Whitespace\NoSpacesAroundOffsetFixer
- PhpCsFixer\Fixer\ControlStructure\NoTrailingCommaInListCallFixer
- PhpCsFixer\Fixer\ArrayNotation\NoTrailingCommaInSinglelineArrayFixer
- PhpCsFixer\Fixer\ControlStructure\NoUnneededControlParenthesesFixer
- PhpCsFixer\Fixer\Import\NoUnusedImportsFixer
- PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer
- PhpCsFixer\Fixer\Whitespace\NoWhitespaceInBlankLineFixer
- PhpCsFixer\Fixer\ArrayNotation\NormalizeIndexBraceFixer
- PhpCsFixer\Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer
- PhpCsFixer\Fixer\PhpUnit\PhpUnitFqcnAnnotationFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocAnnotationWithoutDotFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocIndentFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocInlineTagFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocNoAccessFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocNoEmptyReturnFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocNoPackageFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocReturnSelfReferenceFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocScalarFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocSingleLineVarSpacingFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocSummaryFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocTrimFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocVarWithoutNameFixer
- PhpCsFixer\Fixer\Operator\PreIncrementFixer
- PhpCsFixer\Fixer\FunctionNotation\ReturnTypeDeclarationFixer
- PhpCsFixer\Fixer\ClassNotation\SelfAccessorFixer
- PhpCsFixer\Fixer\CastNotation\ShortScalarCastFixer
- PhpCsFixer\Fixer\ClassNotation\SingleClassElementPerStatementFixer
- PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer
- PhpCsFixer\Fixer\Semicolon\SpaceAfterSemicolonFixer
- PhpCsFixer\Fixer\Operator\StandardizeNotEqualsFixer
- PhpCsFixer\Fixer\Operator\TernaryOperatorSpacesFixer
- PhpCsFixer\Fixer\Operator\TernaryToNullCoalescingFixer
- PhpCsFixer\Fixer\ArrayNotation\TrimArraySpacesFixer
- PhpCsFixer\Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer

# PHP 7.1
PhpCsFixer\Fixer\Alias\RandomApiMigrationFixer:
mt_rand: random_int
rand: random_int
PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer:
- const
- property
- method

# new since PhpCsFixer 2.1/2.2
- PhpCsFixer\Fixer\LanguageConstruct\IsNullFixer
- PhpCsFixer\Fixer\LanguageConstruct\FunctionToConstantFixer
- PhpCsFixer\Fixer\Basic\NonPrintableCharacterFixer
- PhpCsFixer\Fixer\Casing\MagicConstantCasingFixer
enableEachParameterAndReturnInspection: true

parameters:
skip:
SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff:
- src/ObjectCalisthenics/Sniffs/*/*Sniff.php
- *src/ObjectCalisthenics/Sniffs/*/*Sniff.php

exclude_checkers:
# Symfony ruleset
- PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer
- PhpCsFixer\Fixer\Operator\NewWithBracesFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer
# mutually excluded
- SlevomatCodingStandard\Sniffs\ControlStructures\DisallowYodaComparisonSniff
- PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer
2 changes: 2 additions & 0 deletions phpstan.neon
Expand Up @@ -3,3 +3,5 @@ parameters:
- %currentWorkingDirectory%/vendor/squizlabs/php_codesniffer/autoload.php
excludes_analyse:
- **/ObjectCalisthenics/Helper/Slevomat/**
ignoreErrors:
- '#Method ObjectCalisthenics\\Sniffs\\Metrics\\MaxNestingLevelSniff::register\(\) should return int\[\] but returns \(int\|string\)\[\]#'
2 changes: 1 addition & 1 deletion src/ObjectCalisthenics/Helper/ClassAnalyzer.php
Expand Up @@ -10,7 +10,7 @@ final class ClassAnalyzer
/**
* @var mixed[]
*/
private static $propertyList;
private static $propertyList = [];

public static function getClassMethodCount(File $file, int $position): int
{
Expand Down

0 comments on commit c657e90

Please sign in to comment.