Skip to content

Commit aea27d5

Browse files
committed
Updated for PHPStan 0.7
1 parent 1c116ae commit aea27d5

8 files changed

+18
-15
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
>
9393
<arg value="analyse"/>
9494
<arg value="-l"/>
95-
<arg value="4"/>
95+
<arg value="7"/>
9696
<arg value="-c"/>
9797
<arg path="phpstan.neon"/>
9898
<arg path="src"/>

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
"license": ["MIT"],
55
"minimum-stability": "dev",
66
"prefer-stable": true,
7+
"extra": {
8+
"branch-alias": {
9+
"dev-master": "0.7-dev"
10+
}
11+
},
712
"require": {
813
"php": "~7.0",
9-
"phpstan/phpstan": "^0.6",
14+
"phpstan/phpstan": "^0.7",
1015
"nette/component-model": "^2.3.0 || ^3.0.0",
1116
"nette/di": "^2.3.0 || ^3.0.0",
1217
"nette/forms": "^2.3.0 || ^3.0.0",

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
22
ignoreErrors:
3-
- '#Call to an undefined method PHPUnit_Framework_MockObject_MockObject::[a-zA-Z0-9_]+\(\)#'
3+
- '#PHPUnit_Framework_MockObject_MockObject given#'
44
- '#Class Nette\\Utils\\ObjectHelpers not found#'
55
- '#Call to static method getMagicProperties\(\) on an unknown class Nette\\Utils\\ObjectHelpers#'

src/Reflection/Nette/HtmlMethodReflection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function getName(): string
6868

6969
public function getReturnType(): Type
7070
{
71-
return new ObjectType(Html::class, false);
71+
return new ObjectType(Html::class);
7272
}
7373

7474
}

src/Reflection/Nette/NetteObjectClassReflectionExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ private function getMethodByProperty(ClassReflection $classReflection, string $p
5050

5151
public function getProperty(ClassReflection $classReflection, string $propertyName): PropertyReflection
5252
{
53+
/** @var \PHPStan\Reflection\MethodReflection $getterMethod */
5354
$getterMethod = $this->getMethodByProperty($classReflection, $propertyName);
5455
return new NetteObjectPropertyReflection($classReflection, $getterMethod->getReturnType());
5556
}

src/Reflection/Nette/SmartObjectPropertiesClassReflectionExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ private function getMethodByProperty(ClassReflection $classReflection, string $p
7171

7272
public function getProperty(ClassReflection $classReflection, string $propertyName): PropertyReflection
7373
{
74+
/** @var \PHPStan\Reflection\MethodReflection $getterMethod */
7475
$getterMethod = $this->getMethodByProperty($classReflection, $propertyName);
7576
return new NetteObjectPropertyReflection($classReflection, $getterMethod->getReturnType());
7677
}

src/Type/Nette/ServiceLocatorDynamicReturnTypeExtension.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PHPStan\Type\ObjectType;
99
use PHPStan\Type\TrueBooleanType;
1010
use PHPStan\Type\Type;
11+
use PHPStan\Type\TypeCombinator;
1112

1213
class ServiceLocatorDynamicReturnTypeExtension implements \PHPStan\Type\DynamicMethodReturnTypeExtension
1314
{
@@ -47,19 +48,19 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
4748
}
4849

4950
if ($class === 'self') {
50-
$class = $scope->getClass();
51+
$class = $scope->getClassReflection()->getName();
5152
}
5253

53-
$isNullable = false;
54+
$type = new ObjectType($class);
5455
if (
5556
$methodReflection->getName() === 'getByType'
5657
&& count($methodCall->args) >= 2
5758
&& $scope->getType($methodCall->args[1]->value) instanceof TrueBooleanType
5859
) {
59-
$isNullable = true;
60+
$type = TypeCombinator::addNull($type);
6061
}
6162

62-
return new ObjectType($class, $isNullable);
63+
return $type;
6364
}
6465

6566
}

tests/Reflection/Nette/HtmlClassReflectionExtensionTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace PHPStan\Reflection\Nette;
44

55
use PHPStan\Reflection\ClassReflection;
6-
use PHPStan\Type\MixedType;
7-
use PHPStan\Type\ObjectType;
86

97
class HtmlClassReflectionExtensionTest extends \PHPUnit_Framework_TestCase
108
{
@@ -58,9 +56,7 @@ public function testGetMethod()
5856
$this->assertTrue($methodReflection->isVariadic());
5957
$this->assertFalse($methodReflection->isPrivate());
6058
$this->assertTrue($methodReflection->isPublic());
61-
$this->assertInstanceOf(ObjectType::class, $methodReflection->getReturnType());
62-
$this->assertSame(\Nette\Utils\Html::class, $methodReflection->getReturnType()->getClass());
63-
$this->assertFalse($methodReflection->getReturnType()->isNullable());
59+
$this->assertSame(\Nette\Utils\Html::class, $methodReflection->getReturnType()->describe());
6460
}
6561

6662
/**
@@ -101,8 +97,7 @@ public function testGetProperty()
10197
$this->assertFalse($propertyReflection->isStatic());
10298
$this->assertFalse($propertyReflection->isPrivate());
10399
$this->assertTrue($propertyReflection->isPublic());
104-
$this->assertInstanceOf(MixedType::class, $propertyReflection->getType());
105-
$this->assertTrue($propertyReflection->getType()->isNullable());
100+
$this->assertSame('mixed', $propertyReflection->getType()->describe());
106101
}
107102

108103
}

0 commit comments

Comments
 (0)