3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Person { protected const NAME = 'Serkan'; } class PhpSpec { public function __construct() { $name = 'NAME'; $func = function() use ($name) { return constant(get_class($this) . '::' . $name); }; $closure = $func->bindTo(new Person()); echo $closure(); } } $spe = new PhpSpec();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MPnfp
function name:  (null)
number of ops:  4
compiled vars:  !0 = $spe
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $1      'PhpSpec'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
          3      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FMPnfp%3A12%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MPnfp
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   BIND_STATIC                                              !0
   13     1        INIT_FCALL                                               'constant'
          2        FETCH_THIS                                       ~1      
          3        GET_CLASS                                        ~2      ~1
          4        CONCAT                                           ~3      ~2, '%3A%3A'
          5        CONCAT                                           ~4      ~3, !0
          6        SEND_VAL                                                 ~4
          7        DO_ICALL                                         $5      
          8      > RETURN                                                   $5
   14     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMPnfp%3A12%240

Class Person: [no user functions]
Class PhpSpec:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MPnfp
function name:  __construct
number of ops:  14
compiled vars:  !0 = $name, !1 = $func, !2 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, 'NAME'
   12     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMPnfp%3A12%240'
          2        BIND_LEXICAL                                             ~4, !0
          3        ASSIGN                                                   !1, ~4
   16     4        INIT_METHOD_CALL                                         !1, 'bindTo'
          5        NEW                                              $6      'Person'
          6        DO_FCALL                                      0          
          7        SEND_VAR_NO_REF_EX                                       $6
          8        DO_FCALL                                      0  $8      
          9        ASSIGN                                                   !2, $8
   18    10        INIT_DYNAMIC_CALL                                        !2
         11        DO_FCALL                                      0  $10     
         12        ECHO                                                     $10
   19    13      > RETURN                                                   null

End of function __construct

End of class PhpSpec.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
250.13 ms | 1396 KiB | 15 Q