Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions extension.neon
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ services:
-
class: PHPStan\Type\Doctrine\Descriptors\JsonType
tags: [phpstan.doctrine.typeDescriptor]
-
class: PHPStan\Type\Doctrine\Descriptors\NumberType
tags: [phpstan.doctrine.typeDescriptor]
-
class: PHPStan\Type\Doctrine\Descriptors\ObjectType
tags: [phpstan.doctrine.typeDescriptor]
Expand Down
12 changes: 12 additions & 0 deletions phpstan-baseline-dbal-4.neon
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ parameters:
count: 1
path: src/Type/Doctrine/Query/QueryResultTypeWalker.php

-
message: '#^Class Doctrine\\DBAL\\Types\\NumberType not found\.$#'
identifier: class.notFound
count: 1
path: src/Type/Doctrine/Descriptors/NumberType.php

-
message: '#^Method PHPStan\\Type\\Doctrine\\Descriptors\\NumberType\:\:getType\(\) should return class\-string\<Doctrine\\DBAL\\Types\\Type\> but returns string\.$#'
identifier: return.type
count: 1
path: src/Type/Doctrine/Descriptors/NumberType.php

-
rawMessage: '''
Call to method __construct() of deprecated class Doctrine\ORM\Mapping\Driver\AnnotationDriver:
Expand Down
31 changes: 31 additions & 0 deletions src/Type/Doctrine/Descriptors/NumberType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types = 1);

namespace PHPStan\Type\Doctrine\Descriptors;

use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;

class NumberType implements DoctrineTypeDescriptor
{

public function getType(): string
{
return \Doctrine\DBAL\Types\NumberType::class;
}

public function getWritableToPropertyType(): Type
{
return new ObjectType('BcMath\Number');
}

public function getWritableToDatabaseType(): Type
{
return new ObjectType('BcMath\Number');
}

public function getDatabaseInternalType(): Type
{
return (new ObjectType('BcMath\Number'))->toString();
}

}
2 changes: 2 additions & 0 deletions tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use PHPStan\Type\Doctrine\Descriptors\EnumType;
use PHPStan\Type\Doctrine\Descriptors\IntegerType;
use PHPStan\Type\Doctrine\Descriptors\JsonType;
use PHPStan\Type\Doctrine\Descriptors\NumberType;
use PHPStan\Type\Doctrine\Descriptors\Ramsey\UuidTypeDescriptor as RamseyUuidTypeDescriptor;
use PHPStan\Type\Doctrine\Descriptors\ReflectionDescriptor;
use PHPStan\Type\Doctrine\Descriptors\SimpleArrayType;
Expand Down Expand Up @@ -95,6 +96,7 @@ protected function getRule(): Rule
new DecimalType(new DriverDetector()),
new JsonType(),
new IntegerType(),
new NumberType(),
new StringType(),
new SimpleArrayType(),
new EnumType(),
Expand Down
Loading