Skip to content

Commit

Permalink
Fixes after PHPStan update
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Oct 4, 2024
1 parent a0572ad commit d1e08ac
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 27 deletions.
6 changes: 3 additions & 3 deletions src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\PrettyPrinter\Standard;
use PHPStan\Analyser\Scope;
use PHPStan\Node\Printer\Printer;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
use PHPStan\Symfony\ServiceMap;
Expand All @@ -21,9 +21,9 @@ final class ContainerInterfaceUnknownServiceRule implements Rule

private ServiceMap $serviceMap;

private Standard $printer;
private Printer $printer;

public function __construct(ServiceMap $symfonyServiceMap, Standard $printer)
public function __construct(ServiceMap $symfonyServiceMap, Printer $printer)
{
$this->serviceMap = $symfonyServiceMap;
$this->printer = $printer;
Expand Down
6 changes: 3 additions & 3 deletions src/Rules/Symfony/UndefinedArgumentRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use InvalidArgumentException;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\PrettyPrinter\Standard;
use PHPStan\Analyser\Scope;
use PHPStan\Node\Printer\Printer;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
use PHPStan\Symfony\ConsoleApplicationResolver;
Expand All @@ -23,9 +23,9 @@ final class UndefinedArgumentRule implements Rule

private ConsoleApplicationResolver $consoleApplicationResolver;

private Standard $printer;
private Printer $printer;

public function __construct(ConsoleApplicationResolver $consoleApplicationResolver, Standard $printer)
public function __construct(ConsoleApplicationResolver $consoleApplicationResolver, Printer $printer)
{
$this->consoleApplicationResolver = $consoleApplicationResolver;
$this->printer = $printer;
Expand Down
6 changes: 3 additions & 3 deletions src/Rules/Symfony/UndefinedOptionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use InvalidArgumentException;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\PrettyPrinter\Standard;
use PHPStan\Analyser\Scope;
use PHPStan\Node\Printer\Printer;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
use PHPStan\Symfony\ConsoleApplicationResolver;
Expand All @@ -23,9 +23,9 @@ final class UndefinedOptionRule implements Rule

private ConsoleApplicationResolver $consoleApplicationResolver;

private Standard $printer;
private Printer $printer;

public function __construct(ConsoleApplicationResolver $consoleApplicationResolver, Standard $printer)
public function __construct(ConsoleApplicationResolver $consoleApplicationResolver, Printer $printer)
{
$this->consoleApplicationResolver = $consoleApplicationResolver;
$this->printer = $printer;
Expand Down
6 changes: 3 additions & 3 deletions src/Type/Symfony/ArgumentTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
namespace PHPStan\Type\Symfony;

use PhpParser\Node\Expr\MethodCall;
use PhpParser\PrettyPrinter\Standard;
use PHPStan\Analyser\Scope;
use PHPStan\Analyser\SpecifiedTypes;
use PHPStan\Analyser\TypeSpecifier;
use PHPStan\Analyser\TypeSpecifierAwareExtension;
use PHPStan\Analyser\TypeSpecifierContext;
use PHPStan\Node\Printer\Printer;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Type\MethodTypeSpecifyingExtension;

final class ArgumentTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
{

private Standard $printer;
private Printer $printer;

private TypeSpecifier $typeSpecifier;

public function __construct(Standard $printer)
public function __construct(Printer $printer)
{
$this->printer = $printer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
final class PassParentObjectDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
{

/** @var class-string */
private string $className;

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

/**
* @param class-string $className
* @param string[] $methods
*/
public function __construct(string $className, array $methods)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
final class ReturnParentDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
{

/** @var class-string */
private string $className;

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

/**
* @param class-string $className
* @param string[] $methods
*/
public function __construct(string $className, array $methods)
Expand Down
6 changes: 3 additions & 3 deletions src/Type/Symfony/OptionTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
namespace PHPStan\Type\Symfony;

use PhpParser\Node\Expr\MethodCall;
use PhpParser\PrettyPrinter\Standard;
use PHPStan\Analyser\Scope;
use PHPStan\Analyser\SpecifiedTypes;
use PHPStan\Analyser\TypeSpecifier;
use PHPStan\Analyser\TypeSpecifierAwareExtension;
use PHPStan\Analyser\TypeSpecifierContext;
use PHPStan\Node\Printer\Printer;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Type\MethodTypeSpecifyingExtension;

final class OptionTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
{

private Standard $printer;
private Printer $printer;

private TypeSpecifier $typeSpecifier;

public function __construct(Standard $printer)
public function __construct(Printer $printer)
{
$this->printer = $printer;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Type/Symfony/ParameterDynamicReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
final class ParameterDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
{

/** @var class-string */
private string $className;

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

private TypeStringResolver $typeStringResolver;

/**
* @param class-string $className
*/
public function __construct(
string $className,
?string $methodGet,
Expand Down
4 changes: 4 additions & 0 deletions src/Type/Symfony/SerializerDynamicReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
class SerializerDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
{

/** @var class-string */
private string $class;

private string $method;

/**
* @param class-string $class
*/
public function __construct(string $class, string $method)
{
$this->class = $class;
Expand Down
4 changes: 4 additions & 0 deletions src/Type/Symfony/ServiceDynamicReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
final class ServiceDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
{

/** @var class-string */
private string $className;

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

private ?ParameterBag $parameterBag = null;

/**
* @param class-string $className
*/
public function __construct(
string $className,
Configuration $configuration,
Expand Down
10 changes: 7 additions & 3 deletions src/Type/Symfony/ServiceTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,29 @@
namespace PHPStan\Type\Symfony;

use PhpParser\Node\Expr\MethodCall;
use PhpParser\PrettyPrinter\Standard;
use PHPStan\Analyser\Scope;
use PHPStan\Analyser\SpecifiedTypes;
use PHPStan\Analyser\TypeSpecifier;
use PHPStan\Analyser\TypeSpecifierAwareExtension;
use PHPStan\Analyser\TypeSpecifierContext;
use PHPStan\Node\Printer\Printer;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Type\MethodTypeSpecifyingExtension;

final class ServiceTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
{

/** @var class-string */
private string $className;

private Standard $printer;
private Printer $printer;

private TypeSpecifier $typeSpecifier;

public function __construct(string $className, Standard $printer)
/**
* @param class-string $className
*/
public function __construct(string $className, Printer $printer)
{
$this->className = $className;
$this->printer = $printer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

namespace PHPStan\Rules\Symfony;

use PhpParser\PrettyPrinter\Standard;
use PHPStan\Node\Printer\Printer;
use PHPStan\Rules\Rule;
use PHPStan\Symfony\Configuration;
use PHPStan\Symfony\XmlServiceMapFactory;
use PHPStan\Testing\RuleTestCase;
use PHPStan\Type\MethodTypeSpecifyingExtension;
use PHPStan\Type\Symfony\ServiceTypeSpecifyingExtension;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use function class_exists;

/**
Expand All @@ -19,7 +20,7 @@ final class ContainerInterfaceUnknownServiceRuleFakeTest extends RuleTestCase

protected function getRule(): Rule
{
return new ContainerInterfaceUnknownServiceRule((new XmlServiceMapFactory(new Configuration([])))->create(), new Standard());
return new ContainerInterfaceUnknownServiceRule((new XmlServiceMapFactory(new Configuration([])))->create(), self::getContainer()->getByType(Printer::class));
}

/**
Expand All @@ -28,7 +29,7 @@ protected function getRule(): Rule
protected function getMethodTypeSpecifyingExtensions(): array
{
return [
new ServiceTypeSpecifyingExtension('Symfony\Bundle\FrameworkBundle\Controller\Controller', new Standard()),
new ServiceTypeSpecifyingExtension(AbstractController::class, self::getContainer()->getByType(Printer::class)),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PHPStan\Rules\Symfony;

use PhpParser\PrettyPrinter\Standard;
use PHPStan\Node\Printer\Printer;
use PHPStan\Rules\Rule;
use PHPStan\Symfony\Configuration;
use PHPStan\Symfony\XmlServiceMapFactory;
Expand All @@ -18,7 +18,7 @@ final class ContainerInterfaceUnknownServiceRuleTest extends RuleTestCase

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

public function testGetPrivateService(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Rules/Symfony/UndefinedArgumentRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PHPStan\Rules\Symfony;

use PhpParser\PrettyPrinter\Standard;
use PHPStan\Node\Printer\Printer;
use PHPStan\Rules\Rule;
use PHPStan\Symfony\Configuration;
use PHPStan\Symfony\ConsoleApplicationResolver;
Expand All @@ -16,7 +16,7 @@ final class UndefinedArgumentRuleTest extends RuleTestCase

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

public function testGetArgument(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Rules/Symfony/UndefinedOptionRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PHPStan\Rules\Symfony;

use PhpParser\PrettyPrinter\Standard;
use PHPStan\Node\Printer\Printer;
use PHPStan\Rules\Rule;
use PHPStan\Symfony\Configuration;
use PHPStan\Symfony\ConsoleApplicationResolver;
Expand All @@ -16,7 +16,7 @@ final class UndefinedOptionRuleTest extends RuleTestCase

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

public function testGetArgument(): void
Expand Down

0 comments on commit d1e08ac

Please sign in to comment.