Skip to content

Invalid nullable property check for simple_array mapping type #670

Description

@v-noskov

Doctrine DBAL always converts the database value to a PHP array, even when the field contains null. SimpleArrayType mapper converts the null value from DB to an empty PHP array.
However, when I put a not-nullable type hint for the simple_array mapping from the nullable DB field:

/**
 * @var list<string>
 * @ORM\Column(type="simple_array", nullable=true)
 */
private $simpleArrayFromNullableField;

PHPStan check produces an error:
Property PHPStan\Rules\Doctrine\ORM\MyEntity::$simpleArrayFromNullableField type mapping mismatch: database can contain list<string>|null but property expects list<string>.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions