Skip to content

Commit 24f7283

Browse files
committedJun 9, 2021
Rewrite in backward compatibility compliant way
1 parent 748eaac commit 24f7283

File tree

4 files changed

+72
-16
lines changed

4 files changed

+72
-16
lines changed
 

‎composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
],
88
"require": {
99
"php": "^7.1 || ^8.0",
10-
"phpstan/phpstan": "^0.12.89"
10+
"phpstan/phpstan": "^0.12.85"
1111
},
1212
"conflict": {
1313
"doctrine/collections": "<1.0",
+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Reflection\Doctrine;
4+
5+
use PHPStan\Reflection\ParameterReflection;
6+
use PHPStan\Reflection\PassedByReference;
7+
use PHPStan\Type\Type;
8+
9+
class DummyParameter implements ParameterReflection
10+
{
11+
12+
/** @var string */
13+
private $name;
14+
15+
/** @var Type */
16+
private $type;
17+
18+
/** @var bool */
19+
private $optional;
20+
21+
/** @var PassedByReference */
22+
private $passedByReference;
23+
24+
/** @var bool */
25+
private $variadic;
26+
27+
/** @var Type|null */
28+
private $defaultValue;
29+
30+
public function __construct(string $name, Type $type, bool $optional, ?PassedByReference $passedByReference, bool $variadic, ?Type $defaultValue)
31+
{
32+
$this->name = $name;
33+
$this->type = $type;
34+
$this->optional = $optional;
35+
$this->passedByReference = $passedByReference ?? PassedByReference::createNo();
36+
$this->variadic = $variadic;
37+
$this->defaultValue = $defaultValue;
38+
}
39+
40+
public function getName(): string
41+
{
42+
return $this->name;
43+
}
44+
45+
public function isOptional(): bool
46+
{
47+
return $this->optional;
48+
}
49+
50+
public function getType(): Type
51+
{
52+
return $this->type;
53+
}
54+
55+
public function passedByReference(): PassedByReference
56+
{
57+
return $this->passedByReference;
58+
}
59+
60+
public function isVariadic(): bool
61+
{
62+
return $this->variadic;
63+
}
64+
65+
public function getDefaultValue(): ?Type
66+
{
67+
return $this->defaultValue;
68+
}
69+
70+
}

‎src/Reflection/Doctrine/MagicRepositoryMethodReflection.php

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use PHPStan\Reflection\ClassReflection;
66
use PHPStan\Reflection\FunctionVariant;
77
use PHPStan\Reflection\MethodReflection;
8-
use PHPStan\Reflection\Php\DummyParameter;
98
use PHPStan\TrinaryLogic;
109
use PHPStan\Type\Generic\TemplateTypeMap;
1110
use PHPStan\Type\MixedType;

‎tests/Rules/Doctrine/ORM/MagicRepositoryMethodCallRuleTest.php

+1-14
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22

33
namespace PHPStan\Rules\Doctrine\ORM;
44

5-
use PHPStan\Php\PhpVersion;
6-
use PHPStan\Rules\FunctionCallParametersCheck;
75
use PHPStan\Rules\Methods\CallMethodsRule;
8-
use PHPStan\Rules\NullsafeCheck;
9-
use PHPStan\Rules\PhpDoc\UnresolvableTypeHelper;
106
use PHPStan\Rules\Rule;
11-
use PHPStan\Rules\RuleLevelHelper;
127
use PHPStan\Testing\RuleTestCase;
138

149
/**
@@ -19,15 +14,7 @@ class MagicRepositoryMethodCallRuleTest extends RuleTestCase
1914

2015
protected function getRule(): Rule
2116
{
22-
$broker = $this->createBroker();
23-
$ruleLevelHelper = new RuleLevelHelper($broker, true, false, true);
24-
return new CallMethodsRule(
25-
$broker,
26-
new FunctionCallParametersCheck($ruleLevelHelper, new NullsafeCheck(), new PhpVersion(PHP_VERSION_ID), new UnresolvableTypeHelper(true), true, true, true, true, true),
27-
$ruleLevelHelper,
28-
true,
29-
true
30-
);
17+
return self::getContainer()->getByType(CallMethodsRule::class);
3118
}
3219

3320
/**

0 commit comments

Comments
 (0)