Skip to content

Commit

Permalink
implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Oct 16, 2024
1 parent dc9ed79 commit 203639b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
18 changes: 18 additions & 0 deletions e2e/with-php-level/expected-output.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
1 file with changes
===================

1) src/SomeClass.php:0

---------- begin diff ----------
@@ @@
<?php

-ldap_first_attribute($ldap, $entry, $more);
+ldap_first_attribute($ldap, $entry);
----------- end diff -----------

Applied rules:
* RemoveFuncCallArgRector


[OK] 1 file would have been changed (dry-run) by Rector
2 changes: 1 addition & 1 deletion e2e/with-php-level/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
return RectorConfig::configure()
->withPaths([__DIR__ . '/src'])
->withPhpVersion(PhpVersionFeature::ATTRIBUTES)
->withPhpLevel(10);
->withPhpLevel(2);
2 changes: 1 addition & 1 deletion e2e/with-php-level/src/SomeClass.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

class SomeClass {}
ldap_first_attribute($ldap, $entry, $more);
11 changes: 6 additions & 5 deletions src/Configuration/RectorConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Rector\Config\RectorConfig;
use Rector\Config\RegisteredService;
use Rector\Configuration\Levels\LevelRulesResolver;
use Rector\Configuration\Parameter\SimpleParameterProvider;
use Rector\Console\Notifier;
use Rector\Contract\Rector\ConfigurableRectorInterface;
use Rector\Contract\Rector\RectorInterface;
Expand All @@ -30,6 +31,7 @@
use Rector\Symfony\Set\SensiolabsSetList;
use Rector\Symfony\Set\SymfonySetList;
use Rector\ValueObject\PhpVersion;
use Rector\ValueObject\PhpVersionFeature;
use Symfony\Component\Finder\Finder;
use Webmozart\Assert\Assert;

Expand Down Expand Up @@ -290,10 +292,6 @@ public function __invoke(RectorConfig $rectorConfig): void
$rectorConfig->phpstanConfigs($this->phpstanConfigs);
}

if ($this->phpVersion !== null) {
$rectorConfig->phpVersion($this->phpVersion);
}

if ($this->parallel !== null) {
if ($this->parallel) {
$rectorConfig->parallel(
Expand Down Expand Up @@ -922,7 +920,10 @@ public function withPHPStanConfigs(array $phpstanConfigs): self
*/
public function withPhpVersion(int $phpVersion): self
{
$this->phpVersion = $phpVersion;
// trigger from new RectorConfig instance
// as too late usage on __invoke() on withPhpSets() or withPhpLevel()
(new RectorConfig())->phpVersion($phpVersion);

return $this;
}

Expand Down

0 comments on commit 203639b

Please sign in to comment.