3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); final class Foo implements \Stringable { private function __construct(public readonly string $value) { } public static function fromString(string $string): self { return new self($string); } /** * {@inheritdoc} */ public function __toString(): string { return $this->value; } } $options = [ Foo::fromString('c'), Foo::fromString('b'), Foo::fromString('a'), Foo::fromString('ccc'), Foo::fromString('bcc'), ]; function foo(string $a, string $b): int { return 1; } uasort($options, 'foo'); var_export($options);
Output for 8.3.5 - 8.3.30, 8.4.9
array ( 4 => \Foo::__set_state(array( 'value' => 'bcc', )), 3 => \Foo::__set_state(array( 'value' => 'ccc', )), 1 => \Foo::__set_state(array( 'value' => 'b', )), 2 => \Foo::__set_state(array( 'value' => 'a', )), 0 => \Foo::__set_state(array( 'value' => 'c', )), )

preferences:
49.42 ms | 515 KiB | 4 Q