3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { static function bar() { $foo = static function() { return get_called_class(); }; return $foo(); } static function baz() { $foo = function() { return get_called_class(); }; return $foo(); } static function rebind() { $foo = function() { return get_called_class(); }; $oFoo=new Foo; return $foo->bindTo(null,Foo); } } class Bar extends Foo { } //print Bar::bar() . Bar::baz() . print Bar::rebind(); assert(Bar::bar() === 'Bar'); assert(Bar::baz() === 'Bar');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eTdAG
function name:  (null)
number of ops:  23
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  28     1        NOP                                                      
         2        NOP                                                      
  33     3        INIT_STATIC_METHOD_CALL                                  'Bar', 'rebind'
         4        DO_FCALL                                      0  $3      
         5        ECHO                                                     $3
  35     6        ASSERT_CHECK                                             
         7        INIT_FCALL                                               'assert'
         8        INIT_STATIC_METHOD_CALL                                  'Bar', 'bar'
         9        DO_FCALL                                      0  $4      
        10        IS_IDENTICAL                                     ~5      $4, 'Bar'
        11        SEND_VAL                                                 ~5
        12        SEND_VAL                                                 'assert%28Bar%3A%3Abar%28%29+%3D%3D%3D+%27Bar%27%29'
        13        DO_ICALL                                                 
  36    14        ASSERT_CHECK                                             
        15        INIT_FCALL                                               'assert'
        16        INIT_STATIC_METHOD_CALL                                  'Bar', 'baz'
        17        DO_FCALL                                      0  $7      
        18        IS_IDENTICAL                                     ~8      $7, 'Bar'
        19        SEND_VAL                                                 ~8
        20        SEND_VAL                                                 'assert%28Bar%3A%3Abaz%28%29+%3D%3D%3D+%27Bar%27%29'
        21        DO_ICALL                                                 
        22      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FeTdAG0x7f7df979607e

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

End of function %00%7Bclosure%7D%2Fin%2FeTdAG0x7f7df9796103

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

End of function %00%7Bclosure%7D%2Fin%2FeTdAG0x7f7df979618b

Class Foo:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eTdAG
function name:  bar
number of ops:  6
compiled vars:  !0 = $foo
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   5     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FeTdAG0x7f7df979607e'
   7     1        ASSIGN                                                   !0, ~1
   9     2        INIT_DYNAMIC_CALL                                        !0
         3        DO_FCALL                                      0  $3      
         4      > RETURN                                                   $3
  10     5*     > RETURN                                                   null

End of function bar

Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eTdAG
function name:  baz
number of ops:  6
compiled vars:  !0 = $foo
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  12     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FeTdAG0x7f7df9796103'
  14     1        ASSIGN                                                   !0, ~1
  16     2        INIT_DYNAMIC_CALL                                        !0
         3        DO_FCALL                                      0  $3      
         4      > RETURN                                                   $3
  17     5*     > RETURN                                                   null

End of function baz

Function rebind:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eTdAG
function name:  rebind
number of ops:  12
compiled vars:  !0 = $foo, !1 = $oFoo
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  19     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FeTdAG0x7f7df979618b'
  21     1        ASSIGN                                                   !0, ~2
  22     2        NEW                                              $4      :-4
         3        DO_FCALL                                      0          
         4        ASSIGN                                                   !1, $4
  24     5        INIT_METHOD_CALL                                         !0, 'bindTo'
         6        SEND_VAL_EX                                              null
         7        FETCH_CONSTANT                                   ~7      'Foo'
         8        SEND_VAL_EX                                              ~7
         9        DO_FCALL                                      0  $8      
        10      > RETURN                                                   $8
  25    11*     > RETURN                                                   null

End of function rebind

End of class Foo.

Class Bar:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eTdAG
function name:  bar
number of ops:  6
compiled vars:  !0 = $foo
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   5     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FeTdAG0x7f7df979607e'
   7     1        ASSIGN                                                   !0, ~1
   9     2        INIT_DYNAMIC_CALL                                        !0
         3        DO_FCALL                                      0  $3      
         4      > RETURN                                                   $3
  10     5*     > RETURN                                                   null

End of function bar

Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eTdAG
function name:  baz
number of ops:  6
compiled vars:  !0 = $foo
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  12     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FeTdAG0x7f7df9796103'
  14     1        ASSIGN                                                   !0, ~1
  16     2        INIT_DYNAMIC_CALL                                        !0
         3        DO_FCALL                                      0  $3      
         4      > RETURN                                                   $3
  17     5*     > RETURN                                                   null

End of function baz

Function rebind:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eTdAG
function name:  rebind
number of ops:  12
compiled vars:  !0 = $foo, !1 = $oFoo
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  19     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FeTdAG0x7f7df979618b'
  21     1        ASSIGN                                                   !0, ~2
  22     2        NEW                                              $4      :-4
         3        DO_FCALL                                      0          
         4        ASSIGN                                                   !1, $4
  24     5        INIT_METHOD_CALL                                         !0, 'bindTo'
         6        SEND_VAL_EX                                              null
         7        FETCH_CONSTANT                                   ~7      'Foo'
         8        SEND_VAL_EX                                              ~7
         9        DO_FCALL                                      0  $8      
        10      > RETURN                                                   $8
  25    11*     > RETURN                                                   null

End of function rebind

End of class Bar.

Generated using Vulcan Logic Dumper, using php 7.3.0