3v4l.org

run code in 300+ PHP versions simultaneously
<?php //return $this->has_many('Post'); class Foo{ public static $has_manyhg = "Post"; public static $age = "18"; private static $city = "Boston"; public $r=9; public static $has_many = "Post"; public function has_many($a){ return 'hola'; } function get_relationship($val) { $class = new ReflectionClass('Foo'); $staticProperties = $class->getStaticProperties(); $object=new Foo; $model = ucwords(substr($val, 4)); foreach ($staticProperties as $propertyName => $value) { if(preg_match('/^(has_many|age)$/', $propertyName) && $value == $model) { return $object->{$propertyName}($model); } } } } $foo = new Foo; echo $foo->get_relationship('get_post'); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NLWBc
function name:  (null)
number of ops:  8
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   40     3        INIT_METHOD_CALL                                         !0, 'get_relationship'
          4        SEND_VAL_EX                                              'get_post'
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
   43     7      > RETURN                                                   1

Class Foo:
Function has_many:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NLWBc
function name:  has_many
number of ops:  3
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1      > RETURN                                                   'hola'
   14     2*     > RETURN                                                   null

End of function has_many

Function get_relationship:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 36
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 36
Branch analysis from position: 21
2 jumps found. (Code = 46) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 29
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/NLWBc
function name:  get_relationship
number of ops:  38
compiled vars:  !0 = $val, !1 = $class, !2 = $staticProperties, !3 = $object, !4 = $model, !5 = $value, !6 = $propertyName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        NEW                                              $7      'ReflectionClass'
          2        SEND_VAL_EX                                              'Foo'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $7
   20     5        INIT_METHOD_CALL                                         !1, 'getStaticProperties'
          6        DO_FCALL                                      0  $10     
          7        ASSIGN                                                   !2, $10
   22     8        NEW                                              $12     'Foo'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !3, $12
   23    11        INIT_FCALL                                               'ucwords'
         12        INIT_FCALL                                               'substr'
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 4
         15        DO_ICALL                                         $15     
         16        SEND_VAR                                                 $15
         17        DO_ICALL                                         $16     
         18        ASSIGN                                                   !4, $16
   25    19      > FE_RESET_R                                       $18     !2, ->36
         20    > > FE_FETCH_R                                       ~19     $18, !5, ->36
         21    >   ASSIGN                                                   !6, ~19
   26    22        INIT_FCALL                                               'preg_match'
         23        SEND_VAL                                                 '%2F%5E%28has_many%7Cage%29%24%2F'
         24        SEND_VAR                                                 !6
         25        DO_ICALL                                         $21     
         26      > JMPZ_EX                                          ~22     $21, ->29
         27    >   IS_EQUAL                                         ~23     !5, !4
         28        BOOL                                             ~22     ~23
         29    > > JMPZ                                                     ~22, ->35
   29    30    >   INIT_METHOD_CALL                                         !3, !6
         31        SEND_VAR_EX                                              !4
         32        DO_FCALL                                      0  $24     
         33        FE_FREE                                                  $18
         34      > RETURN                                                   $24
   25    35    > > JMP                                                      ->20
         36    >   FE_FREE                                                  $18
   33    37      > RETURN                                                   null

End of function get_relationship

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.26 ms | 1400 KiB | 19 Q