3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TestSampleClass { } class MethodReflection extends ReflectionMethod { protected $annotations = null; public function getDocBlock() { if ('' == $this->getDocComment()) { return false; } $instance = new DocBlockReflection($this); return $instance; } public function getAnnotations(AnnotationManager $annotationManager) { if (($docComment = $this->getDocComment()) == '') { return false; } if (!$this->annotations) { $cachingFileScanner = new CachingFileScanner($this->getFileName()); $nameInformation = $cachingFileScanner->getClassNameInformation($this->getDeclaringClass()->getName()); $this->annotations = new AnnotationScanner($annotationManager, $docComment, $nameInformation); } return $this->annotations; } public function getDeclaringClass() { $phpReflection = parent::getDeclaringClass(); $zendReflection = new ClassReflection($phpReflection->getName()); unset($phpReflection); return $zendReflection; } public function getParameters() { $phpReflections = parent::getParameters(); $zendReflections = array(); while ($phpReflections && ($phpReflection = array_shift($phpReflections))) { $instance = new ParameterReflection(array($this->getDeclaringClass()->getName(), $this->getName()), $phpReflection->getName()); $zendReflections[] = $instance; unset($phpReflection); } unset($phpReflections); return $zendReflections; } } class ParameterReflection extends ReflectionParameter { protected $isFromMethod = false; public function getDeclaringClass() { $phpReflection = parent::getDeclaringClass(); $zendReflection = new ReflectionClass($phpReflection->getName()); unset($phpReflection); return $zendReflection; } public function getClass() { $phpReflection = parent::getClass(); if ($phpReflection == null) { return null; } $zendReflection = new ClassReflection($phpReflection->getName()); unset($phpReflection); return $zendReflection; } public function getDeclaringFunction($reflectionClass = null) { $phpReflection = parent::getDeclaringFunction(); if ($phpReflection instanceof ReflectionMethod) { $zendReflection = new MethodReflection($this->getDeclaringClass()->getName(), $phpReflection->getName()); } else { $zendReflection = new ReflectionFunction($phpReflection->getName()); } unset($phpReflection); return $zendReflection; } 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; } } class TestSampleClass5 { /** * @param int $one Description for one * @param int Description for two * @param string $three Description for three * which spans multiple lines */ 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'; } } $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 = 2, Position 2 = 16
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/7IqFt
function name:  (null)
number of ops:  18
compiled vars:  !0 = $tests, !1 = $test, !2 = $param
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  141     0  E >   ASSIGN                                                   !0, <array>
  156     1      > FE_RESET_R                                       $4      !0, ->16
          2    > > FE_FETCH_R                                               $4, !1, ->16
  158     3    >   NEW                                              $5      'ParameterReflection'
          4        SEND_VAL_EX                                              <array>
          5        CHECK_FUNC_ARG                                           
          6        FETCH_DIM_FUNC_ARG                               $6      !1, 0
          7        SEND_FUNC_ARG                                            $6
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !2, $5
  160    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !2, 'getType'
         12        DO_FCALL                                      0  $9      
         13        SEND_VAR                                                 $9
         14        DO_ICALL                                                 
  156    15      > JMP                                                      ->2
         16    >   FE_FREE                                                  $4
  161    17      > RETURN                                                   1

Class TestSampleClass: [no user functions]
Class MethodReflection:
Function getdocblock:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7IqFt
function name:  getDocBlock
number of ops:  12
compiled vars:  !0 = $instance
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_METHOD_CALL                                         'getDocComment'
          1        DO_FCALL                                      0  $1      
          2        IS_EQUAL                                                 $1, ''
          3      > JMPZ                                                     ~2, ->5
   12     4    > > RETURN                                                   <false>
   15     5    >   NEW                                              $3      'DocBlockReflection'
          6        FETCH_THIS                                       $4      
          7        SEND_VAR_EX                                              $4
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !0, $3
   16    10      > RETURN                                                   !0
   17    11*     > RETURN                                                   null

End of function getdocblock

Function getannotations:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 31
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/7IqFt
function name:  getAnnotations
number of ops:  34
compiled vars:  !0 = $annotationManager, !1 = $docComment, !2 = $cachingFileScanner, !3 = $nameInformation
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        INIT_METHOD_CALL                                         'getDocComment'
          2        DO_FCALL                                      0  $4      
          3        ASSIGN                                           ~5      !1, $4
          4        IS_EQUAL                                                 ~5, ''
          5      > JMPZ                                                     ~6, ->7
   21     6    > > RETURN                                                   <false>
   24     7    >   FETCH_OBJ_R                                      ~7      'annotations'
          8        BOOL_NOT                                         ~8      ~7
          9      > JMPZ                                                     ~8, ->31
   25    10    >   NEW                                              $9      'CachingFileScanner'
         11        INIT_METHOD_CALL                                         'getFileName'
         12        DO_FCALL                                      0  $10     
         13        SEND_VAR_NO_REF_EX                                       $10
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !2, $9
   26    16        INIT_METHOD_CALL                                         !2, 'getClassNameInformation'
         17        INIT_METHOD_CALL                                         'getDeclaringClass'
         18        DO_FCALL                                      0  $13     
         19        INIT_METHOD_CALL                                         $13, 'getName'
         20        DO_FCALL                                      0  $14     
         21        SEND_VAR_NO_REF_EX                                       $14
         22        DO_FCALL                                      0  $15     
         23        ASSIGN                                                   !3, $15
   28    24        NEW                                              $18     'AnnotationScanner'
         25        SEND_VAR_EX                                              !0
         26        SEND_VAR_EX                                              !1
         27        SEND_VAR_EX                                              !3
         28        DO_FCALL                                      0          
         29        ASSIGN_OBJ                                               'annotations'
         30        OP_DATA                                                  $18
   31    31    >   FETCH_OBJ_R                                      ~20     'annotations'
         32      > RETURN                                                   ~20
   32    33*     > RETURN                                                   null

End of function getannotations

Function getdeclaringclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7IqFt
function name:  getDeclaringClass
number of ops:  12
compiled vars:  !0 = $phpReflection, !1 = $zendReflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   INIT_STATIC_METHOD_CALL                                  'getDeclaringClass'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   36     3        NEW                                              $4      'ClassReflection'
          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
   37     9        UNSET_CV                                                 !0
   38    10      > RETURN                                                   !1
   39    11*     > RETURN                                                   null

End of function getdeclaringclass

Function getparameters:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 5
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
Branch analysis from position: 29
Branch analysis from position: 29
filename:       /in/7IqFt
function name:  getParameters
number of ops:  33
compiled vars:  !0 = $phpReflections, !1 = $zendReflections, !2 = $instance, !3 = $phpReflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   INIT_STATIC_METHOD_CALL                                  'getParameters'
          1        DO_FCALL                                      0  $4      
          2        ASSIGN                                                   !0, $4
   43     3        ASSIGN                                                   !1, <array>
   44     4      > JMP                                                      ->23
   45     5    >   NEW                                              $7      'ParameterReflection'
          6        INIT_METHOD_CALL                                         'getDeclaringClass'
          7        DO_FCALL                                      0  $8      
          8        INIT_METHOD_CALL                                         $8, 'getName'
          9        DO_FCALL                                      0  $9      
         10        INIT_ARRAY                                       ~10     $9
   46    11        INIT_METHOD_CALL                                         'getName'
         12        DO_FCALL                                      0  $11     
         13        ADD_ARRAY_ELEMENT                                ~10     $11
         14        SEND_VAL_EX                                              ~10
         15        INIT_METHOD_CALL                                         !3, 'getName'
         16        DO_FCALL                                      0  $12     
         17        SEND_VAR_NO_REF_EX                                       $12
         18        DO_FCALL                                      0          
   45    19        ASSIGN                                                   !2, $7
   47    20        ASSIGN_DIM                                               !1
         21        OP_DATA                                                  !2
   48    22        UNSET_CV                                                 !3
   44    23    > > JMPZ_EX                                          ~16     !0, ->29
         24    >   INIT_FCALL                                               'array_shift'
         25        SEND_REF                                                 !0
         26        DO_ICALL                                         $17     
         27        ASSIGN                                           ~18     !3, $17
         28        BOOL                                             ~16     ~18
         29    > > JMPNZ                                                    ~16, ->5
   50    30    >   UNSET_CV                                                 !0
   51    31      > RETURN                                                   !1
   52    32*     > RETURN                                                   null

End of function getparameters

End of class MethodReflection.

Class ParameterReflection:
Function getdeclaringclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7IqFt
function name:  getDeclaringClass
number of ops:  12
compiled vars:  !0 = $phpReflection, !1 = $zendReflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   INIT_STATIC_METHOD_CALL                                  'getDeclaringClass'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   61     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
   62     9        UNSET_CV                                                 !0
   64    10      > RETURN                                                   !1
   65    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/7IqFt
function name:  getClass
number of ops:  15
compiled vars:  !0 = $phpReflection, !1 = $zendReflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   68     0  E >   INIT_STATIC_METHOD_CALL                                  'getClass'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   69     3        IS_EQUAL                                                 !0, null
          4      > JMPZ                                                     ~4, ->6
   70     5    > > RETURN                                                   null
   72     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
   73    12        UNSET_CV                                                 !0
   75    13      > RETURN                                                   !1
   76    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/7IqFt
function name:  getDeclaringFunction
number of ops:  27
compiled vars:  !0 = $reflectionClass, !1 = $phpReflection, !2 = $zendReflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   77     0  E >   RECV_INIT                                        !0      null
   79     1        INIT_STATIC_METHOD_CALL                                  'getDeclaringFunction'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !1, $3
   80     4        INSTANCEOF                                               !1, 'ReflectionMethod'
          5      > JMPZ                                                     ~5, ->18
   81     6    >   NEW                                              $6      'MethodReflection'
          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
   83    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
   85    24    >   UNSET_CV                                                 !1
   87    25      > RETURN                                                   !2
   88    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 = 15
Branch analysis from position: 15
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 19
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 46
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 41
Branch analysis from position: 22
4 jumps found. (Code = 188) Position 1 = 36, Position 2 = 38, Position 3 = 40, Position 4 = 31
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 40
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 36
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 38
Branch analysis from position: 36
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 46
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
Branch analysis from position: 46
Branch analysis from position: 19
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 19
Branch analysis from position: 18
Branch analysis from position: 19
Branch analysis from position: 15
filename:       /in/7IqFt
function name:  getType
number of ops:  48
compiled vars:  !0 = $type, !1 = $checkDefault, !2 = $class, !3 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   91     0  E >   ASSIGN                                                   !0, null
   93     1        ASSIGN                                                   !1, <true>
   95     2        INIT_METHOD_CALL                                         'isArray'
          3        DO_FCALL                                      0  $6      
          4      > JMPZ                                                     $6, ->7
   96     5    >   ASSIGN                                                   !0, 'array'
          6      > JMP                                                      ->15
   97     7    >   INIT_METHOD_CALL                                         'getClass'
          8        DO_FCALL                                      0  $8      
          9        ASSIGN                                           ~9      !2, $8
         10        INSTANCEOF                                               ~9, 'ReflectionClass'
         11      > JMPZ                                                     ~10, ->15
   98    12    >   INIT_METHOD_CALL                                         !2, 'getName'
         13        DO_FCALL                                      0  $11     
         14        ASSIGN                                                   !0, $11
  108    15    >   INIT_METHOD_CALL                                         'isDefaultValueAvailable'
         16        DO_FCALL                                      0  $13     
         17      > JMPZ_EX                                          ~14     $13, ->19
         18    >   BOOL                                             ~14     !1
         19    > > JMPZ                                                     ~14, ->46
  109    20    >   TYPE_CHECK                                    2          !0
         21      > JMPZ                                                     ~15, ->41
  110    22    >   INIT_METHOD_CALL                                         'getDefaultValue'
         23        DO_FCALL                                      0  $16     
         24        ASSIGN                                                   !3, $16
  111    25        INIT_FCALL                                               'strtolower'
         26        GET_TYPE                                         ~18     !3
         27        SEND_VAL                                                 ~18
         28        DO_ICALL                                         $19     
         29        ASSIGN                                                   !0, $19
  113    30      > SWITCH_STRING                                            !0, [ 'boolean':->36, 'integer':->38, ], ->40
  114    31    >   IS_EQUAL                                                 !0, 'boolean'
         32      > JMPNZ                                                    ~21, ->36
  115    33    >   IS_EQUAL                                                 !0, 'integer'
         34      > JMPNZ                                                    ~21, ->38
         35    > > JMP                                                      ->40
  114    36    >   ASSIGN                                                   !0, 'bool'
         37      > JMP                                                      ->40
  115    38    >   ASSIGN                                                   !0, 'int'
         39      > JMP                                                      ->40
         40    > > JMP                                                      ->46
  118    41    >   INIT_METHOD_CALL                                         'getDefaultValue'
         42        DO_FCALL                                      0  $24     
         43        TYPE_CHECK                                    2          $24
         44      > JMPZ                                                     ~25, ->46
  119    45    >   ASSIGN_OP                                     8          !0, '%7Cnull'
  124    46    > > RETURN                                                   !0
  125    47*     > RETURN                                                   null

End of function gettype

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/7IqFt
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
-------------------------------------------------------------------------------------
  135     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
  137    12      > RETURN                                                   'mixedValue'
  138    13*     > RETURN                                                   null

End of function dosomething

End of class TestSampleClass5.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.58 ms | 1412 KiB | 19 Q