3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TestSampleClass { } /** * @category Zend * @package Zend_Reflection */ class ParameterReflection extends ReflectionParameter { /** * @var bool */ protected $isFromMethod = false; /** * Get declaring class reflection object * * @return ClassReflection */ public function getDeclaringClass() { $phpReflection = parent::getDeclaringClass(); $zendReflection = new ReflectionClass($phpReflection->getName()); unset($phpReflection); return $zendReflection; } /** * Get class reflection object * * @return ClassReflection */ public function getClass() { $phpReflection = parent::getClass(); if ($phpReflection == null) { return null; } $zendReflection = new ClassReflection($phpReflection->getName()); unset($phpReflection); return $zendReflection; } /** * Get declaring function reflection object * * @param string $reflectionClass Reflection class to use * @return FunctionReflection|MethodReflection */ public function getDeclaringFunction($reflectionClass = null) { $phpReflection = parent::getDeclaringFunction(); if ($phpReflection instanceof ReflectionMethod) { $zendReflection = new ReflectionMethod($this->getDeclaringClass()->getName(), $phpReflection->getName()); } else { $zendReflection = new ReflectionFunction($phpReflection->getName()); } unset($phpReflection); return $zendReflection; } /** * Get parameter type * * @return string */ public function getType() { $type = null; $checkDefault = true; if ($this->isArray()) { $type = 'array'; } elseif (($class = $this->getClass()) instanceof ReflectionClass) { $type = $class->getName(); } elseif ($docBlock = $this->getDeclaringFunction()->getDocBlock()) { $params = $docBlock->getTags('param'); if (isset($params[$this->getPosition()])) { $type = $params[$this->getPosition()]->getType(); $checkDefault = false; } } if ($this->isDefaultValueAvailable() && $checkDefault) { if ($type === null) { $value = $this->getDefaultValue(); $type = strtolower(gettype($value)); switch ($type) { case 'boolean' : $type = 'bool'; break; case 'integer' : $type = 'int'; break; } } else { if ($this->getDefaultValue() === null) { $type .= '|null'; } } } return $type; } public function toString() { return parent::__toString(); } public function __toString() { return parent::__toString(); } } /** * TestSampleClass5 DocBlock Short Desc * * This is a long description for * the docblock of this class, it * should be longer than 3 lines. * It indeed is longer than 3 lines * now. * * @author Ralph Schindler <ralph.schindler@zend.com> * @method test() * @property $test */ class TestSampleClass5 { /** * Method ShortDescription * * Method LongDescription * This is a long description for * the docblock of this class, it * should be longer than 3 lines. * It indeed is longer than 3 lines * now. * * @param int $one Description for one * @param int Description for two * @param string $three Description for three * which spans multiple lines * @return mixed Some return descr */ public function doSomething($one, $two = 2, $three = 'three', $empty, $string = 'somestring', $null = null, $int = 1, $bool = true, array $array, array $arrayOrNull = null, TestSampleClass $class, TestSampleClass $classOrNull = null) { return 'mixedValue'; } /** * Method ShortDescription * * @param int $one Description for one * @param int Description for two * @param string $three Description for three * which spans multiple lines * @return int */ public function doSomethingElse($one, $two = 2, $three = 'three') { return 'mixedValue'; } } $tests = array( array('one', 'int'), array('two', 'int'), array('three', 'string'), array('empty', null), array('string', 'string'), array('null', 'null'), array('int', 'int'), array('bool', 'bool'), array('array', 'array'), array('arrayOrNull','array|null'), array('class', 'ZendTest\Code\Reflection\TestAsset\TestSampleClass'), array('classOrNull','ZendTest\Code\Reflection\TestAsset\TestSampleClass|null'), ); foreach($tests as $test) { $param = new ParameterReflection(array('TestSampleClass5', 'doSomething'), $test[0]); var_dump($param->getType()); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 17
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/ODoYi
function name:  (null)
number of ops:  19
compiled vars:  !0 = $tests, !1 = $test, !2 = $param
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   DECLARE_CLASS                                            'parameterreflection', 'reflectionparameter'
  173     1        ASSIGN                                                   !0, <array>
  188     2      > FE_RESET_R                                       $4      !0, ->17
          3    > > FE_FETCH_R                                               $4, !1, ->17
  190     4    >   NEW                                              $5      'ParameterReflection'
          5        SEND_VAL_EX                                              <array>
          6        CHECK_FUNC_ARG                                           
          7        FETCH_DIM_FUNC_ARG                               $6      !1, 0
          8        SEND_FUNC_ARG                                            $6
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $5
  192    11        INIT_FCALL                                               'var_dump'
         12        INIT_METHOD_CALL                                         !2, 'getType'
         13        DO_FCALL                                      0  $9      
         14        SEND_VAR                                                 $9
         15        DO_ICALL                                                 
  188    16      > JMP                                                      ->3
         17    >   FE_FREE                                                  $4
  193    18      > RETURN                                                   1

Class TestSampleClass: [no user functions]
Class ParameterReflection:
Function getdeclaringclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ODoYi
function name:  getDeclaringClass
number of ops:  12
compiled vars:  !0 = $phpReflection, !1 = $zendReflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_STATIC_METHOD_CALL                                  'getDeclaringClass'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   25     3        NEW                                              $4      'ReflectionClass'
          4        INIT_METHOD_CALL                                         !0, 'getName'
          5        DO_FCALL                                      0  $5      
          6        SEND_VAR_NO_REF_EX                                       $5
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $4
   26     9        UNSET_CV                                                 !0
   28    10      > RETURN                                                   !1
   29    11*     > RETURN                                                   null

End of function getdeclaringclass

Function getclass:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ODoYi
function name:  getClass
number of ops:  15
compiled vars:  !0 = $phpReflection, !1 = $zendReflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   INIT_STATIC_METHOD_CALL                                  'getClass'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   39     3        IS_EQUAL                                                 !0, null
          4      > JMPZ                                                     ~4, ->6
   40     5    > > RETURN                                                   null
   42     6    >   NEW                                              $5      'ClassReflection'
          7        INIT_METHOD_CALL                                         !0, 'getName'
          8        DO_FCALL                                      0  $6      
          9        SEND_VAR_NO_REF_EX                                       $6
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !1, $5
   43    12        UNSET_CV                                                 !0
   45    13      > RETURN                                                   !1
   46    14*     > RETURN                                                   null

End of function getclass

Function getdeclaringfunction:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 18
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ODoYi
function name:  getDeclaringFunction
number of ops:  27
compiled vars:  !0 = $reflectionClass, !1 = $phpReflection, !2 = $zendReflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV_INIT                                        !0      null
   56     1        INIT_STATIC_METHOD_CALL                                  'getDeclaringFunction'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !1, $3
   57     4        INSTANCEOF                                               !1, 'ReflectionMethod'
          5      > JMPZ                                                     ~5, ->18
   58     6    >   NEW                                              $6      'ReflectionMethod'
          7        INIT_METHOD_CALL                                         'getDeclaringClass'
          8        DO_FCALL                                      0  $7      
          9        INIT_METHOD_CALL                                         $7, 'getName'
         10        DO_FCALL                                      0  $8      
         11        SEND_VAR_NO_REF_EX                                       $8
         12        INIT_METHOD_CALL                                         !1, 'getName'
         13        DO_FCALL                                      0  $9      
         14        SEND_VAR_NO_REF_EX                                       $9
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !2, $6
         17      > JMP                                                      ->24
   60    18    >   NEW                                              $12     'ReflectionFunction'
         19        INIT_METHOD_CALL                                         !1, 'getName'
         20        DO_FCALL                                      0  $13     
         21        SEND_VAR_NO_REF_EX                                       $13
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !2, $12
   62    24    >   UNSET_CV                                                 !1
   64    25      > RETURN                                                   !2
   65    26*     > RETURN                                                   null

End of function getdeclaringfunction

Function gettype:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 46) Position 1 = 40, Position 2 = 41
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 68
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 63
Branch analysis from position: 44
4 jumps found. (Code = 188) Position 1 = 58, Position 2 = 60, Position 3 = 62, Position 4 = 53
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
Branch analysis from position: 62
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 55, Position 2 = 58
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 60
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
Branch analysis from position: 60
Branch analysis from position: 58
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 68
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 68
Branch analysis from position: 68
Branch analysis from position: 41
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 37
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 37
Branch analysis from position: 30
2 jumps found. (Code = 46) Position 1 = 40, Position 2 = 41
Branch analysis from position: 40
Branch analysis from position: 41
Branch analysis from position: 37
Branch analysis from position: 37
filename:       /in/ODoYi
function name:  getType
number of ops:  70
compiled vars:  !0 = $type, !1 = $checkDefault, !2 = $class, !3 = $docBlock, !4 = $params, !5 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   74     0  E >   ASSIGN                                                   !0, null
   76     1        ASSIGN                                                   !1, <true>
   78     2        INIT_METHOD_CALL                                         'isArray'
          3        DO_FCALL                                      0  $8      
          4      > JMPZ                                                     $8, ->7
   79     5    >   ASSIGN                                                   !0, 'array'
          6      > JMP                                                      ->37
   80     7    >   INIT_METHOD_CALL                                         'getClass'
          8        DO_FCALL                                      0  $10     
          9        ASSIGN                                           ~11     !2, $10
         10        INSTANCEOF                                               ~11, 'ReflectionClass'
         11      > JMPZ                                                     ~12, ->16
   81    12    >   INIT_METHOD_CALL                                         !2, 'getName'
         13        DO_FCALL                                      0  $13     
         14        ASSIGN                                                   !0, $13
         15      > JMP                                                      ->37
   82    16    >   INIT_METHOD_CALL                                         'getDeclaringFunction'
         17        DO_FCALL                                      0  $15     
         18        INIT_METHOD_CALL                                         $15, 'getDocBlock'
         19        DO_FCALL                                      0  $16     
         20        ASSIGN                                           ~17     !3, $16
         21      > JMPZ                                                     ~17, ->37
   83    22    >   INIT_METHOD_CALL                                         !3, 'getTags'
         23        SEND_VAL_EX                                              'param'
         24        DO_FCALL                                      0  $18     
         25        ASSIGN                                                   !4, $18
   85    26        INIT_METHOD_CALL                                         'getPosition'
         27        DO_FCALL                                      0  $20     
         28        ISSET_ISEMPTY_DIM_OBJ                         0          !4, $20
         29      > JMPZ                                                     ~21, ->37
   86    30    >   INIT_METHOD_CALL                                         'getPosition'
         31        DO_FCALL                                      0  $22     
         32        FETCH_DIM_R                                      ~23     !4, $22
         33        INIT_METHOD_CALL                                         ~23, 'getType'
         34        DO_FCALL                                      0  $24     
         35        ASSIGN                                                   !0, $24
   87    36        ASSIGN                                                   !1, <false>
   91    37    >   INIT_METHOD_CALL                                         'isDefaultValueAvailable'
         38        DO_FCALL                                      0  $27     
         39      > JMPZ_EX                                          ~28     $27, ->41
         40    >   BOOL                                             ~28     !1
         41    > > JMPZ                                                     ~28, ->68
   92    42    >   TYPE_CHECK                                    2          !0
         43      > JMPZ                                                     ~29, ->63
   93    44    >   INIT_METHOD_CALL                                         'getDefaultValue'
         45        DO_FCALL                                      0  $30     
         46        ASSIGN                                                   !5, $30
   94    47        INIT_FCALL                                               'strtolower'
         48        GET_TYPE                                         ~32     !5
         49        SEND_VAL                                                 ~32
         50        DO_ICALL                                         $33     
         51        ASSIGN                                                   !0, $33
   96    52      > SWITCH_STRING                                            !0, [ 'boolean':->58, 'integer':->60, ], ->62
   97    53    >   IS_EQUAL                                                 !0, 'boolean'
         54      > JMPNZ                                                    ~35, ->58
   98    55    >   IS_EQUAL                                                 !0, 'integer'
         56      > JMPNZ                                                    ~35, ->60
         57    > > JMP                                                      ->62
   97    58    >   ASSIGN                                                   !0, 'bool'
         59      > JMP                                                      ->62
   98    60    >   ASSIGN                                                   !0, 'int'
         61      > JMP                                                      ->62
         62    > > JMP                                                      ->68
  101    63    >   INIT_METHOD_CALL                                         'getDefaultValue'
         64        DO_FCALL                                      0  $38     
         65        TYPE_CHECK                                    2          $38
         66      > JMPZ                                                     ~39, ->68
  102    67    >   ASSIGN_OP                                     8          !0, '%7Cnull'
  107    68    > > RETURN                                                   !0
  108    69*     > RETURN                                                   null

End of function gettype

Function tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ODoYi
function name:  toString
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  112     0  E >   INIT_STATIC_METHOD_CALL                                  '__toString'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
  113     3*     > RETURN                                                   null

End of function tostring

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ODoYi
function name:  __toString
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  117     0  E >   INIT_STATIC_METHOD_CALL                                  '__toString'
          1        DO_FCALL                                      0  $0      
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
  118     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function __tostring

End of class ParameterReflection.

Class TestSampleClass5:
Function dosomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ODoYi
function name:  doSomething
number of ops:  14
compiled vars:  !0 = $one, !1 = $two, !2 = $three, !3 = $empty, !4 = $string, !5 = $null, !6 = $int, !7 = $bool, !8 = $array, !9 = $arrayOrNull, !10 = $class, !11 = $classOrNull
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  153     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      2
          2        RECV_INIT                                        !2      'three'
          3        RECV                                             !3      
          4        RECV_INIT                                        !4      'somestring'
          5        RECV_INIT                                        !5      null
          6        RECV_INIT                                        !6      1
          7        RECV_INIT                                        !7      <true>
          8        RECV                                             !8      
          9        RECV_INIT                                        !9      null
         10        RECV                                             !10     
         11        RECV_INIT                                        !11     null
  155    12      > RETURN                                                   'mixedValue'
  156    13*     > 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/ODoYi
function name:  doSomethingElse
number of ops:  5
compiled vars:  !0 = $one, !1 = $two, !2 = $three
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  167     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      2
          2        RECV_INIT                                        !2      'three'
  169     3      > RETURN                                                   'mixedValue'
  170     4*     > RETURN                                                   null

End of function dosomethingelse

End of class TestSampleClass5.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.68 ms | 1416 KiB | 17 Q