3v4l.org

run code in 300+ PHP versions simultaneously
<?php class LazyValue { public function __construct( private Closure $lazy, ){} public function getValue() { static $value = ($this->lazy)(); return $value; } } $t1 = new LazyValue(function () { echo "slow\n"; return "42\n"; }); echo $t1->getValue(); echo $t1->getValue(); echo $t1->getValue();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dfn5j
function name:  (null)
number of ops:  15
compiled vars:  !0 = $t1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $1      'LazyValue'
          1        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   21     2        SEND_VAL_EX                                              ~2
   17     3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   24     5        INIT_METHOD_CALL                                         !0, 'getValue'
          6        DO_FCALL                                      0  $5      
          7        ECHO                                                     $5
   25     8        INIT_METHOD_CALL                                         !0, 'getValue'
          9        DO_FCALL                                      0  $6      
         10        ECHO                                                     $6
   26    11        INIT_METHOD_CALL                                         !0, 'getValue'
         12        DO_FCALL                                      0  $7      
         13        ECHO                                                     $7
         14      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dfn5j
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ECHO                                                     'slow%0A'
   20     1      > RETURN                                                   '42%0A'
   21     2*     > RETURN                                                   null

End of Dynamic Function 0

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

End of function __construct

Function getvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dfn5j
function name:  getValue
number of ops:  7
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ZEND_BIND_INIT_STATIC_OR_JMP                             !0
          1        FETCH_OBJ_R                                      ~1      'lazy'
          2        INIT_DYNAMIC_CALL                                        ~1
          3        DO_FCALL                                      0  $2      
          4        BIND_STATIC                                              !0, $2
   13     5      > RETURN                                                   !0
   14     6*     > RETURN                                                   null

End of function getvalue

End of class LazyValue.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.14 ms | 1424 KiB | 13 Q