README: add compiler pass + inspiration

This commit is contained in:
Tomas Votruba 2018-08-10 13:48:39 +02:00
parent e44a887f73
commit b5a3333c5e
2 changed files with 23 additions and 5 deletions

View File

@ -188,8 +188,26 @@ foreach ($nodes as $node) {
}
```
3. Add CompilerPass to your Kernel
```php
<?php declare(strict_types=1);
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Rector\NodeTypeResolver\DependencyInjection\CompilerPass\NodeTypeResolverCollectorCompilerPass;
class AppKernel extends Kernel
{
protected function build(ContainerBuilder $containerBuilder): void
{
$containerBuilder->addCompilerPass(new NodeTypeResolverCollectorCompilerPass());
}
}
```
And that's it!
### Inspiration
@todo silverstripe
- [PHPStanScopeVisitor](https://github.com/silverstripe/silverstripe-upgrader/blob/532182b23e854d02e0b27e68ebc394f436de0682/src/UpgradeRule/PHP/Visitor/PHPStanScopeVisitor.php) in [SilverStripe](https://github.com/silverstripe/) - Thank you ❤️️

View File

@ -25,7 +25,7 @@ final class ScopeFactory
/**
* @var PHPStanScopeFactory
*/
private $pHPStanScopeFactory;
private $phpStanScopeFactory;
/**
* @var BetterStandardPrinter
@ -35,19 +35,19 @@ final class ScopeFactory
public function __construct(
Broker $broker,
TypeSpecifier $typeSpecifier,
PHPStanScopeFactory $pHPStanScopeFactory,
PHPStanScopeFactory $phpStanScopeFactory,
BetterStandardPrinter $betterStandardPrinter
) {
$this->broker = $broker;
$this->typeSpecifier = $typeSpecifier;
$this->pHPStanScopeFactory = $pHPStanScopeFactory;
$this->phpStanScopeFactory = $phpStanScopeFactory;
$this->betterStandardPrinter = $betterStandardPrinter;
}
public function createFromFileInfo(SplFileInfo $splFileInfo): Scope
{
return new Scope(
$this->pHPStanScopeFactory,
$this->phpStanScopeFactory,
$this->broker,
$this->betterStandardPrinter,
$this->typeSpecifier,