3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Expression { protected function escapeStringLiteral(string $value): string { return 'never called'; } } trait ExpressionTrait { protected function escapeStringLiteral(string $value): string { return '\'' . str_replace('\'', '\'\'', $value) . '\''; } } class MyExpression extends Expression { use ExpressionTrait; } class TestExpression extends Expression { private Expression $dummyExpression; public function __construct(Expression $dummyExpression) { $this->dummyExpression = $dummyExpression; } #[\Override] protected function escapeStringLiteral(string $value): string { return $this->dummyExpression->escapeStringLiteral($value); } public function test(): void { var_dump($this->escapeStringLiteral('foo \' bar')); } }; class TestCl { public function test(): void { $exprNoRender = new TestExpression(new MyExpression()); $exprNoRender->test(); } } (new TestCl())->test();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KI9eF
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   DECLARE_CLASS                                            'myexpression', 'expression'
   55     1        NEW                                              $0      'TestCl'
          2        DO_FCALL                                      0          
          3        INIT_METHOD_CALL                                         $0, 'test'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Class Expression:
Function escapestringliteral:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KI9eF
function name:  escapeStringLiteral
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1      > RETURN                                                   'never+called'
    8     2*       VERIFY_RETURN_TYPE                                       
          3*     > RETURN                                                   null

End of function escapestringliteral

End of class Expression.

Class ExpressionTrait:
Function escapestringliteral:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KI9eF
function name:  escapeStringLiteral
number of ops:  12
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 '%27'
          3        SEND_VAL                                                 '%27%27'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6        CONCAT                                           ~2      '%27', $1
          7        CONCAT                                           ~3      ~2, '%27'
          8        VERIFY_RETURN_TYPE                                       ~3
          9      > RETURN                                                   ~3
   16    10*       VERIFY_RETURN_TYPE                                       
         11*     > RETURN                                                   null

End of function escapestringliteral

End of class ExpressionTrait.

Class MyExpression: [no user functions]
Class TestExpression:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KI9eF
function name:  __construct
number of ops:  4
compiled vars:  !0 = $dummyExpression
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   30     1        ASSIGN_OBJ                                               'dummyExpression'
          2        OP_DATA                                                  !0
   31     3      > RETURN                                                   null

End of function __construct

Function escapestringliteral:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KI9eF
function name:  escapeStringLiteral
number of ops:  9
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   36     1        FETCH_OBJ_R                                      ~1      'dummyExpression'
          2        INIT_METHOD_CALL                                         ~1, 'escapeStringLiteral'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $2      
          5        VERIFY_RETURN_TYPE                                       $2
          6      > RETURN                                                   $2
   37     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function escapestringliteral

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KI9eF
function name:  test
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_METHOD_CALL                                         'escapeStringLiteral'
          2        SEND_VAL_EX                                              'foo+%27+bar'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   42     6      > RETURN                                                   null

End of function test

End of class TestExpression.

Class TestCl:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KI9eF
function name:  test
number of ops:  9
compiled vars:  !0 = $exprNoRender
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   NEW                                              $1      'TestExpression'
          1        NEW                                              $2      'MyExpression'
          2        DO_FCALL                                      0          
          3        SEND_VAR_NO_REF_EX                                       $2
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   51     6        INIT_METHOD_CALL                                         !0, 'test'
          7        DO_FCALL                                      0          
   52     8      > RETURN                                                   null

End of function test

End of class TestCl.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.99 ms | 1016 KiB | 15 Q