diff --git a/src/Type/Doctrine/Descriptors/JsonType.php b/src/Type/Doctrine/Descriptors/JsonType.php index bc5c55f9..fcd15a1c 100644 --- a/src/Type/Doctrine/Descriptors/JsonType.php +++ b/src/Type/Doctrine/Descriptors/JsonType.php @@ -8,6 +8,7 @@ use PHPStan\Type\FloatType; use PHPStan\Type\IntegerType; use PHPStan\Type\MixedType; +use PHPStan\Type\NeverType; use PHPStan\Type\NullType; use PHPStan\Type\ObjectType; use PHPStan\Type\StringType; @@ -40,7 +41,7 @@ public function getType(): string public function getWritableToPropertyType(): Type { - return self::getJsonType(); + return new NeverType(); } public function getWritableToDatabaseType(): Type diff --git a/tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php b/tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php index 9b2a7484..27710827 100644 --- a/tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php +++ b/tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php @@ -126,10 +126,6 @@ public function testRule(): void 'Property PHPStan\Rules\Doctrine\ORM\MyBrokenEntity::$invalidCarbonImmutable type mapping mismatch: database can contain Carbon\CarbonImmutable but property expects Carbon\Carbon.', 138, ], - [ - '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.', - 156, - ], [ '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.', 156, @@ -137,6 +133,11 @@ public function testRule(): void ]); } + public function testRuleOnMyEntity(): void + { + $this->analyse([__DIR__ . '/data/MyEntity.php'], []); + } + public function testSuperclass(): void { $this->analyse([__DIR__ . '/data/MyBrokenSuperclass.php'], [