3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Spaceship { public $name; public $maxSpeed; public function __construct($name, $maxSpeed) { $this->name = $name; $this->maxSpeed = $maxSpeed; } } $spaceships = [ new Spaceship('Rebel Transport', 20), new Spaceship('Millenium Falcon', 80), new Spaceship('X-Wing Starfighter', 80), new Spaceship('TIE Bomber', 60), new Spaceship('TIE Fighter', 100), new Spaceship('Imperial Star Destroyer', 60), ]; // Sort the spaceships by name (in ascending order) usort($spaceships, function ($ship1, $ship2) { return $ship1->name <=> $ship2->name; });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eBY1C
function name:  (null)
number of ops:  37
compiled vars:  !0 = $spaceships
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   NEW                                              $1      'Spaceship'
          1        SEND_VAL_EX                                              'Rebel+Transport'
          2        SEND_VAL_EX                                              20
          3        DO_FCALL                                      0          
          4        INIT_ARRAY                                       ~3      $1
   14     5        NEW                                              $4      'Spaceship'
          6        SEND_VAL_EX                                              'Millenium+Falcon'
          7        SEND_VAL_EX                                              80
          8        DO_FCALL                                      0          
          9        ADD_ARRAY_ELEMENT                                ~3      $4
   15    10        NEW                                              $6      'Spaceship'
         11        SEND_VAL_EX                                              'X-Wing+Starfighter'
         12        SEND_VAL_EX                                              80
         13        DO_FCALL                                      0          
         14        ADD_ARRAY_ELEMENT                                ~3      $6
   16    15        NEW                                              $8      'Spaceship'
         16        SEND_VAL_EX                                              'TIE+Bomber'
         17        SEND_VAL_EX                                              60
         18        DO_FCALL                                      0          
         19        ADD_ARRAY_ELEMENT                                ~3      $8
   17    20        NEW                                              $10     'Spaceship'
         21        SEND_VAL_EX                                              'TIE+Fighter'
         22        SEND_VAL_EX                                              100
         23        DO_FCALL                                      0          
         24        ADD_ARRAY_ELEMENT                                ~3      $10
   18    25        NEW                                              $12     'Spaceship'
         26        SEND_VAL_EX                                              'Imperial+Star+Destroyer'
         27        SEND_VAL_EX                                              60
         28        DO_FCALL                                      0          
         29        ADD_ARRAY_ELEMENT                                ~3      $12
   12    30        ASSIGN                                                   !0, ~3
   22    31        INIT_FCALL                                               'usort'
         32        SEND_REF                                                 !0
         33        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FeBY1C%3A22%240'
   24    34        SEND_VAL                                                 ~15
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FeBY1C%3A22%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eBY1C
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $ship1, !1 = $ship2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   23     2        FETCH_OBJ_R                                      ~2      !0, 'name'
          3        FETCH_OBJ_R                                      ~3      !1, 'name'
          4        SPACESHIP                                        ~4      ~2, ~3
          5      > RETURN                                                   ~4
   24     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FeBY1C%3A22%240

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

End of function __construct

End of class Spaceship.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.52 ms | 1400 KiB | 15 Q