Skip to content

Problem with NumberType and integers #7383

Description

@whataboutpereira

Bug Report

Q A
Version 4.4.3

Summary

Incorporating BcMath\Number I ran into an unexpected (or not) issue. Since NumberType only accepts Number when converting to database value, one cannot use integers as query parameters.

Current behavior

$repository->count(['number' => 0]);

will yield:

Could not convert PHP value 0 to type Doctrine\DBAL\Types\NumberType. Expected one of the following types: null, BcMath\Number

Expected behavior

Expected $repository->count(['number' => 0]); to keep working when number is BcMath\Number especially because comparisons between integer and Number are supported in PHP.

How to reproduce

Have an entity with a BcMath\Number field:

#[ORM\Column(type: Types::NUMBER, precision: 5, scale: 2)]
private BcMath\Number $number;

Try to get a count of all zero values:

$repository->count(['number' => 0]);

Unfortunately phpstan-doctrine won't catch these either.

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