3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class MyClass { public function doSomething() { return "doneSomething"; } abstract public function doSomethingElse(); } class MyClassTest { public function getMockForAbstractClass($className) { $mockClassName = 'Mock_' . $className; $class = <<<EOF class $mockClassName extends $className { public function doSomethingElse() {} } EOF; eval($class); return new $mockClassName(); } public function testDoSomething() { $object = $this->getMockForAbstractClass('MyClass'); assert('"doneSomething" == "' . $object->doSomething() . '"'); } } $test = new MyClassTest(); $test->testDoSomething();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cU1HR
function name:  (null)
number of ops:  6
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   NEW                                              $1      'MyClassTest'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   36     3        INIT_METHOD_CALL                                         !0, 'testDoSomething'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Class MyClass:
Function dosomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cU1HR
function name:  doSomething
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E > > RETURN                                                   'doneSomething'
    8     1*     > RETURN                                                   null

End of function dosomething

Function dosomethingelse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cU1HR
function name:  doSomethingElse
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E > > RETURN                                                   null

End of function dosomethingelse

End of class MyClass.

Class MyClassTest:
Function getmockforabstractclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cU1HR
function name:  getMockForAbstractClass
number of ops:  15
compiled vars:  !0 = $className, !1 = $mockClassName, !2 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        CONCAT                                           ~3      'Mock_', !0
          2        ASSIGN                                                   !1, ~3
   19     3        ROPE_INIT                                     5  ~6      'class+'
          4        ROPE_ADD                                      1  ~6      ~6, !1
          5        ROPE_ADD                                      2  ~6      ~6, '+extends+'
          6        ROPE_ADD                                      3  ~6      ~6, !0
          7        ROPE_END                                      4  ~5      ~6, '+%7B%0A++public+function+doSomethingElse%28%29+%7B%7D%0A%7D'
   18     8        ASSIGN                                                   !2, ~5
   23     9        INCLUDE_OR_EVAL                                          !2, EVAL
   24    10        FETCH_CLASS                                   0  $11     !1
         11        NEW                                              $12     $11
         12        DO_FCALL                                      0          
         13      > RETURN                                                   $12
   25    14*     > RETURN                                                   null

End of function getmockforabstractclass

Function testdosomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cU1HR
function name:  testDoSomething
number of ops:  14
compiled vars:  !0 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_METHOD_CALL                                         'getMockForAbstractClass'
          1        SEND_VAL_EX                                              'MyClass'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   31     4        ASSERT_CHECK                                             
          5        INIT_FCALL                                               'assert'
          6        INIT_METHOD_CALL                                         !0, 'doSomething'
          7        DO_FCALL                                      0  $3      
          8        CONCAT                                           ~4      '%22doneSomething%22+%3D%3D+%22', $3
          9        CONCAT                                           ~5      ~4, '%22'
         10        SEND_VAL                                                 ~5
         11        SEND_VAL                                                 'assert%28%27%22doneSomething%22+%3D%3D+%22%27+.+%24object-%3EdoSomething%28%29+.+%27%22%27%29'
         12        DO_ICALL                                                 
   32    13      > RETURN                                                   null

End of function testdosomething

End of class MyClassTest.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.66 ms | 1400 KiB | 15 Q