Skip to content

Commit

Permalink
Fix JsonType
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jul 4, 2021
1 parent 5532790 commit 062fc75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Type/Doctrine/Descriptors/JsonType.php
Expand Up @@ -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;
Expand Down Expand Up @@ -40,7 +41,7 @@ public function getType(): string

public function getWritableToPropertyType(): Type
{
return self::getJsonType();
return new NeverType();
}

public function getWritableToDatabaseType(): Type
Expand Down
9 changes: 5 additions & 4 deletions tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php
Expand Up @@ -126,17 +126,18 @@ 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,
],
]);
}

public function testRuleOnMyEntity(): void
{
$this->analyse([__DIR__ . '/data/MyEntity.php'], []);
}

public function testSuperclass(): void
{
$this->analyse([__DIR__ . '/data/MyBrokenSuperclass.php'], [
Expand Down

0 comments on commit 062fc75

Please sign in to comment.