Skip to content

Commit

Permalink
Rewrite in backward compatibility compliant way
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jun 9, 2021
1 parent 748eaac commit 24f7283
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 16 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -7,7 +7,7 @@
],
"require": {
"php": "^7.1 || ^8.0",
"phpstan/phpstan": "^0.12.89"
"phpstan/phpstan": "^0.12.85"
},
"conflict": {
"doctrine/collections": "<1.0",
Expand Down
70 changes: 70 additions & 0 deletions src/Reflection/Doctrine/DummyParameter.php
@@ -0,0 +1,70 @@
<?php declare(strict_types = 1);

namespace PHPStan\Reflection\Doctrine;

use PHPStan\Reflection\ParameterReflection;
use PHPStan\Reflection\PassedByReference;
use PHPStan\Type\Type;

class DummyParameter implements ParameterReflection
{

/** @var string */
private $name;

/** @var Type */
private $type;

/** @var bool */
private $optional;

/** @var PassedByReference */
private $passedByReference;

/** @var bool */
private $variadic;

/** @var Type|null */
private $defaultValue;

public function __construct(string $name, Type $type, bool $optional, ?PassedByReference $passedByReference, bool $variadic, ?Type $defaultValue)
{
$this->name = $name;
$this->type = $type;
$this->optional = $optional;
$this->passedByReference = $passedByReference ?? PassedByReference::createNo();
$this->variadic = $variadic;
$this->defaultValue = $defaultValue;
}

public function getName(): string
{
return $this->name;
}

public function isOptional(): bool
{
return $this->optional;
}

public function getType(): Type
{
return $this->type;
}

public function passedByReference(): PassedByReference
{
return $this->passedByReference;
}

public function isVariadic(): bool
{
return $this->variadic;
}

public function getDefaultValue(): ?Type
{
return $this->defaultValue;
}

}
Expand Up @@ -5,7 +5,6 @@
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\FunctionVariant;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\Php\DummyParameter;
use PHPStan\TrinaryLogic;
use PHPStan\Type\Generic\TemplateTypeMap;
use PHPStan\Type\MixedType;
Expand Down
15 changes: 1 addition & 14 deletions tests/Rules/Doctrine/ORM/MagicRepositoryMethodCallRuleTest.php
Expand Up @@ -2,13 +2,8 @@

namespace PHPStan\Rules\Doctrine\ORM;

use PHPStan\Php\PhpVersion;
use PHPStan\Rules\FunctionCallParametersCheck;
use PHPStan\Rules\Methods\CallMethodsRule;
use PHPStan\Rules\NullsafeCheck;
use PHPStan\Rules\PhpDoc\UnresolvableTypeHelper;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleLevelHelper;
use PHPStan\Testing\RuleTestCase;

/**
Expand All @@ -19,15 +14,7 @@ class MagicRepositoryMethodCallRuleTest extends RuleTestCase

protected function getRule(): Rule
{
$broker = $this->createBroker();
$ruleLevelHelper = new RuleLevelHelper($broker, true, false, true);
return new CallMethodsRule(
$broker,
new FunctionCallParametersCheck($ruleLevelHelper, new NullsafeCheck(), new PhpVersion(PHP_VERSION_ID), new UnresolvableTypeHelper(true), true, true, true, true, true),
$ruleLevelHelper,
true,
true
);
return self::getContainer()->getByType(CallMethodsRule::class);
}

/**
Expand Down

0 comments on commit 24f7283

Please sign in to comment.