Skip to content

ctype_digit false positive after casted parameters #8736

@staabm

Description

@staabm
          With the code below, PHPStan says `Strict comparison using === between int<48, 57>|int<256, max>|numeric-string and 1 will always evaluate to false.`, but that is not true.

$mixed should be typed as int<0, max>|numeric-string, isn't it?

if (ctype_digit((string) $mixed)) {
	if ($mixed === 1) {
		echo '$mixed is 1';
	}
}

https://3v4l.org/AWVMB
https://phpstan.org/r/fff69d60-d579-44fa-bb1c-33f9eee4f2a9

Originally posted by @takaram in #8714 (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