3v4l.org

run code in 500+ PHP versions simultaneously
<?php class A { public string $a; public string $b; public function __construct( string $a, string $b, ){ $this->a = $a; $this->b = $b; } } $a = new A('b', 'a'); $b = new A('a', 'b'); var_dump($a <=> $b); // 1 var_dump($b <=> $a); // -1 class B { public string $b; // The property declarations are inverted public string $a; public function __construct( string $a, string $b, ){ $this->a = $a; $this->b = $b; } } $a = new B('b', 'a'); $b = new B('a', 'b'); var_dump($a <=> $b); // -1 var_dump($b <=> $a); // 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2nPL6
function name:  (null)
number of ops:  37
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   NEW                                                  $2      'A'
          1        SEND_VAL_EX                                                  'b'
          2        SEND_VAL_EX                                                  'a'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !0, $2
   16     5        NEW                                                  $5      'A'
          6        SEND_VAL_EX                                                  'a'
          7        SEND_VAL_EX                                                  'b'
          8        DO_FCALL                                          0          
          9        ASSIGN                                                       !1, $5
   18    10        INIT_FCALL                                                   'var_dump'
         11        SPACESHIP                                            ~8      !0, !1
         12        SEND_VAL                                                     ~8
         13        DO_ICALL                                                     
   19    14        INIT_FCALL                                                   'var_dump'
         15        SPACESHIP                                            ~10     !1, !0
         16        SEND_VAL                                                     ~10
         17        DO_ICALL                                                     
   33    18        NEW                                                  $12     'B'
         19        SEND_VAL_EX                                                  'b'
         20        SEND_VAL_EX                                                  'a'
         21        DO_FCALL                                          0          
         22        ASSIGN                                                       !0, $12
   34    23        NEW                                                  $15     'B'
         24        SEND_VAL_EX                                                  'a'
         25        SEND_VAL_EX                                                  'b'
         26        DO_FCALL                                          0          
         27        ASSIGN                                                       !1, $15
   36    28        INIT_FCALL                                                   'var_dump'
         29        SPACESHIP                                            ~18     !0, !1
         30        SEND_VAL                                                     ~18
         31        DO_ICALL                                                     
   37    32        INIT_FCALL                                                   'var_dump'
         33        SPACESHIP                                            ~20     !1, !0
         34        SEND_VAL                                                     ~20
         35        DO_ICALL                                                     
         36      > RETURN                                                       1

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

End of function __construct

End of class A.

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

End of function __construct

End of class B.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
171.56 ms | 3356 KiB | 14 Q