Skip to content

Testing Whether Key is Suitable for non-decimal-int-string #14749

@oleibman

Description

@oleibman

Bug report

Just experimenting with your new safe array key 'prevent' option. I have a string that I wish to use as a key, but not if it's unsuitable for non-decimal-int-string. So I do a is_numeric check. If that's false, I think that ought to be sufficient to indicate that it's okay to use as a non-decimal-int-string. Perhaps I'm overlooking something; Phpstan certainly disagrees with me.

Code snippet that reproduces the problem

https://phpstan.org/r/d1a622e1-b1ba-4ae9-8d65-673e0697b001

Expected output

I think Phpstan should not issue an error message for line 27, but it does. If Phpstan is operating correctly, is there some other test I can/should make?

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

Always happy with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions