3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private const string PREFIX = "Hello. "; private static string $prefix = "Hello, "; private static function prefix(): string { return "Hello, "; } public function greetFunc(string $to): string { return static::prefix() . $to . "!"; // passes, but insecure } public function greetVar(string $to): string { return statics::$prefix . $to . "!"; // passes, but insecure } public function greetConst(string $to): string { return static::PREFIX . $to . "!"; // crashes immediately } } class Bar extends Foo { } echo (new Bar())->greetFunc("World") . PHP_EOL; echo (new Bar())->greetVar("World") . PHP_EOL; // echo (new Bar())->greetConst("World") . PHP_EOL; // Error! Referencing undefined Bar::PREFIX... class Buz extends Foo { protected static string $prefix = "Hi, "; protected static function prefix(): string { return "Hi, "; } } echo (new Buz())->greetFunc("World") . PHP_EOL; // No! private function was actually overridden!! echo (new Buz())->greetVar("World") . PHP_EOL; // No! private property was actually overridden!!
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luae4
function name:  (null)
number of ops:  29
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   NEW                                              $0      'Bar'
          1        DO_FCALL                                      0          
          2        INIT_METHOD_CALL                                         $0, 'greetFunc'
          3        SEND_VAL_EX                                              'World'
          4        DO_FCALL                                      0  $2      
          5        CONCAT                                           ~3      $2, '%0A'
          6        ECHO                                                     ~3
   35     7        NEW                                              $4      'Bar'
          8        DO_FCALL                                      0          
          9        INIT_METHOD_CALL                                         $4, 'greetVar'
         10        SEND_VAL_EX                                              'World'
         11        DO_FCALL                                      0  $6      
         12        CONCAT                                           ~7      $6, '%0A'
         13        ECHO                                                     ~7
   49    14        NEW                                              $8      'Buz'
         15        DO_FCALL                                      0          
         16        INIT_METHOD_CALL                                         $8, 'greetFunc'
         17        SEND_VAL_EX                                              'World'
         18        DO_FCALL                                      0  $10     
         19        CONCAT                                           ~11     $10, '%0A'
         20        ECHO                                                     ~11
   50    21        NEW                                              $12     'Buz'
         22        DO_FCALL                                      0          
         23        INIT_METHOD_CALL                                         $12, 'greetVar'
         24        SEND_VAL_EX                                              'World'
         25        DO_FCALL                                      0  $14     
         26        CONCAT                                           ~15     $14, '%0A'
         27        ECHO                                                     ~15
         28      > RETURN                                                   1

Class Foo:
Function prefix:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luae4
function name:  prefix
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E > > RETURN                                                   'Hello%2C+'
   12     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function prefix

Function greetfunc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luae4
function name:  greetFunc
number of ops:  9
compiled vars:  !0 = $to
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        INIT_STATIC_METHOD_CALL                                  'prefix'
          2        DO_FCALL                                      0  $1      
          3        CONCAT                                           ~2      $1, !0
          4        CONCAT                                           ~3      ~2, '%21'
          5        VERIFY_RETURN_TYPE                                       ~3
          6      > RETURN                                                   ~3
   17     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function greetfunc

Function greetvar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luae4
function name:  greetVar
number of ops:  8
compiled vars:  !0 = $to
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        FETCH_STATIC_PROP_R          unknown             ~1      'prefix'
          2        CONCAT                                           ~2      ~1, !0
          3        CONCAT                                           ~3      ~2, '%21'
          4        VERIFY_RETURN_TYPE                                       ~3
          5      > RETURN                                                   ~3
   22     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function greetvar

Function greetconst:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luae4
function name:  greetConst
number of ops:  8
compiled vars:  !0 = $to
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   26     1        FETCH_CLASS_CONSTANT                             ~1      'PREFIX'
          2        CONCAT                                           ~2      ~1, !0
          3        CONCAT                                           ~3      ~2, '%21'
          4        VERIFY_RETURN_TYPE                                       ~3
          5      > RETURN                                                   ~3
   27     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function greetconst

End of class Foo.

Class Bar:
Function prefix:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luae4
function name:  prefix
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E > > RETURN                                                   'Hello%2C+'
   12     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function prefix

Function greetfunc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luae4
function name:  greetFunc
number of ops:  9
compiled vars:  !0 = $to
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        INIT_STATIC_METHOD_CALL                                  'prefix'
          2        DO_FCALL                                      0  $1      
          3        CONCAT                                           ~2      $1, !0
          4        CONCAT                                           ~3      ~2, '%21'
          5        VERIFY_RETURN_TYPE                                       ~3
          6      > RETURN                                                   ~3
   17     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function greetfunc

Function greetvar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luae4
function name:  greetVar
number of ops:  8
compiled vars:  !0 = $to
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        FETCH_STATIC_PROP_R          unknown             ~1      'prefix'
          2        CONCAT                                           ~2      ~1, !0
          3        CONCAT                                           ~3      ~2, '%21'
          4        VERIFY_RETURN_TYPE                                       ~3
          5      > RETURN                                                   ~3
   22     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function greetvar

Function greetconst:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luae4
function name:  greetConst
number of ops:  8
compiled vars:  !0 = $to
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   26     1        FETCH_CLASS_CONSTANT                             ~1      'PREFIX'
          2        CONCAT                                           ~2      ~1, !0
          3        CONCAT                                           ~3      ~2, '%21'
          4        VERIFY_RETURN_TYPE                                       ~3
          5      > RETURN                                                   ~3
   27     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function greetconst

End of class Bar.

Class Buz:
Function prefix:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luae4
function name:  prefix
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E > > RETURN                                                   'Hi%2C+'
   46     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function prefix

Function greetfunc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luae4
function name:  greetFunc
number of ops:  9
compiled vars:  !0 = $to
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        INIT_STATIC_METHOD_CALL                                  'prefix'
          2        DO_FCALL                                      0  $1      
          3        CONCAT                                           ~2      $1, !0
          4        CONCAT                                           ~3      ~2, '%21'
          5        VERIFY_RETURN_TYPE                                       ~3
          6      > RETURN                                                   ~3
   17     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function greetfunc

Function greetvar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luae4
function name:  greetVar
number of ops:  8
compiled vars:  !0 = $to
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        FETCH_STATIC_PROP_R          unknown             ~1      'prefix'
          2        CONCAT                                           ~2      ~1, !0
          3        CONCAT                                           ~3      ~2, '%21'
          4        VERIFY_RETURN_TYPE                                       ~3
          5      > RETURN                                                   ~3
   22     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function greetvar

Function greetconst:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luae4
function name:  greetConst
number of ops:  8
compiled vars:  !0 = $to
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   26     1        FETCH_CLASS_CONSTANT                             ~1      'PREFIX'
          2        CONCAT                                           ~2      ~1, !0
          3        CONCAT                                           ~3      ~2, '%21'
          4        VERIFY_RETURN_TYPE                                       ~3
          5      > RETURN                                                   ~3
   27     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function greetconst

End of class Buz.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.74 ms | 1026 KiB | 13 Q