Skip to content

Commit 1a8acd1

Browse files
lookymanondrejmirtes
authored andcommitted
Replaced some requirements with conflicts
1 parent 77f9cb3 commit 1a8acd1

11 files changed

+32
-28
lines changed

composer.json

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
"require": {
1313
"php": "~7.1",
1414
"phpstan/phpstan": "^0.10",
15-
"nette/application": "^2.3.0 || ^3.0.0",
16-
"nette/component-model": "^2.3.0 || ^3.0.0",
17-
"nette/di": "^2.3.0 || ^3.0.0",
18-
"nette/forms": "^2.3.0 || ^3.0.0",
19-
"nette/utils": "^2.3.0 || ^3.0.0",
20-
"nette/http": "^2.3.0 || ^3.0.0",
2115
"nikic/php-parser": "^4.0"
2216
},
2317
"require-dev": {
@@ -30,7 +24,21 @@
3024
"phpstan/phpstan-strict-rules": "^0.10",
3125
"phpunit/phpunit": "^7.0",
3226
"satooshi/php-coveralls": "^1.0",
33-
"slevomat/coding-standard": "^4.5.2"
27+
"slevomat/coding-standard": "^4.5.2",
28+
"nette/application": "^2.3.0 || ^3.0.0",
29+
"nette/component-model": "^2.3.0 || ^3.0.0",
30+
"nette/di": "^2.3.0 || ^3.0.0",
31+
"nette/forms": "^2.3.0 || ^3.0.0",
32+
"nette/utils": "^2.3.0 || ^3.0.0",
33+
"nette/http": "^2.3.0 || ^3.0.0"
34+
},
35+
"conflict": {
36+
"nette/application": "<2.3.0",
37+
"nette/component-model": "<2.3.0",
38+
"nette/di": "<2.3.0",
39+
"nette/forms": "<2.3.0",
40+
"nette/utils": "<2.3.0",
41+
"nette/http": "<2.3.0"
3442
},
3543
"autoload": {
3644
"psr-4": {

src/Reflection/Nette/HtmlClassReflectionExtension.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace PHPStan\Reflection\Nette;
44

5-
use Nette\Utils\Html;
65
use PHPStan\Reflection\ClassReflection;
76
use PHPStan\Reflection\MethodReflection;
87
use PHPStan\Reflection\MethodsClassReflectionExtension;
@@ -14,7 +13,7 @@ class HtmlClassReflectionExtension implements MethodsClassReflectionExtension, P
1413

1514
public function hasMethod(ClassReflection $classReflection, string $methodName): bool
1615
{
17-
return $classReflection->getName() === Html::class || $classReflection->isSubclassOf(Html::class);
16+
return $classReflection->getName() === 'Nette\Utils\Html' || $classReflection->isSubclassOf('Nette\Utils\Html');
1817
}
1918

2019
public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection
@@ -24,7 +23,7 @@ public function getMethod(ClassReflection $classReflection, string $methodName):
2423

2524
public function hasProperty(ClassReflection $classReflection, string $propertyName): bool
2625
{
27-
return $classReflection->getName() === Html::class || $classReflection->isSubclassOf(Html::class);
26+
return $classReflection->getName() === 'Nette\Utils\Html' || $classReflection->isSubclassOf('Nette\Utils\Html');
2827
}
2928

3029
public function getProperty(ClassReflection $classReflection, string $propertyName): PropertyReflection

src/Reflection/Nette/HtmlMethodReflection.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace PHPStan\Reflection\Nette;
44

5-
use Nette\Utils\Html;
65
use PHPStan\Reflection\ClassMemberReflection;
76
use PHPStan\Reflection\ClassReflection;
87
use PHPStan\Reflection\FunctionVariant;
@@ -49,7 +48,7 @@ public function getVariants(): array
4948
new FunctionVariant(
5049
[],
5150
true,
52-
substr($this->name, 0, 3) === 'get' ? new MixedType() : new ObjectType(Html::class)
51+
substr($this->name, 0, 3) === 'get' ? new MixedType() : new ObjectType('Nette\Utils\Html')
5352
),
5453
];
5554
}

src/Reflection/Nette/NetteObjectClassReflectionExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function getProperty(ClassReflection $classReflection, string $propertyNa
4949
public function hasMethod(ClassReflection $classReflection, string $methodName): bool
5050
{
5151
$traitNames = $this->getTraitNames($classReflection->getNativeReflection());
52-
if (!in_array(\Nette\SmartObject::class, $traitNames, true) && !$this->inheritsFromNetteObject($classReflection->getNativeReflection())) {
52+
if (!in_array('Nette\SmartObject', $traitNames, true) && !$this->inheritsFromNetteObject($classReflection->getNativeReflection())) {
5353
return false;
5454
}
5555

src/Rule/Nette/DoNotExtendNetteObjectRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function processNode(Node $node, Scope $scope): array
5353
"Class %s extends %s - it's better to use %s trait.",
5454
$className,
5555
'Nette\Object',
56-
\Nette\SmartObject::class
56+
'Nette\SmartObject'
5757
),
5858
];
5959
}

src/Type/Nette/ComponentLookupDynamicReturnTypeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class ComponentLookupDynamicReturnTypeExtension implements DynamicMethodRe
1616

1717
public function getClass(): string
1818
{
19-
return \Nette\ComponentModel\Component::class;
19+
return 'Nette\ComponentModel\Component';
2020
}
2121

2222
public function isMethodSupported(MethodReflection $methodReflection): bool

src/Type/Nette/ComponentModelDynamicReturnTypeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ComponentModelDynamicReturnTypeExtension implements DynamicMethodReturnTyp
1616

1717
public function getClass(): string
1818
{
19-
return \Nette\ComponentModel\Container::class;
19+
return 'Nette\ComponentModel\Container';
2020
}
2121

2222
public function isMethodSupported(

src/Type/Nette/FormContainerValuesDynamicReturnTypeExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class FormContainerValuesDynamicReturnTypeExtension implements DynamicMeth
1919

2020
public function getClass(): string
2121
{
22-
return \Nette\Forms\Container::class;
22+
return 'Nette\Forms\Container';
2323
}
2424

2525
public function isMethodSupported(MethodReflection $methodReflection): bool
@@ -30,7 +30,7 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
3030
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
3131
{
3232
if (count($methodCall->args) === 0) {
33-
return new ObjectType(\Nette\Utils\ArrayHash::class);
33+
return new ObjectType('Nette\Utils\ArrayHash');
3434
}
3535

3636
$arg = $methodCall->args[0]->value;
@@ -40,7 +40,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
4040
}
4141

4242
if (!$scopedType->getValue()) {
43-
return new ObjectType(\Nette\Utils\ArrayHash::class);
43+
return new ObjectType('Nette\Utils\ArrayHash');
4444
}
4545

4646
return new ArrayType(new StringType(), new MixedType());

src/Type/Nette/FormsBaseControlDynamicReturnTypeExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ class FormsBaseControlDynamicReturnTypeExtension implements \PHPStan\Type\Dynami
1313

1414
public function getClass(): string
1515
{
16-
return \Nette\Forms\Controls\BaseControl::class;
16+
return 'Nette\Forms\Controls\BaseControl';
1717
}
1818

1919
public function isMethodSupported(
2020
MethodReflection $methodReflection
2121
): bool
2222
{
23-
return $methodReflection->getDeclaringClass()->getName() === \Nette\Forms\Controls\BaseControl::class;
23+
return $methodReflection->getDeclaringClass()->getName() === 'Nette\Forms\Controls\BaseControl';
2424
}
2525

2626
public function getTypeFromMethodCall(
@@ -33,7 +33,7 @@ public function getTypeFromMethodCall(
3333
$referencedClasses = $returnType->getReferencedClasses();
3434
if (
3535
count($referencedClasses) === 1
36-
&& $referencedClasses[0] === \Nette\Forms\Controls\BaseControl::class
36+
&& $referencedClasses[0] === 'Nette\Forms\Controls\BaseControl'
3737
) {
3838
return $scope->getType($methodCall->var);
3939
}

src/Type/Nette/PresenterGetSessionReturnTypeExtension.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace PHPStan\Type\Nette;
44

5-
use Nette\Http\Session;
6-
use Nette\Http\SessionSection;
75
use PhpParser\Node\Expr\MethodCall;
86
use PHPStan\Analyser\Scope;
97
use PHPStan\Reflection\MethodReflection;
@@ -17,7 +15,7 @@ final class PresenterGetSessionReturnTypeExtension implements DynamicMethodRetur
1715

1816
public function getClass(): string
1917
{
20-
return \Nette\Application\UI\Presenter::class;
18+
return 'Nette\Application\UI\Presenter';
2119
}
2220

2321
public function isMethodSupported(MethodReflection $methodReflection): bool
@@ -28,10 +26,10 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
2826
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
2927
{
3028
if (count($methodCall->args) === 0 || $scope->getType($methodCall->args[0]->value) instanceof NullType) {
31-
return new ObjectType(Session::class);
29+
return new ObjectType('Nette\Http\Session');
3230
}
3331

34-
return new ObjectType(SessionSection::class);
32+
return new ObjectType('Nette\Http\SessionSection');
3533
}
3634

3735
}

src/Type/Nette/ServiceLocatorDynamicReturnTypeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ServiceLocatorDynamicReturnTypeExtension implements \PHPStan\Type\DynamicM
1717

1818
public function getClass(): string
1919
{
20-
return \Nette\DI\Container::class;
20+
return 'Nette\DI\Container';
2121
}
2222

2323
public function isMethodSupported(MethodReflection $methodReflection): bool

0 commit comments

Comments
 (0)