Skip to content

Commit

Permalink
Updated for PHPStan 0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed May 8, 2017
1 parent 50162c7 commit cadbb8e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
>
<arg value="analyse"/>
<arg value="-l"/>
<arg value="4"/>
<arg value="7"/>
<arg value="-c"/>
<arg path="phpstan.neon"/>
<arg path="src"/>
Expand Down
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@
"license": ["MIT"],
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"branch-alias": {
"dev-master": "0.7-dev"
}
},
"require": {
"php": "~7.0",
"phpstan/phpstan": "^0.6.3",
"phpstan/phpstan": "^0.7",
"doctrine/common": "^2.7",
"doctrine/orm": "^2.5"
},
"require-dev": {
"consistence/coding-standard": "~0.12.0",
"consistence/coding-standard": "~0.13.0",
"jakub-onderka/php-parallel-lint": "^0.9.2",
"phing/phing": "^2.16.0",
"phpunit/phpunit": "^5.7",
"slevomat/coding-standard": "dev-php7#d4a1a9c"
"slevomat/coding-standard": "^2.0"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 3 additions & 1 deletion ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
<exclude name="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces"/>
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/>
</rule>
<rule ref="SlevomatCodingStandard.Typehints.TypeHintDeclaration">
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration">
<properties>
<property name="usefulAnnotations" type="array" value="
@dataProvider
"/>
<property name="enableNullableTypeHints" type="false" />
<property name="enableVoidTypeHint" type="false" />
</properties>
</rule>
</ruleset>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PHPStan\Reflection\MethodReflection;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;

class EntityManagerFindDynamicReturnTypeExtension implements \PHPStan\Type\DynamicMethodReturnTypeExtension
{
Expand Down Expand Up @@ -51,10 +52,15 @@ public function getTypeFromMethodCall(
}

if ($class === 'self') {
$class = $scope->getClass();
$class = $scope->getClassReflection()->getName();
}

return new ObjectType($class, $methodReflection->getName() === 'find');
$type = new ObjectType($class);
if ($methodReflection->getName() === 'find') {
$type = TypeCombinator::addNull($type);
}

return $type;
}

}

0 comments on commit cadbb8e

Please sign in to comment.