Skip to content

Commit

Permalink
Upgrade rector to the latest version (#1944)
Browse files Browse the repository at this point in the history
* Upgrade phpstan to the latest version

* Upgrade rector to the latest version
  • Loading branch information
maks-rafalko committed Mar 23, 2024
1 parent 85e6514 commit af53859
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 32 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"phpstan/phpstan-strict-rules": "^1.1.0",
"phpstan/phpstan-webmozart-assert": "^1.0.2",
"phpunit/phpunit": "^10.5",
"rector/rector": "^0.16.0",
"rector/rector": "^1.0",
"sidz/phpstan-rules": "^0.4.0",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0",
"thecodingmachine/phpstan-safe-rule": "^1.2.0"
Expand Down
21 changes: 8 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions devTools/phpstan-src.neon
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ parameters:
-
message: '#^Function shell_exec is unsafe to use#'
path: '../src/TestFramework/CommandLineBuilder.php'
- # TODO: fix this; this was introduced as bumping to PHP 8.1 as the minimim requirement
message: '#^Parameter \#1 \$string of function trim expects string, string\|null given\.$#'
path: '../src/TestFramework/PhpUnit/Config/Path/PathReplacer.php'
-
message: "#^Instantiated class Infection\\\\FileSystem\\\\DummyFileSystem not found\\.$#"
count: 1
Expand Down
17 changes: 5 additions & 12 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,17 @@

use Rector\Config\RectorConfig;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
// TODO uncomment as a separate PR
// __DIR__ . '/tests/phpunit',
]);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_81,
]);

$rectorConfig->skip([
])
->withPhpSets(php81: true)
->withSkip([
ReadOnlyPropertyRector::class => [
// property can't be readonly as it's returned by reference and may be updated
__DIR__ . '/src/TestFramework/Coverage/TestLocations.php',
],
]);
};
2 changes: 1 addition & 1 deletion src/Mutation/MutationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function __construct(
array $mutators,
private readonly EventDispatcher $eventDispatcher,
private readonly FileMutationGenerator $fileMutationGenerator,
private bool $runConcurrently,
private readonly bool $runConcurrently,
) {
Assert::allIsInstanceOf($mutators, Mutator::class);
$this->mutators = $mutators;
Expand Down
2 changes: 1 addition & 1 deletion src/Process/Runner/MutationTestingRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MutationTestingRunner
/**
* @param array<string, array<int, string>> $ignoreSourceCodeMutatorsMap
*/
public function __construct(private readonly MutantProcessFactory $processFactory, private readonly MutantFactory $mutantFactory, private readonly ProcessRunner $processRunner, private readonly EventDispatcher $eventDispatcher, private readonly Filesystem $fileSystem, private readonly DiffSourceCodeMatcher $diffSourceCodeMatcher, private bool $runConcurrently, private readonly float $timeout, private readonly array $ignoreSourceCodeMutatorsMap)
public function __construct(private readonly MutantProcessFactory $processFactory, private readonly MutantFactory $mutantFactory, private readonly ProcessRunner $processRunner, private readonly EventDispatcher $eventDispatcher, private readonly Filesystem $fileSystem, private readonly DiffSourceCodeMatcher $diffSourceCodeMatcher, private readonly bool $runConcurrently, private readonly float $timeout, private readonly array $ignoreSourceCodeMutatorsMap)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/TestFramework/PhpUnit/Config/Path/PathReplacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(private readonly Filesystem $filesystem, private rea

public function replaceInNode(DOMElement|DOMNode $domElement): void
{
$path = trim($domElement->nodeValue);
$path = trim((string) $domElement->nodeValue);

if (!$this->filesystem->isAbsolutePath($path)) {
$newPath = sprintf(
Expand Down

0 comments on commit af53859

Please sign in to comment.