Skip to content

Commit cadbb8e

Browse files
committed
Updated for PHPStan 0.7
1 parent 50162c7 commit cadbb8e

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

build.xml

+1-1
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

+9-3
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@
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.3",
14+
"phpstan/phpstan": "^0.7",
1015
"doctrine/common": "^2.7",
1116
"doctrine/orm": "^2.5"
1217
},
1318
"require-dev": {
14-
"consistence/coding-standard": "~0.12.0",
19+
"consistence/coding-standard": "~0.13.0",
20+
"jakub-onderka/php-parallel-lint": "^0.9.2",
1521
"phing/phing": "^2.16.0",
1622
"phpunit/phpunit": "^5.7",
17-
"slevomat/coding-standard": "dev-php7#d4a1a9c"
23+
"slevomat/coding-standard": "^2.0"
1824
},
1925
"autoload": {
2026
"psr-4": {

ruleset.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
<exclude name="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces"/>
88
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/>
99
</rule>
10-
<rule ref="SlevomatCodingStandard.Typehints.TypeHintDeclaration">
10+
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration">
1111
<properties>
1212
<property name="usefulAnnotations" type="array" value="
1313
@dataProvider
1414
"/>
15+
<property name="enableNullableTypeHints" type="false" />
16+
<property name="enableVoidTypeHint" type="false" />
1517
</properties>
1618
</rule>
1719
</ruleset>

src/Type/Doctrine/EntityManagerFindDynamicReturnTypeExtension.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PHPStan\Reflection\MethodReflection;
88
use PHPStan\Type\ObjectType;
99
use PHPStan\Type\Type;
10+
use PHPStan\Type\TypeCombinator;
1011

1112
class EntityManagerFindDynamicReturnTypeExtension implements \PHPStan\Type\DynamicMethodReturnTypeExtension
1213
{
@@ -51,10 +52,15 @@ public function getTypeFromMethodCall(
5152
}
5253

5354
if ($class === 'self') {
54-
$class = $scope->getClass();
55+
$class = $scope->getClassReflection()->getName();
5556
}
5657

57-
return new ObjectType($class, $methodReflection->getName() === 'find');
58+
$type = new ObjectType($class);
59+
if ($methodReflection->getName() === 'find') {
60+
$type = TypeCombinator::addNull($type);
61+
}
62+
63+
return $type;
5864
}
5965

6066
}

0 commit comments

Comments
 (0)