3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Obj { private $_name; public function getName() { if ($this->_name === null) { // Heavy DB query $this->_name = 'Foo'; } return $this->_name; } } $objects = array(new Obj(), new Obj()); usort($objects, function($a, $b) { if ($a->getName() < $b->getName()) { return 1; } else if ($a->getName() > $b->getName()) { return -1; } return 0; }); var_dump($objects);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iPMuR
function name:  (null)
number of ops:  16
compiled vars:  !0 = $objects
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   NEW                                              $1      'Obj'
          1        DO_FCALL                                      0          
          2        INIT_ARRAY                                       ~3      $1
          3        NEW                                              $4      'Obj'
          4        DO_FCALL                                      0          
          5        ADD_ARRAY_ELEMENT                                ~3      $4
          6        ASSIGN                                                   !0, ~3
   18     7        INIT_FCALL                                               'usort'
          8        SEND_REF                                                 !0
          9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FiPMuR%3A18%240'
   26    10        SEND_VAL                                                 ~7
         11        DO_ICALL                                                 
   28    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FiPMuR%3A18%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iPMuR
function name:  {closure}
number of ops:  19
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        INIT_METHOD_CALL                                         !0, 'getName'
          3        DO_FCALL                                      0  $2      
          4        INIT_METHOD_CALL                                         !1, 'getName'
          5        DO_FCALL                                      0  $3      
          6        IS_SMALLER                                               $2, $3
          7      > JMPZ                                                     ~4, ->10
   20     8    > > RETURN                                                   1
          9*       JMP                                                      ->17
   21    10    >   INIT_METHOD_CALL                                         !0, 'getName'
         11        DO_FCALL                                      0  $5      
         12        INIT_METHOD_CALL                                         !1, 'getName'
         13        DO_FCALL                                      0  $6      
         14        IS_SMALLER                                               $6, $5
         15      > JMPZ                                                     ~7, ->17
   22    16    > > RETURN                                                   -1
   25    17    > > RETURN                                                   0
   26    18*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FiPMuR%3A18%240

Class Obj:
Function getname:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/iPMuR
function name:  getName
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   FETCH_OBJ_R                                      ~0      '_name'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->5
    9     3    >   ASSIGN_OBJ                                               '_name'
          4        OP_DATA                                                  'Foo'
   12     5    >   FETCH_OBJ_R                                      ~3      '_name'
          6      > RETURN                                                   ~3
   13     7*     > RETURN                                                   null

End of function getname

End of class Obj.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.1 ms | 1400 KiB | 17 Q