Skip to content

Commit

Permalink
remove symfony/dependency-injection and move unused to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Aug 15, 2023
1 parent 7165002 commit f73ae8b
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 95 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ jobs:
-
name: 'Detect unused dependencies'
# "default" format overrides default "github" in CI
run: vendor/bin/composer-unused --ansi --output-format=default
run: |
composer require icanhazstring/composer-unused --dev
vendor/bin/composer-unused --ansi --output-format=default
name: ${{ matrix.actions.name }}
runs-on: ubuntu-latest
Expand Down
4 changes: 0 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@
"rector/rector-phpunit": "dev-main",
"rector/rector-symfony": "dev-main",
"sebastian/diff": "^5.0",
"symfony/config": "^6.2",
"symfony/console": "^6.3",
"symfony/contracts": "^3.2",
"symfony/dependency-injection": "6.1.*",
"symfony/finder": "^6.3",
"symfony/process": "^6.3",
"symplify/easy-parallel": "^11.1",
Expand All @@ -46,7 +43,6 @@
},
"require-dev": {
"cweagans/composer-patches": "^1.7.2",
"icanhazstring/composer-unused": "^0.8.5",
"nategood/httpful": "^0.3.2",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-deprecation-rules": "^1.1",
Expand Down
13 changes: 2 additions & 11 deletions src/Configuration/ConfigInitializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,18 @@
use Rector\Core\Php\PhpVersionProvider;
use Rector\PostRector\Contract\Rector\PostRectorInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;

final class ConfigInitializer
{
/**
* @var RectorInterface[]
*/
private array $rectors = [];

/**
* @param RewindableGenerator<RectorInterface>|RectorInterface[] $rectors
* @param RectorInterface[] $rectors
*/
public function __construct(
iterable $rectors,
private readonly array $rectors,
private readonly InitFilePathsResolver $initFilePathsResolver,
private readonly SymfonyStyle $symfonyStyle,
private readonly PhpVersionProvider $phpVersionProvider,
) {
$this->rectors = $rectors instanceof RewindableGenerator ? iterator_to_array(
$rectors->getIterator()
) : $rectors;
}

public function createConfig(string $projectDirectory): void
Expand Down
4 changes: 2 additions & 2 deletions src/Configuration/Parameter/SimpleParameterProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Rector\Core\Configuration\Parameter;

use Rector\Core\Configuration\Option;
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
use Rector\Core\Exception\ShouldNotHappenException;
use Webmozart\Assert\Assert;

/**
Expand Down Expand Up @@ -113,6 +113,6 @@ private static function ensureParameterIsSet(string $name): void
return;
}

throw new ParameterNotFoundException($name);
throw new ShouldNotHappenException(sprintf('Parameter "%s" was not found', $name));
}
}
16 changes: 2 additions & 14 deletions src/Console/Command/ListRulesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,18 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;

final class ListRulesCommand extends Command
{
/**
* @var RectorInterface[]
*/
private array $rectors = [];

/**
* @param RewindableGenerator<RectorInterface>|RectorInterface[] $rectors
* @param RectorInterface[] $rectors
*/
public function __construct(
private readonly SymfonyStyle $symfonyStyle,
private readonly SkippedClassResolver $skippedClassResolver,
iterable $rectors
private readonly array $rectors
) {
parent::__construct();

if ($rectors instanceof RewindableGenerator) {
$rectors = iterator_to_array($rectors->getIterator());
}

$this->rectors = $rectors;
}

protected function configure(): void
Expand Down

This file was deleted.

11 changes: 2 additions & 9 deletions src/PhpParser/NodeTraverser/RectorNodeTraverser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,18 @@
use PhpParser\NodeTraverser;
use Rector\Core\Contract\Rector\PhpRectorInterface;
use Rector\VersionBonding\PhpVersionedFilter;
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;

final class RectorNodeTraverser extends NodeTraverser
{
private bool $areNodeVisitorsPrepared = false;

/**
* @var PhpRectorInterface[]
*/
private array $phpRectors = [];

/**
* @param RewindableGenerator<PhpRectorInterface>|PhpRectorInterface[] $phpRectors
* @param PhpRectorInterface[] $phpRectors
*/
public function __construct(
iterable $phpRectors,
private array $phpRectors,
private readonly PhpVersionedFilter $phpVersionedFilter
) {
$this->phpRectors = is_array($phpRectors) ? $phpRectors : iterator_to_array($phpRectors);
parent::__construct();
}

Expand Down

0 comments on commit f73ae8b

Please sign in to comment.