Skip to content

uasort() with 'strnatcasecmp' acts weird #21568

@staabm

Description

@staabm

Description

we are in the process of covering the handling of uasort when using with strnatcasecmp and found a few things which we are not able to make sense of. I also looked thru the docs and did not find something which explained what we see.

the problem occur arround strict-types and Stringable vs. string territory.

especially interessting is that strnatcasecmp when invoked directly behaves differently in comparison while using strnatcasecmp as callback via uasort. results vary with strict-types 0/1.

see

so our questions mainly are

  • is all this expected behaviour?
  • can someone share some insights so we can properly reflect php-src runtime behaviour in PHPStan?

thank you

PHP Version

PHP 8.3.x

Operating System

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