Skip to content

ctype_alnum should narrow given input at least as non-empty-string #13089

@herndlm

Description

@herndlm

Bug report

Calling ctype_alnum with an empty string "" returns always false, we can narrow the param type to at least non-empty-string then in a truthy-scope I'd say.

See https://www.php.net/manual/en/function.ctype-alnum.php

Also https://3v4l.org/oKuT9

Could be done potentially for other ctype_* functions as well most likely.

Code snippet that reproduces the problem

https://phpstan.org/r/4d5dc3e8-e17c-427b-9ff3-f796511d4670

Expected output

Dumped type: non-empty-string

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions