Compatibility with PHPStan 0.12.4

This commit is contained in:
Ondrej Mirtes 2020-01-06 09:43:51 +01:00
parent 84e1e98a51
commit b77fa521c3
No known key found for this signature in database
GPG Key ID: 8E730BA25823D8B5
4 changed files with 21 additions and 1 deletions

View File

@ -21,7 +21,7 @@
"nikic/php-parser": "^4.3",
"ondram/ci-detector": "^3.1",
"phpstan/phpdoc-parser": "^0.4",
"phpstan/phpstan": "0.12.3",
"phpstan/phpstan": "^0.12.4",
"phpstan/phpstan-phpunit": "^0.12",
"sebastian/diff": "^3.0",
"symfony/console": "^4.4|^5.0",

View File

@ -27,3 +27,6 @@ services:
PHPStan\Analyser\ScopeFactory:
factory: ['@Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory', 'createScopeFactory']
PHPStan\DependencyInjection\Container:
factory: ['@Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory', 'createContainer']

View File

@ -89,4 +89,9 @@ final class PHPStanServicesFactory
{
return $this->container->getByType(ScopeFactory::class);
}
public function createContainer(): Container
{
return $this->container->getByType(Container::class);
}
}

View File

@ -10,6 +10,9 @@ use PHPStan\Analyser\ScopeContext;
use PHPStan\Analyser\ScopeFactory as PHPStanScopeFactory;
use PHPStan\Analyser\TypeSpecifier;
use PHPStan\Broker\Broker;
use PHPStan\DependencyInjection\Container;
use PHPStan\DependencyInjection\Type\DynamicReturnTypeExtensionRegistryProvider;
use PHPStan\DependencyInjection\Type\OperatorTypeSpecifyingExtensionRegistryProvider;
use PHPStan\Rules\Properties\PropertyReflectionFinder;
use Rector\PhpParser\Printer\BetterStandardPrinter;
@ -20,6 +23,11 @@ final class ScopeFactory
*/
private $broker;
/**
* @var \PHPStan\DependencyInjection\Container
*/
private $container;
/**
* @var TypeSpecifier
*/
@ -37,11 +45,13 @@ final class ScopeFactory
public function __construct(
Broker $broker,
Container $container,
TypeSpecifier $typeSpecifier,
PHPStanScopeFactory $phpStanScopeFactory,
BetterStandardPrinter $betterStandardPrinter
) {
$this->broker = $broker;
$this->container = $container;
$this->typeSpecifier = $typeSpecifier;
$this->phpStanScopeFactory = $phpStanScopeFactory;
$this->betterStandardPrinter = $betterStandardPrinter;
@ -52,6 +62,8 @@ final class ScopeFactory
return new MutatingScope(
$this->phpStanScopeFactory,
$this->broker,
$this->container->getByType(DynamicReturnTypeExtensionRegistryProvider::class)->getRegistry(),
$this->container->getByType(OperatorTypeSpecifyingExtensionRegistryProvider::class)->getRegistry(),
$this->betterStandardPrinter,
$this->typeSpecifier,
new PropertyReflectionFinder(),