Automattic / phpcs-neutron-standard

A set of phpcs sniffs for PHP >7 development
MIT License
94 stars 7 forks source link

Static analysis reveals few errors #76

Open szepeviktor opened 5 years ago

szepeviktor commented 5 years ago
 ------ -----------------------------------------------------------------------------------------------------------
  Line   SniffHelpers.php
 ------ -----------------------------------------------------------------------------------------------------------
  49     Parameter #1 $types of method PHP_CodeSniffer\Files\File::findPrevious() expects array|int, string given.
  53     Parameter #3 $end of method PHP_CodeSniffer\Files\File::findPrevious() expects int|null, int|true given.
  67     Parameter #1 $types of method PHP_CodeSniffer\Files\File::findNext() expects array|int, string given.
  75     Parameter #1 $types of method PHP_CodeSniffer\Files\File::findNext() expects array|int, string given.
  83     Parameter #1 $types of method PHP_CodeSniffer\Files\File::findNext() expects array|int, string given.
  90     Parameter #1 $types of method PHP_CodeSniffer\Files\File::findNext() expects array|int, string given.
  101    Parameter #1 $types of method PHP_CodeSniffer\Files\File::findNext() expects array|int, string given.
 ------ -----------------------------------------------------------------------------------------------------------

 ------ ----------------------------------------------------------------------------------------------------------------------------------
  Line   Sniffs/Conditions/DisallowConditionAssignWithoutConditionalSniff.php
 ------ ----------------------------------------------------------------------------------------------------------------------------------
  10     Method NeutronStandard\Sniffs\Conditions\DisallowConditionAssignWithoutConditionalSniff::register() should return array<int> but
         returns array<int, string>.
  22     Parameter #1 $types of method PHP_CodeSniffer\Files\File::findNext() expects array|int, string given.
 ------ ----------------------------------------------------------------------------------------------------------------------------------

 ------ --------------------------------------------------------------------------------------------------------------------------------
  Line   Sniffs/Functions/TypeHintSniff.php
 ------ --------------------------------------------------------------------------------------------------------------------------------
  11     Method NeutronStandard\Sniffs\Functions\TypeHintSniff::register() should return array<int> but returns array<int, int|string>.
 ------ --------------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------------------
  Line   Sniffs/Whitespace/RequireParenthesisSpacingSniff.php
 ------ -------------------------------------------------------------------------------------------------------------------------------------
  11     Method NeutronStandard\Sniffs\Whitespace\RequireParenthesisSpacingSniff::register() should return array<int> but returns array<int,
         string>.
 ------ -------------------------------------------------------------------------------------------------------------------------------------
szepeviktor commented 5 years ago

e.g. in SniffHelpers.php:50 it could be if (! is_int($openParenPtr))

szepeviktor commented 5 years ago

Config for PHPStan is very short: phpstan.neon

parameters:
    level: max
    paths:
        - %currentWorkingDirectory%/NeutronStandard/
    autoload_files:
        - %currentWorkingDirectory%/vendor/squizlabs/php_codesniffer/autoload.php
        - %currentWorkingDirectory%/vendor/squizlabs/php_codesniffer/src/Util/Tokens.php