Skip to content

Commit d1e08ac

Browse files
committed
Fixes after PHPStan update
1 parent a0572ad commit d1e08ac

15 files changed

+48
-27
lines changed

src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use PhpParser\Node;
66
use PhpParser\Node\Expr\MethodCall;
7-
use PhpParser\PrettyPrinter\Standard;
87
use PHPStan\Analyser\Scope;
8+
use PHPStan\Node\Printer\Printer;
99
use PHPStan\Rules\Rule;
1010
use PHPStan\Rules\RuleErrorBuilder;
1111
use PHPStan\Symfony\ServiceMap;
@@ -21,9 +21,9 @@ final class ContainerInterfaceUnknownServiceRule implements Rule
2121

2222
private ServiceMap $serviceMap;
2323

24-
private Standard $printer;
24+
private Printer $printer;
2525

26-
public function __construct(ServiceMap $symfonyServiceMap, Standard $printer)
26+
public function __construct(ServiceMap $symfonyServiceMap, Printer $printer)
2727
{
2828
$this->serviceMap = $symfonyServiceMap;
2929
$this->printer = $printer;

src/Rules/Symfony/UndefinedArgumentRule.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use InvalidArgumentException;
66
use PhpParser\Node;
77
use PhpParser\Node\Expr\MethodCall;
8-
use PhpParser\PrettyPrinter\Standard;
98
use PHPStan\Analyser\Scope;
9+
use PHPStan\Node\Printer\Printer;
1010
use PHPStan\Rules\Rule;
1111
use PHPStan\Rules\RuleErrorBuilder;
1212
use PHPStan\Symfony\ConsoleApplicationResolver;
@@ -23,9 +23,9 @@ final class UndefinedArgumentRule implements Rule
2323

2424
private ConsoleApplicationResolver $consoleApplicationResolver;
2525

26-
private Standard $printer;
26+
private Printer $printer;
2727

28-
public function __construct(ConsoleApplicationResolver $consoleApplicationResolver, Standard $printer)
28+
public function __construct(ConsoleApplicationResolver $consoleApplicationResolver, Printer $printer)
2929
{
3030
$this->consoleApplicationResolver = $consoleApplicationResolver;
3131
$this->printer = $printer;

src/Rules/Symfony/UndefinedOptionRule.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use InvalidArgumentException;
66
use PhpParser\Node;
77
use PhpParser\Node\Expr\MethodCall;
8-
use PhpParser\PrettyPrinter\Standard;
98
use PHPStan\Analyser\Scope;
9+
use PHPStan\Node\Printer\Printer;
1010
use PHPStan\Rules\Rule;
1111
use PHPStan\Rules\RuleErrorBuilder;
1212
use PHPStan\Symfony\ConsoleApplicationResolver;
@@ -23,9 +23,9 @@ final class UndefinedOptionRule implements Rule
2323

2424
private ConsoleApplicationResolver $consoleApplicationResolver;
2525

26-
private Standard $printer;
26+
private Printer $printer;
2727

28-
public function __construct(ConsoleApplicationResolver $consoleApplicationResolver, Standard $printer)
28+
public function __construct(ConsoleApplicationResolver $consoleApplicationResolver, Printer $printer)
2929
{
3030
$this->consoleApplicationResolver = $consoleApplicationResolver;
3131
$this->printer = $printer;

src/Type/Symfony/ArgumentTypeSpecifyingExtension.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
namespace PHPStan\Type\Symfony;
44

55
use PhpParser\Node\Expr\MethodCall;
6-
use PhpParser\PrettyPrinter\Standard;
76
use PHPStan\Analyser\Scope;
87
use PHPStan\Analyser\SpecifiedTypes;
98
use PHPStan\Analyser\TypeSpecifier;
109
use PHPStan\Analyser\TypeSpecifierAwareExtension;
1110
use PHPStan\Analyser\TypeSpecifierContext;
11+
use PHPStan\Node\Printer\Printer;
1212
use PHPStan\Reflection\MethodReflection;
1313
use PHPStan\Type\MethodTypeSpecifyingExtension;
1414

1515
final class ArgumentTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
1616
{
1717

18-
private Standard $printer;
18+
private Printer $printer;
1919

2020
private TypeSpecifier $typeSpecifier;
2121

22-
public function __construct(Standard $printer)
22+
public function __construct(Printer $printer)
2323
{
2424
$this->printer = $printer;
2525
}

src/Type/Symfony/Config/PassParentObjectDynamicReturnTypeExtension.php

+2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
final class PassParentObjectDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
1616
{
1717

18+
/** @var class-string */
1819
private string $className;
1920

2021
/** @var string[] */
2122
private array $methods;
2223

2324
/**
25+
* @param class-string $className
2426
* @param string[] $methods
2527
*/
2628
public function __construct(string $className, array $methods)

src/Type/Symfony/Config/ReturnParentDynamicReturnTypeExtension.php

+2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
final class ReturnParentDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
1414
{
1515

16+
/** @var class-string */
1617
private string $className;
1718

1819
/** @var string[] */
1920
private array $methods;
2021

2122
/**
23+
* @param class-string $className
2224
* @param string[] $methods
2325
*/
2426
public function __construct(string $className, array $methods)

src/Type/Symfony/OptionTypeSpecifyingExtension.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
namespace PHPStan\Type\Symfony;
44

55
use PhpParser\Node\Expr\MethodCall;
6-
use PhpParser\PrettyPrinter\Standard;
76
use PHPStan\Analyser\Scope;
87
use PHPStan\Analyser\SpecifiedTypes;
98
use PHPStan\Analyser\TypeSpecifier;
109
use PHPStan\Analyser\TypeSpecifierAwareExtension;
1110
use PHPStan\Analyser\TypeSpecifierContext;
11+
use PHPStan\Node\Printer\Printer;
1212
use PHPStan\Reflection\MethodReflection;
1313
use PHPStan\Type\MethodTypeSpecifyingExtension;
1414

1515
final class OptionTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
1616
{
1717

18-
private Standard $printer;
18+
private Printer $printer;
1919

2020
private TypeSpecifier $typeSpecifier;
2121

22-
public function __construct(Standard $printer)
22+
public function __construct(Printer $printer)
2323
{
2424
$this->printer = $printer;
2525
}

src/Type/Symfony/ParameterDynamicReturnTypeExtension.php

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
final class ParameterDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
4343
{
4444

45+
/** @var class-string */
4546
private string $className;
4647

4748
private ?string $methodGet = null;
@@ -54,6 +55,9 @@ final class ParameterDynamicReturnTypeExtension implements DynamicMethodReturnTy
5455

5556
private TypeStringResolver $typeStringResolver;
5657

58+
/**
59+
* @param class-string $className
60+
*/
5761
public function __construct(
5862
string $className,
5963
?string $methodGet,

src/Type/Symfony/SerializerDynamicReturnTypeExtension.php

+4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@
1717
class SerializerDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
1818
{
1919

20+
/** @var class-string */
2021
private string $class;
2122

2223
private string $method;
2324

25+
/**
26+
* @param class-string $class
27+
*/
2428
public function __construct(string $class, string $method)
2529
{
2630
$this->class = $class;

src/Type/Symfony/ServiceDynamicReturnTypeExtension.php

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
final class ServiceDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
2323
{
2424

25+
/** @var class-string */
2526
private string $className;
2627

2728
private bool $constantHassers;
@@ -32,6 +33,9 @@ final class ServiceDynamicReturnTypeExtension implements DynamicMethodReturnType
3233

3334
private ?ParameterBag $parameterBag = null;
3435

36+
/**
37+
* @param class-string $className
38+
*/
3539
public function __construct(
3640
string $className,
3741
Configuration $configuration,

src/Type/Symfony/ServiceTypeSpecifyingExtension.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,29 @@
33
namespace PHPStan\Type\Symfony;
44

55
use PhpParser\Node\Expr\MethodCall;
6-
use PhpParser\PrettyPrinter\Standard;
76
use PHPStan\Analyser\Scope;
87
use PHPStan\Analyser\SpecifiedTypes;
98
use PHPStan\Analyser\TypeSpecifier;
109
use PHPStan\Analyser\TypeSpecifierAwareExtension;
1110
use PHPStan\Analyser\TypeSpecifierContext;
11+
use PHPStan\Node\Printer\Printer;
1212
use PHPStan\Reflection\MethodReflection;
1313
use PHPStan\Type\MethodTypeSpecifyingExtension;
1414

1515
final class ServiceTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
1616
{
1717

18+
/** @var class-string */
1819
private string $className;
1920

20-
private Standard $printer;
21+
private Printer $printer;
2122

2223
private TypeSpecifier $typeSpecifier;
2324

24-
public function __construct(string $className, Standard $printer)
25+
/**
26+
* @param class-string $className
27+
*/
28+
public function __construct(string $className, Printer $printer)
2529
{
2630
$this->className = $className;
2731
$this->printer = $printer;

tests/Rules/Symfony/ContainerInterfaceUnknownServiceRuleFakeTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace PHPStan\Rules\Symfony;
44

5-
use PhpParser\PrettyPrinter\Standard;
5+
use PHPStan\Node\Printer\Printer;
66
use PHPStan\Rules\Rule;
77
use PHPStan\Symfony\Configuration;
88
use PHPStan\Symfony\XmlServiceMapFactory;
99
use PHPStan\Testing\RuleTestCase;
1010
use PHPStan\Type\MethodTypeSpecifyingExtension;
1111
use PHPStan\Type\Symfony\ServiceTypeSpecifyingExtension;
12+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1213
use function class_exists;
1314

1415
/**
@@ -19,7 +20,7 @@ final class ContainerInterfaceUnknownServiceRuleFakeTest extends RuleTestCase
1920

2021
protected function getRule(): Rule
2122
{
22-
return new ContainerInterfaceUnknownServiceRule((new XmlServiceMapFactory(new Configuration([])))->create(), new Standard());
23+
return new ContainerInterfaceUnknownServiceRule((new XmlServiceMapFactory(new Configuration([])))->create(), self::getContainer()->getByType(Printer::class));
2324
}
2425

2526
/**
@@ -28,7 +29,7 @@ protected function getRule(): Rule
2829
protected function getMethodTypeSpecifyingExtensions(): array
2930
{
3031
return [
31-
new ServiceTypeSpecifyingExtension('Symfony\Bundle\FrameworkBundle\Controller\Controller', new Standard()),
32+
new ServiceTypeSpecifyingExtension(AbstractController::class, self::getContainer()->getByType(Printer::class)),
3233
];
3334
}
3435

tests/Rules/Symfony/ContainerInterfaceUnknownServiceRuleTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PHPStan\Rules\Symfony;
44

5-
use PhpParser\PrettyPrinter\Standard;
5+
use PHPStan\Node\Printer\Printer;
66
use PHPStan\Rules\Rule;
77
use PHPStan\Symfony\Configuration;
88
use PHPStan\Symfony\XmlServiceMapFactory;
@@ -18,7 +18,7 @@ final class ContainerInterfaceUnknownServiceRuleTest extends RuleTestCase
1818

1919
protected function getRule(): Rule
2020
{
21-
return new ContainerInterfaceUnknownServiceRule((new XmlServiceMapFactory(new Configuration(['containerXmlPath' => __DIR__ . '/container.xml'])))->create(), new Standard());
21+
return new ContainerInterfaceUnknownServiceRule((new XmlServiceMapFactory(new Configuration(['containerXmlPath' => __DIR__ . '/container.xml'])))->create(), self::getContainer()->getByType(Printer::class));
2222
}
2323

2424
public function testGetPrivateService(): void

tests/Rules/Symfony/UndefinedArgumentRuleTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PHPStan\Rules\Symfony;
44

5-
use PhpParser\PrettyPrinter\Standard;
5+
use PHPStan\Node\Printer\Printer;
66
use PHPStan\Rules\Rule;
77
use PHPStan\Symfony\Configuration;
88
use PHPStan\Symfony\ConsoleApplicationResolver;
@@ -16,7 +16,7 @@ final class UndefinedArgumentRuleTest extends RuleTestCase
1616

1717
protected function getRule(): Rule
1818
{
19-
return new UndefinedArgumentRule(new ConsoleApplicationResolver(new Configuration(['consoleApplicationLoader' => __DIR__ . '/console_application_loader.php'])), new Standard());
19+
return new UndefinedArgumentRule(new ConsoleApplicationResolver(new Configuration(['consoleApplicationLoader' => __DIR__ . '/console_application_loader.php'])), self::getContainer()->getByType(Printer::class));
2020
}
2121

2222
public function testGetArgument(): void

tests/Rules/Symfony/UndefinedOptionRuleTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PHPStan\Rules\Symfony;
44

5-
use PhpParser\PrettyPrinter\Standard;
5+
use PHPStan\Node\Printer\Printer;
66
use PHPStan\Rules\Rule;
77
use PHPStan\Symfony\Configuration;
88
use PHPStan\Symfony\ConsoleApplicationResolver;
@@ -16,7 +16,7 @@ final class UndefinedOptionRuleTest extends RuleTestCase
1616

1717
protected function getRule(): Rule
1818
{
19-
return new UndefinedOptionRule(new ConsoleApplicationResolver(new Configuration(['consoleApplicationLoader' => __DIR__ . '/console_application_loader.php'])), new Standard());
19+
return new UndefinedOptionRule(new ConsoleApplicationResolver(new Configuration(['consoleApplicationLoader' => __DIR__ . '/console_application_loader.php'])), self::getContainer()->getByType(Printer::class));
2020
}
2121

2222
public function testGetArgument(): void

0 commit comments

Comments
 (0)