Skip to content

Commit

Permalink
Adjust phpstan entity relation type from Entity -> Entity|null
Browse files Browse the repository at this point in the history
  • Loading branch information
daohoangson committed Oct 1, 2018
1 parent ef1a5ec commit 8df702e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cli/Command/AutoGen.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AutoGen extends Command

const MARKER_BEGINS = '// DevHelper/Autogen begins';
const MARKER_ENDS = '// DevHelper/Autogen ends';
const VERSION_ID = 2018092102;
const VERSION_ID = 2018100101;

protected $devHelperDirPath;

Expand Down
4 changes: 3 additions & 1 deletion PHPStan/Reflection/EntityRelationReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Type\ArrayType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\NullType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use PHPStan\Type\UnionType;
use XF\Mvc\Entity\Entity;

class EntityRelationReflection implements PropertyReflection
Expand Down Expand Up @@ -59,7 +61,7 @@ public function getType(): Type
$className = str_replace(':', '\Entity\\', $this->entity);

if ($this->type === Entity::TO_ONE) {
return new ObjectType($className);
return new UnionType([new NullType(), new ObjectType($className)]);
} else {
return new ArrayType(new IntegerType(), new ObjectType($className));
}
Expand Down

0 comments on commit 8df702e

Please sign in to comment.