Skip to content

Commit 062fc75

Browse files
committed
Fix JsonType
1 parent 5532790 commit 062fc75

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/Type/Doctrine/Descriptors/JsonType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PHPStan\Type\FloatType;
99
use PHPStan\Type\IntegerType;
1010
use PHPStan\Type\MixedType;
11+
use PHPStan\Type\NeverType;
1112
use PHPStan\Type\NullType;
1213
use PHPStan\Type\ObjectType;
1314
use PHPStan\Type\StringType;
@@ -40,7 +41,7 @@ public function getType(): string
4041

4142
public function getWritableToPropertyType(): Type
4243
{
43-
return self::getJsonType();
44+
return new NeverType();
4445
}
4546

4647
public function getWritableToDatabaseType(): Type

tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,18 @@ public function testRule(): void
126126
'Property PHPStan\Rules\Doctrine\ORM\MyBrokenEntity::$invalidCarbonImmutable type mapping mismatch: database can contain Carbon\CarbonImmutable but property expects Carbon\Carbon.',
127127
138,
128128
],
129-
[
130-
'Property PHPStan\Rules\Doctrine\ORM\MyBrokenEntity::$incompatibleJsonValueObject type mapping mismatch: database can contain array|bool|float|int|JsonSerializable|stdClass|string|null but property expects PHPStan\Rules\Doctrine\ORM\EmptyObject.',
131-
156,
132-
],
133129
[
134130
'Property PHPStan\Rules\Doctrine\ORM\MyBrokenEntity::$incompatibleJsonValueObject type mapping mismatch: property can contain PHPStan\Rules\Doctrine\ORM\EmptyObject but database expects array|bool|float|int|JsonSerializable|stdClass|string|null.',
135131
156,
136132
],
137133
]);
138134
}
139135

136+
public function testRuleOnMyEntity(): void
137+
{
138+
$this->analyse([__DIR__ . '/data/MyEntity.php'], []);
139+
}
140+
140141
public function testSuperclass(): void
141142
{
142143
$this->analyse([__DIR__ . '/data/MyBrokenSuperclass.php'], [

0 commit comments

Comments
 (0)