3v4l.org

run code in 500+ PHP versions simultaneously
<?php class XABC { function foo() { // static does not apply to self $f = static function () : self { // __CLASS__ is preserved in the closure echo __CLASS__.PHP_EOL; return new self(); }; return $f; } } var_dump((new xabc)->foo()());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PAjY6
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                                   'var_dump'
          1        NEW                                                  $0      'xabc'
          2        DO_FCALL                                          0          
          3        INIT_METHOD_CALL                                             $0, 'foo'
          4        DO_FCALL                                          0  $2      
          5        INIT_DYNAMIC_CALL                                            $2
          6        DO_FCALL                                          0  $3      
          7        SEND_VAR                                                     $3
          8        DO_ICALL                                                     
          9      > RETURN                                                       1

Class XABC:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PAjY6
function name:  foo
number of ops:  4
compiled vars:  !0 = $f
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   DECLARE_LAMBDA_FUNCTION                              ~1      [0]
          1        ASSIGN                                                       !0, ~1
   12     2      > RETURN                                                       !0
   13     3*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PAjY6
function name:  {closure:XABC::foo():6}
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   ECHO                                                         'XABC%0A'
    9     1        NEW                              self                $0      
          2        DO_FCALL                                          0          
          3        VERIFY_RETURN_TYPE                                           $0
          4      > RETURN                                                       $0
   10     5*       VERIFY_RETURN_TYPE                                           
          6*     > RETURN                                                       null

End of Dynamic Function 0

End of function foo

End of class XABC.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.68 ms | 1468 KiB | 14 Q