3v4l.org

run code in 300+ 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'), ]; uasort($options, strnatcasecmp(...)); var_dump($options); var_dump(strnatcasecmp(Foo::fromString('c'), Foo::fromString('b')));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GPV8l
function name:  (null)
number of ops:  45
compiled vars:  !0 = $options
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'foo'
   22     1        INIT_STATIC_METHOD_CALL                                  'Foo', 'fromString'
          2        SEND_VAL_EX                                              'c'
          3        DO_FCALL                                      0  $1      
          4        INIT_ARRAY                                       ~2      $1
   23     5        INIT_STATIC_METHOD_CALL                                  'Foo', 'fromString'
          6        SEND_VAL_EX                                              'b'
          7        DO_FCALL                                      0  $3      
          8        ADD_ARRAY_ELEMENT                                ~2      $3
   24     9        INIT_STATIC_METHOD_CALL                                  'Foo', 'fromString'
         10        SEND_VAL_EX                                              'a'
         11        DO_FCALL                                      0  $4      
         12        ADD_ARRAY_ELEMENT                                ~2      $4
   25    13        INIT_STATIC_METHOD_CALL                                  'Foo', 'fromString'
         14        SEND_VAL_EX                                              'ccc'
         15        DO_FCALL                                      0  $5      
         16        ADD_ARRAY_ELEMENT                                ~2      $5
   26    17        INIT_STATIC_METHOD_CALL                                  'Foo', 'fromString'
         18        SEND_VAL_EX                                              'bcc'
         19        DO_FCALL                                      0  $6      
         20        ADD_ARRAY_ELEMENT                                ~2      $6
   21    21        ASSIGN                                                   !0, ~2
   30    22        INIT_FCALL                                               'uasort'
         23        SEND_REF                                                 !0
         24        INIT_FCALL                                               'strnatcasecmp'
         25        ZEND_CALLABLE_CONVERT                            ~8      
         26        SEND_VAL                                                 ~8
         27        DO_ICALL                                                 
   31    28        INIT_FCALL                                               'var_dump'
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                                 
   33    31        INIT_FCALL                                               'var_dump'
         32        INIT_FCALL                                               'strnatcasecmp'
         33        INIT_STATIC_METHOD_CALL                                  'Foo', 'fromString'
         34        SEND_VAL_EX                                              'c'
         35        DO_FCALL                                      0  $11     
         36        SEND_VAR                                                 $11
         37        INIT_STATIC_METHOD_CALL                                  'Foo', 'fromString'
         38        SEND_VAL_EX                                              'b'
         39        DO_FCALL                                      0  $12     
         40        SEND_VAR                                                 $12
         41        DO_ICALL                                         $13     
         42        SEND_VAR                                                 $13
         43        DO_ICALL                                                 
         44      > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GPV8l
function name:  __construct
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ                                               'value'
          2        OP_DATA                                                  !0
    6     3      > RETURN                                                   null

End of function __construct

Function fromstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GPV8l
function name:  fromString
number of ops:  8
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        NEW                          self                $1      
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        VERIFY_RETURN_TYPE                                       $1
          5      > RETURN                                                   $1
   10     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function fromstring

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GPV8l
function name:  __toString
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   FETCH_OBJ_R                                      ~0      'value'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   17     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function __tostring

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.17 ms | 1444 KiB | 16 Q