Skip to content

Commit

Permalink
Merge pull request #3628 from rectorphp/fix-phpstan-reflection
Browse files Browse the repository at this point in the history
Fix PHPStan Reflection break from 0.12.26
  • Loading branch information
kodiakhq[bot] authored Jul 1, 2020
2 parents 5cb1947 + f113d3d commit 2b24acb
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 32 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/broken_reflection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Broken Reflection

on:
pull_request: null
push:
branches:
- master

jobs:
broken_reflection:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v1
with:
php-version: 7.4

- run: composer install --no-progress --ansi

- run: bin/rector p src/Rector/AbstractRector.php -n --debug
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"nikic/php-parser": "^4.5",
"ondram/ci-detector": "^3.4",
"phpstan/phpdoc-parser": "^0.4.7",
"phpstan/phpstan": "^0.12.25",
"phpstan/phpstan": "^0.12.32",
"phpstan/phpstan-phpunit": "^0.12.10",
"psr/simple-cache": "^1.0",
"sebastian/diff": "^3.0|^4.0",
Expand Down
6 changes: 3 additions & 3 deletions docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# All 513 Rectors Overview
# All 514 Rectors Overview

- [Projects](#projects)
- [General](#general)
Expand Down Expand Up @@ -4573,8 +4573,8 @@ services:

### `ReturnThisRemoveRector`

- class: [`Rector\MagicDisclosure\Rector\ClassMethod\ReturnThisRemoveRector`](/../master/rules/magic-disclosure/src/Rector/MethodBody/ReturnThisRemoveRector.php)
- [test fixtures](/../master/rules/magic-disclosure/tests/Rector/MethodBody/ReturnThisRemoveRector/Fixture)
- class: [`Rector\MagicDisclosure\Rector\ClassMethod\ReturnThisRemoveRector`](/../master/rules/magic-disclosure/src/Rector/ClassMethod/ReturnThisRemoveRector.php)
- [test fixtures](/../master/rules/magic-disclosure/tests/Rector/ClassMethod/ReturnThisRemoveRector/Fixture)

Removes "return $this;" from *fluent interfaces* for specified classes.

Expand Down
2 changes: 2 additions & 0 deletions rules/php80/src/Rector/Identical/StrStartsWithRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,7 @@ public function refactor(Node $node): ?Node

return $strStartWithMatchAndRefactor->refactor($strStartsWithValueObject);
}

return null;
}
}
3 changes: 1 addition & 2 deletions rules/php80/src/Rector/NotIdentical/StrContainsRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Rector\Php80\Rector\NotIdentical;

use PhpParser\Node;
use PhpParser\Node\Expr\BinaryOp\Identical;
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Name;
Expand Down Expand Up @@ -59,7 +58,7 @@ public function run()
*/
public function getNodeTypes(): array
{
return [NotIdentical::class, Identical::class];
return [NotIdentical::class];
}

/**
Expand Down
15 changes: 0 additions & 15 deletions rules/phpunit/src/Rector/MethodCall/composer.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,12 @@ public function refactor(Node $node): ?Node
return null;
}

/** @var string $class */
$class = $node->getAttribute(AttributeKey::CLASS_NAME);

// Remember when we have already processed this constant recursively
$node->setAttribute(self::HAS_NEW_ACCESS_LEVEL, true);

/** @var string|null $class */
$class = $node->getAttribute(AttributeKey::CLASS_NAME);
if ($class === null) {
return null;
}

// 0. constants declared in interfaces have to be public
if ($this->classLikeParsedNodesFinder->findInterface($class) !== null) {
$this->makePublic($node);
Expand Down Expand Up @@ -150,7 +147,13 @@ private function shouldSkip(ClassConst $classConst): bool
return true;
}

return count($classConst->consts) !== 1;
if (count($classConst->consts) !== 1) {
return true;
}

/** @var string|null $class */
$class = $classConst->getAttribute(AttributeKey::CLASS_NAME);
return $class === null;
}

private function findParentClassConstantAndRefactorIfPossible(string $class, string $constant): ?ConstantVisibility
Expand Down
1 change: 1 addition & 0 deletions src/Stubs/StubLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function loadStubs(): void
$robotLoader->addDirectory($stubDirectory);
$robotLoader->setTempDirectory(sys_get_temp_dir() . '/_rector_stubs');
$robotLoader->register();
$robotLoader->refresh();

$this->areStubsLoaded = true;
}
Expand Down
8 changes: 4 additions & 4 deletions utils/project-validator/src/Process/ParallelTaskRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ private function createProcessFromSetTask(SetTask $setTask): Process
'--set',
$setTask->getSetName(),
'--dry-run',
'--debug',
];

return new Process($command, $this->cwd);
Expand All @@ -203,15 +204,14 @@ private function evaluateProcess(Process $process): void

$fullOutput = array_filter([$process->getOutput(), $process->getErrorOutput()]);

$ouptput = implode("\n", $fullOutput);

$actualErrorHappened = Strings::match($ouptput, '#(Fatal error)|(\[ERROR\])#');
$output = implode("\n", $fullOutput);
$actualErrorHappened = Strings::match($output, '#(Fatal error)|(\[ERROR\])#');

if (! $actualErrorHappened) {
return;
}

throw new ProcessResultInvalidException($ouptput);
throw new ProcessResultInvalidException($output);
}

private function printSuccess(string $set, int $totalTasks): void
Expand Down

0 comments on commit 2b24acb

Please sign in to comment.