3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $value = 'HI'; public function filter_callable(callable $p) { return $p($this); } public function filter_closure(\Closure $p) { return $p($this); } private function getValue() { return $this->value; } } $foo = new Foo(); echo $foo->filter_callable([$foo, 'getValue']); echo $foo->filter_closure(function($p) { return $p->getValue(); });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7TSf2
function name:  (null)
number of ops:  15
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   24     3        INIT_METHOD_CALL                                         !0, 'filter_callable'
          4        INIT_ARRAY                                       ~4      !0
          5        ADD_ARRAY_ELEMENT                                ~4      'getValue'
          6        SEND_VAL_EX                                              ~4
          7        DO_FCALL                                      0  $5      
          8        ECHO                                                     $5
   26     9        INIT_METHOD_CALL                                         !0, 'filter_closure'
         10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F7TSf2%3A26%240'
   28    11        SEND_VAL_EX                                              ~6
         12        DO_FCALL                                      0  $7      
         13        ECHO                                                     $7
         14      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F7TSf2%3A26%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7TSf2
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        INIT_METHOD_CALL                                         !0, 'getValue'
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
   28     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F7TSf2%3A26%240

Class Foo:
Function filter_callable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7TSf2
function name:  filter_callable
number of ops:  7
compiled vars:  !0 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        INIT_DYNAMIC_CALL                                        !0
          2        FETCH_THIS                                       $1      
          3        SEND_VAR_EX                                              $1
          4        DO_FCALL                                      0  $2      
          5      > RETURN                                                   $2
   10     6*     > RETURN                                                   null

End of function filter_callable

Function filter_closure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7TSf2
function name:  filter_closure
number of ops:  7
compiled vars:  !0 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        INIT_DYNAMIC_CALL                                        !0
          2        FETCH_THIS                                       $1      
          3        SEND_VAR_EX                                              $1
          4        DO_FCALL                                      0  $2      
          5      > RETURN                                                   $2
   15     6*     > RETURN                                                   null

End of function filter_closure

Function getvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7TSf2
function name:  getValue
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~0      'value'
          1      > RETURN                                                   ~0
   20     2*     > RETURN                                                   null

End of function getvalue

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.02 ms | 1399 KiB | 13 Q