Skip to content

(string)numeric === numeric-string ? #4005

@voku

Description

@voku

Bug report

Hi, our legacy project are using MySQL, and MySQL returns type "string" for nearly everything, our Request / Ajax classes also using type "string" very often because everything from _GET / _POST is a string or an array of strings. BUT our ActiveRows are using different type-hints, automatically generated from the database via PHP CS Fixer.

e.g.

  /**
     * @BaseValue
     *
     * <p>Type from DB: decimal(10,3)</p>
     *
     * @var string
     * @phpstan-var numeric
     */
    public $price = '0.000';

... so now I have many methods where "numeric" is the input and e.g. "numeric-string" is the output, but this didn't work as expected.

Code snippet that reproduces the problem

https://phpstan.org/r/298dc1e4-d105-4026-8866-4abf6c80419d

⇾ this is also the case for many functions e.g. "bc_math"-functions will also return numeric-string, or?

⇾ (string)numeric === numeric-string, or?: https://3v4l.org/a5Q0M

⇾ type "numeric" is not documented here, or?: https://phpstan.org/writing-php-code/phpdoc-types

Expected output

no error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions