3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait ClosureInATrait { public static function getClosureInTrait() { return function () { return __CLASS__; }; } } class ClassConstantTest { use ClosureInATrait; public static function getClosureInClass() { return function () { return __CLASS__; }; } } $closureInClass = ClassConstantTest::getClosureInClass(); $closureInTrait = ClassConstantTest::getClosureInTrait(); var_dump($closureInClass(), $closureInTrait()); $closureInClass = Closure::bind($closureInClass, new stdClass()); $closureInTrait = Closure::bind($closureInTrait, new stdClass()); var_dump($closureInClass(), $closureInTrait());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2HGM9
function name:  (null)
number of ops:  38
compiled vars:  !0 = $closureInClass, !1 = $closureInTrait
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   DECLARE_CLASS                                            'classconstanttest'
   25     1        INIT_STATIC_METHOD_CALL                                  'ClassConstantTest', 'getClosureInClass'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
   26     4        INIT_STATIC_METHOD_CALL                                  'ClassConstantTest', 'getClosureInTrait'
          5        DO_FCALL                                      0  $4      
          6        ASSIGN                                                   !1, $4
   28     7        INIT_FCALL                                               'var_dump'
          8        INIT_DYNAMIC_CALL                                        !0
          9        DO_FCALL                                      0  $6      
         10        SEND_VAR                                                 $6
         11        INIT_DYNAMIC_CALL                                        !1
         12        DO_FCALL                                      0  $7      
         13        SEND_VAR                                                 $7
         14        DO_ICALL                                                 
   30    15        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         16        SEND_VAR                                                 !0
         17        NEW                                              $9      'stdClass'
         18        DO_FCALL                                      0          
         19        SEND_VAR                                                 $9
         20        DO_FCALL                                      0  $11     
         21        ASSIGN                                                   !0, $11
   31    22        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         23        SEND_VAR                                                 !1
         24        NEW                                              $13     'stdClass'
         25        DO_FCALL                                      0          
         26        SEND_VAR                                                 $13
         27        DO_FCALL                                      0  $15     
         28        ASSIGN                                                   !1, $15
   33    29        INIT_FCALL                                               'var_dump'
         30        INIT_DYNAMIC_CALL                                        !0
         31        DO_FCALL                                      0  $17     
         32        SEND_VAR                                                 $17
         33        INIT_DYNAMIC_CALL                                        !1
         34        DO_FCALL                                      0  $18     
         35        SEND_VAR                                                 $18
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F2HGM9%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2HGM9
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_CLASS_NAME                                 ~0      
          1      > RETURN                                                   ~0
    9     2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F2HGM9%3A7%240

Function %00%7Bclosure%7D%2Fin%2F2HGM9%3A19%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2HGM9
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E > > RETURN                                                   'ClassConstantTest'
   21     1*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F2HGM9%3A19%241

Class ClosureInATrait:
Function getclosureintrait:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2HGM9
function name:  getClosureInTrait
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F2HGM9%3A7%240'
    9     1      > RETURN                                                   ~0
   10     2*     > RETURN                                                   null

End of function getclosureintrait

End of class ClosureInATrait.

Class ClassConstantTest:
Function getclosureinclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2HGM9
function name:  getClosureInClass
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F2HGM9%3A19%241'
   21     1      > RETURN                                                   ~0
   22     2*     > RETURN                                                   null

End of function getclosureinclass

End of class ClassConstantTest.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.47 ms | 1400 KiB | 15 Q