3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @author @ct-jensschulze <jens.schulze@commercetools.de> */ class PHPUnit_Framework_MockObject_Invocation_Object extends PHPUnit_Framework_MockObject_Invocation_Static { /** * @var object */ public $object; /** * @param string $className * @param string $methodname * @param array $parameters * @param object $object * @param object $cloneObjects */ public function __construct($className, $methodName, array $parameters, $object, $cloneObjects = false) { parent::__construct($className, $methodName, $parameters, $cloneObjects); $this->object = $object; } } class PHPUnit_Framework_MockObject_Invocation_Static { /** * @var array */ protected static $uncloneableExtensions = array( 'mysqli' => true, 'SQLite' => true, 'sqlite3' => true, 'tidy' => true, 'xmlwriter' => true, 'xsl' => true ); /** * @var array */ protected static $uncloneableClasses = array( 'Closure', 'COMPersistHelper', 'IteratorIterator', 'RecursiveIteratorIterator', 'SplFileObject', 'PDORow', 'ZipArchive' ); /** * @var string */ public $className; /** * @var string */ public $methodName; /** * @var array */ public $parameters; /** * @param string $className * @param string $methodname * @param array $parameters * @param boolean $cloneObjects */ public function __construct($className, $methodName, array $parameters, $cloneObjects = false) { $this->className = $className; $this->methodName = $methodName; $this->parameters = $parameters; if (!$cloneObjects) { return; } foreach ($this->parameters as $key => $value) { if (is_object($value)) { $this->parameters[$key] = $this->cloneObject($value); } } } /** * @param object $original * @return object */ protected function cloneObject($original) { return clone $original; } } interface MyInterface { public function doSomethingDifferent(); } abstract class MyClass implements MyInterface { public function doSomething() { return "doneSomething"; } abstract public function doSomethingElse(); } class MyClassTest { public function getMockForAbstractClass($className) { $mockClassName = 'Mock_' . $className; $class = <<<EOF class $mockClassName extends $className { private \$__phpunit_invocationMocker; private \$__phpunit_originalObject; public function __clone() { \$this->__phpunit_invocationMocker = clone \$this->__phpunit_getInvocationMocker(); } public function doSomethingElse() {} public function doSomethingDifferent() { \$arguments = array(); \$count = func_num_args(); if (\$count > 0) { \$_arguments = func_get_args(); for (\$i = 0; \$i < \$count; \$i++) { \$arguments[] = \$_arguments[\$i]; } } \$result = \$this->__phpunit_getInvocationMocker()->invoke( new PHPUnit_Framework_MockObject_Invocation_Object( 'MyInterface', 'httpRequest', \$arguments, \$this, FALSE ) ); return \$result; } } 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/q81Qg
function name:  (null)
number of ops:  8
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   DECLARE_CLASS                                            'phpunit_framework_mockobject_invocation_object', 'phpunit_framework_mockobject_invocation_static'
  106     1        DECLARE_CLASS                                            'myclass'
  166     2        NEW                                              $1      'MyClassTest'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
  167     5        INIT_METHOD_CALL                                         !0, 'testDoSomething'
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Class PHPUnit_Framework_MockObject_Invocation_Object:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q81Qg
function name:  __construct
number of ops:  14
compiled vars:  !0 = $className, !1 = $methodName, !2 = $parameters, !3 = $object, !4 = $cloneObjects
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV_INIT                                        !4      <false>
   22     5        INIT_STATIC_METHOD_CALL                                  
          6        SEND_VAR_EX                                              !0
          7        SEND_VAR_EX                                              !1
          8        SEND_VAR_EX                                              !2
          9        SEND_VAR_EX                                              !4
         10        DO_FCALL                                      0          
   23    11        ASSIGN_OBJ                                               'object'
         12        OP_DATA                                                  !3
   24    13      > RETURN                                                   null

End of function __construct

End of class PHPUnit_Framework_MockObject_Invocation_Object.

Class PHPUnit_Framework_MockObject_Invocation_Static:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 26
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 26
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 25
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 25
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/q81Qg
function name:  __construct
number of ops:  28
compiled vars:  !0 = $className, !1 = $methodName, !2 = $parameters, !3 = $cloneObjects, !4 = $value, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   75     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      <false>
   77     4        ASSIGN_OBJ                                               'className'
          5        OP_DATA                                                  !0
   78     6        ASSIGN_OBJ                                               'methodName'
          7        OP_DATA                                                  !1
   79     8        ASSIGN_OBJ                                               'parameters'
          9        OP_DATA                                                  !2
   81    10        BOOL_NOT                                         ~9      !3
         11      > JMPZ                                                     ~9, ->13
   82    12    > > RETURN                                                   null
   85    13    >   FETCH_OBJ_R                                      ~10     'parameters'
         14      > FE_RESET_R                                       $11     ~10, ->26
         15    > > FE_FETCH_R                                       ~12     $11, !4, ->26
         16    >   ASSIGN                                                   !5, ~12
   86    17        TYPE_CHECK                                  256          !4
         18      > JMPZ                                                     ~14, ->25
   87    19    >   INIT_METHOD_CALL                                         'cloneObject'
         20        SEND_VAR_EX                                              !4
         21        DO_FCALL                                      0  $17     
         22        FETCH_OBJ_W                                      $15     'parameters'
         23        ASSIGN_DIM                                               $15, !5
         24        OP_DATA                                                  $17
   85    25    > > JMP                                                      ->15
         26    >   FE_FREE                                                  $11
   90    27      > RETURN                                                   null

End of function __construct

Function cloneobject:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q81Qg
function name:  cloneObject
number of ops:  4
compiled vars:  !0 = $original
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   96     0  E >   RECV                                             !0      
   98     1        CLONE                                            ~1      !0
          2      > RETURN                                                   ~1
   99     3*     > RETURN                                                   null

End of function cloneobject

End of class PHPUnit_Framework_MockObject_Invocation_Static.

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

End of function dosomethingdifferent

End of class MyInterface.

Class MyClass:
Function dosomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q81Qg
function name:  doSomething
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  110     0  E > > RETURN                                                   'doneSomething'
  111     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/q81Qg
function name:  doSomethingElse
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  112     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/q81Qg
function name:  getMockForAbstractClass
number of ops:  15
compiled vars:  !0 = $className, !1 = $mockClassName, !2 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  118     0  E >   RECV                                             !0      
  120     1        CONCAT                                           ~3      'Mock_', !0
          2        ASSIGN                                                   !1, ~3
  122     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++++private+%24__phpunit_invocationMocker%3B%0A++++private+%24__phpunit_originalObject%3B%0A%0A++++public+function+__clone%28%29%0A++++%7B%0A++++++++%24this-%3E__phpunit_invocationMocker+%3D+clone+%24this-%3E__phpunit_getInvocationMocker%28%29%3B%0A++++%7D%0A%0A++public+function+doSomethingElse%28%29+%7B%7D%0A++public+function+doSomethingDifferent%28%29+%7B%0A++++++++%24arguments+%3D+array%28%29%3B%0A++++++++%24count+++++%3D+func_num_args%28%29%3B%0A%0A++++++++if+%28%24count+%3E+0%29+%7B%0A++++++++++++%24_arguments+%3D+func_get_args%28%29%3B%0A%0A++++++++++++for+%28%24i+%3D+0%3B+%24i+%3C+%24count%3B+%24i%2B%2B%29+%7B%0A++++++++++++++++%24arguments%5B%5D+%3D+%24_arguments%5B%24i%5D%3B%0A++++++++++++%7D%0A++++++++%7D%0A%0A++++++++%24result+%3D+%24this-%3E__phpunit_getInvocationMocker%28%29-%3Einvoke%28%0A++++++++++new+PHPUnit_Framework_MockObject_Invocation_Object%28%0A++++++++++++%27MyInterface%27%2C+%27httpRequest%27%2C+%24arguments%2C+%24this%2C+FALSE%0A++++++++++%29%0A++++++++%29%3B%0A%0A++++++++return+%24result%3B%0A++%7D%0A%7D'
  121     8        ASSIGN                                                   !2, ~5
  154     9        INCLUDE_OR_EVAL                                          !2, EVAL
  155    10        FETCH_CLASS                                   0  $11     !1
         11        NEW                                              $12     $11
         12        DO_FCALL                                      0          
         13      > RETURN                                                   $12
  156    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/q81Qg
function name:  testDoSomething
number of ops:  14
compiled vars:  !0 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  160     0  E >   INIT_METHOD_CALL                                         'getMockForAbstractClass'
          1        SEND_VAL_EX                                              'MyClass'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
  162     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                                                 
  163    13      > RETURN                                                   null

End of function testdosomething

End of class MyClassTest.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.06 ms | 1408 KiB | 15 Q