Skip to content
This repository was archived by the owner on Dec 3, 2023. It is now read-only.

Commit c2192bb

Browse files
authored
[PHPStanRules] Remove NoFactoryInConstructorRule as not possible to resolve caller types (#4130)
1 parent 536b8e8 commit c2192bb

21 files changed

+1
-534
lines changed

packages/phpstan-rules/config/static-rules.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ rules:
1616
- Symplify\PHPStanRules\Rules\ForbiddenParamTypeRemovalRule
1717
- Symplify\PHPStanRules\Rules\NoNestedFuncCallRule
1818
- Symplify\PHPStanRules\Rules\RequireStringRegexMatchKeyRule
19-
- Symplify\PHPStanRules\Rules\NoFactoryInConstructorRule
2019
- Symplify\PHPStanRules\Rules\PreventParentMethodVisibilityOverrideRule
2120

2221
# paths

packages/phpstan-rules/docs/rules_overview.md

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 108 Rules Overview
1+
# 107 Rules Overview
22

33
## AnnotateRegexClassConstWithRegexLinkRule
44

@@ -1832,44 +1832,6 @@ class SomeClass
18321832

18331833
<br>
18341834

1835-
## NoFactoryInConstructorRule
1836-
1837-
Do not use factory/method call in constructor. Put factory in config and get service with dependency injection
1838-
1839-
- class: [`Symplify\PHPStanRules\Rules\NoFactoryInConstructorRule`](../src/Rules/NoFactoryInConstructorRule.php)
1840-
1841-
```php
1842-
class SomeClass
1843-
{
1844-
private $someDependency;
1845-
1846-
public function __construct(SomeFactory $factory)
1847-
{
1848-
$this->someDependency = $factory->build();
1849-
}
1850-
}
1851-
```
1852-
1853-
:x:
1854-
1855-
<br>
1856-
1857-
```php
1858-
class SomeClass
1859-
{
1860-
private $someDependency;
1861-
1862-
public function __construct(SomeDependency $someDependency)
1863-
{
1864-
$this->someDependency = $someDependency;
1865-
}
1866-
}
1867-
```
1868-
1869-
:+1:
1870-
1871-
<br>
1872-
18731835
## NoFuncCallInMethodCallRule
18741836

18751837
Separate function `"%s()"` in method call to standalone row to improve readability

packages/phpstan-rules/src/Reflection/MethodNodeAnalyser.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PHPStan\Analyser\Scope;
88
use PHPStan\Reflection\ClassReflection;
99
use PHPStan\Reflection\MethodReflection;
10-
use Symplify\PackageBuilder\ValueObject\MethodName;
1110

1211
final class MethodNodeAnalyser
1312
{
@@ -44,14 +43,4 @@ public function matchFirstParentClassMethod(Scope $scope, string $methodName): ?
4443

4544
return null;
4645
}
47-
48-
public function isInConstructor(Scope $scope): bool
49-
{
50-
$reflectionFunction = $scope->getFunction();
51-
if (! $reflectionFunction instanceof MethodReflection) {
52-
return false;
53-
}
54-
55-
return $reflectionFunction->getName() === MethodName::CONSTRUCTOR;
56-
}
5746
}

packages/phpstan-rules/src/Rules/NoFactoryInConstructorRule.php

Lines changed: 0 additions & 169 deletions
This file was deleted.

packages/phpstan-rules/tests/Rules/NoFactoryInConstructorRule/Fixture/AbstractClass.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

packages/phpstan-rules/tests/Rules/NoFactoryInConstructorRule/Fixture/SkipArrayDimAssign.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/phpstan-rules/tests/Rules/NoFactoryInConstructorRule/Fixture/SkipEntityRepositoryFactory.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/phpstan-rules/tests/Rules/NoFactoryInConstructorRule/Fixture/SkipException.php

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/phpstan-rules/tests/Rules/NoFactoryInConstructorRule/Fixture/SkipParameterProvider.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/phpstan-rules/tests/Rules/NoFactoryInConstructorRule/Fixture/SkipValueObject.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)