Skip to content

Commit

Permalink
minor #4584 Increase PHPStan level to 1 (julienfalque)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.15 branch.

Discussion
----------

Increase PHPStan level to 1

Commits
-------

c5f71b7 Increase PHPStan level to 1
  • Loading branch information
keradus committed Nov 2, 2019
2 parents 8587bcb + c5f71b7 commit 9dbf585
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -52,7 +52,7 @@ jobs:
| grep -v tests/TestCase.php \
&& (echo "UNKNOWN FILES DETECTED" && travis_terminate 1) || echo "NO UNKNOWN FILES"
- ./check_trailing_spaces.sh || travis_terminate 1
- ./dev-tools/tools/phpstan analyse
- php -d auto_prepend_file=dev-tools/vendor/autoload.php ./dev-tools/tools/phpstan analyse
- if [ -n "$COMMIT_SCA_FILES" ]; then ./dev-tools/vendor/bin/phpmd `echo "$COMMIT_SCA_FILES" | grep -Ev "^tests/Fixtures" | xargs | sed 's/ /,/g'` text phpmd.xml || travis_terminate 1; fi
- ./dev-tools/tools/composer-require-checker check composer.json --config-file $(realpath .composer-require-checker.json) || travis_terminate 1
- composer normalize -d ./dev-tools ./../composer.json --dry-run
Expand Down
3 changes: 2 additions & 1 deletion dev-tools/composer.json
Expand Up @@ -6,7 +6,8 @@
"humbug/box": "~3.7.0",
"localheinz/composer-normalize": "^1.1",
"mi-schi/phpmd-extension": "^4.3",
"phpmd/phpmd": "^2.6"
"phpmd/phpmd": "^2.6",
"phpstan/phpstan-phpunit": "^0.11.2"
},
"conflict": {
"hhvm": "*"
Expand Down
5 changes: 4 additions & 1 deletion phpstan.neon
@@ -1,5 +1,8 @@
includes:
- dev-tools/vendor/phpstan/phpstan-phpunit/extension.neon

parameters:
level: 0
level: 1
paths:
- src
- tests
Expand Down
1 change: 1 addition & 0 deletions src/AbstractLinesBeforeNamespaceFixer.php
Expand Up @@ -37,6 +37,7 @@ protected function fixLinesBeforeNamespace(Tokens $tokens, $index, $expectedMin,
{
// Let's determine the total numbers of new lines before the namespace
// and the opening token
$openingTokenIndex = null;
$precedingNewlines = 0;
$newlineInOpening = false;
$openingToken = null;
Expand Down
3 changes: 2 additions & 1 deletion src/Console/Command/DescribeCommand.php
Expand Up @@ -279,8 +279,9 @@ function ($type) {
$old = $codeSample->getCode();
$tokens = Tokens::fromCode($old);

$configuration = $codeSample->getConfiguration();

if ($fixer instanceof ConfigurableFixerInterface) {
$configuration = $codeSample->getConfiguration();
$fixer->configure(null === $configuration ? [] : $configuration);
}

Expand Down
10 changes: 5 additions & 5 deletions src/Fixer/Basic/BracesFixer.php
Expand Up @@ -566,11 +566,11 @@ static function ($item) {
continue;
}

if (!$isAnonymousClass) {
$prevToken = $tokens[$closingParenthesisIndex - 1];
}

if (!$isAnonymousClass && $prevToken->isWhitespace() && false !== strpos($prevToken->getContent(), "\n")) {
if (
!$isAnonymousClass
&& $tokens[$closingParenthesisIndex - 1]->isWhitespace()
&& false !== strpos($tokens[$closingParenthesisIndex - 1]->getContent(), "\n")
) {
if (!$tokens[$startBraceIndex - 2]->isComment()) {
$tokens->ensureWhitespaceAtIndex($startBraceIndex - 1, 1, ' ');
}
Expand Down
2 changes: 2 additions & 0 deletions src/Fixer/ClassNotation/ClassAttributesSeparationFixer.php
Expand Up @@ -230,6 +230,8 @@ private function fixSpaceAboveClassElement(Tokens $tokens, $classStartIndex, $el
{
static $methodAttr = [T_PRIVATE, T_PROTECTED, T_PUBLIC, T_ABSTRACT, T_FINAL, T_STATIC];

$nonWhiteAbove = null;

// find out where the element definition starts
$firstElementAttributeIndex = $elementIndex;
for ($i = $elementIndex; $i > $classStartIndex; --$i) {
Expand Down
1 change: 1 addition & 0 deletions src/Fixer/Import/SingleImportPerStatementFixer.php
Expand Up @@ -99,6 +99,7 @@ private function getGroupDeclaration(Tokens $tokens, $index)
{
$groupPrefix = '';
$comment = '';
$groupOpenIndex = null;
for ($i = $index + 1;; ++$i) {
if ($tokens[$i]->isGivenKind(CT::T_GROUP_IMPORT_BRACE_OPEN)) {
$groupOpenIndex = $i;
Expand Down

0 comments on commit 9dbf585

Please sign in to comment.