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_manyc($a){ return 'hola'; } } function get_relationship($val) { $class = new ReflectionClass('Foo'); $staticProperties = $class->getStaticProperties(); //print_r($staticProperties); $object=new Foo; $model = ucwords(substr($val, 4)); foreach ($staticProperties as $propertyName => $value) { if(preg_match('/^(has_many|age)$/', $propertyName) && $value == $model) { //return call_user_func(array($object, $propertyName.'c'), $model); return $object->{$propertyName.'c'}($model); } } } echo get_relationship('get_post'); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IaUau
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   INIT_FCALL                                               'get_relationship'
          1        SEND_VAL                                                 'get_post'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   38     4      > RETURN                                                   1

Function get_relationship:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 37
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 37
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 = 36
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 29
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/IaUau
function name:  get_relationship
number of ops:  39
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, ->37
         20    > > FE_FETCH_R                                       ~19     $18, !5, ->37
         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, ->36
   29    30    >   CONCAT                                           ~24     !6, 'c'
         31        INIT_METHOD_CALL                                         !3, ~24
         32        SEND_VAR_EX                                              !4
         33        DO_FCALL                                      0  $25     
         34        FE_FREE                                                  $18
         35      > RETURN                                                   $25
   25    36    > > JMP                                                      ->20
         37    >   FE_FREE                                                  $18
   33    38      > RETURN                                                   null

End of function get_relationship

Class Foo:
Function has_manyc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IaUau
function name:  has_manyc
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_manyc

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.88 ms | 1403 KiB | 20 Q