3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public static $has_many = "PostBlogAdmin"; public function has_many($a){ return 'hola'; } function get_relationship($model) { $class = new ReflectionClass($this); $staticProperties = $class->getStaticProperties(); foreach($staticProperties as $propertyName => $value) { if(preg_match('/^(has_many|age)$/', $propertyName) && $value == $model) { return $this->{$propertyName}($model); } } } function __get($name) { if(substr($name, -strlen('Set')) === 'Set') { echo $model = ucwords(substr($name, 0, -4)); return $this->get_relationship($model); } } } $foo = new Foo; echo $foo->PostBlogAdminSet; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ljjfC
function name:  (null)
number of ops:  6
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   41     3        FETCH_OBJ_R                                      ~4      !0, 'PostBlogAdminSet'
          4        ECHO                                                     ~4
   44     5      > 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/ljjfC
function name:  has_many
number of ops:  3
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1      > RETURN                                                   'hola'
    8     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 = 10, Position 2 = 26
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 26
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 19
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/ljjfC
function name:  get_relationship
number of ops:  28
compiled vars:  !0 = $model, !1 = $class, !2 = $staticProperties, !3 = $value, !4 = $propertyName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        NEW                                              $5      'ReflectionClass'
          2        FETCH_THIS                                       $6      
          3        SEND_VAR_EX                                              $6
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   14     6        INIT_METHOD_CALL                                         !1, 'getStaticProperties'
          7        DO_FCALL                                      0  $9      
          8        ASSIGN                                                   !2, $9
   16     9      > FE_RESET_R                                       $11     !2, ->26
         10    > > FE_FETCH_R                                       ~12     $11, !3, ->26
         11    >   ASSIGN                                                   !4, ~12
   17    12        INIT_FCALL                                               'preg_match'
         13        SEND_VAL                                                 '%2F%5E%28has_many%7Cage%29%24%2F'
         14        SEND_VAR                                                 !4
         15        DO_ICALL                                         $14     
         16      > JMPZ_EX                                          ~15     $14, ->19
         17    >   IS_EQUAL                                         ~16     !3, !0
         18        BOOL                                             ~15     ~16
         19    > > JMPZ                                                     ~15, ->25
   18    20    >   INIT_METHOD_CALL                                         !4
         21        SEND_VAR_EX                                              !0
         22        DO_FCALL                                      0  $17     
         23        FE_FREE                                                  $11
         24      > RETURN                                                   $17
   16    25    > > JMP                                                      ->10
         26    >   FE_FREE                                                  $11
   22    27      > RETURN                                                   null

End of function get_relationship

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 21
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ljjfC
function name:  __get
number of ops:  22
compiled vars:  !0 = $name, !1 = $model
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   26     1        INIT_FCALL                                               'substr'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 -3
          4        DO_ICALL                                         $2      
          5        IS_IDENTICAL                                             $2, 'Set'
          6      > JMPZ                                                     ~3, ->21
   27     7    >   INIT_FCALL                                               'ucwords'
          8        INIT_FCALL                                               'substr'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 0
         11        SEND_VAL                                                 -4
         12        DO_ICALL                                         $4      
         13        SEND_VAR                                                 $4
         14        DO_ICALL                                         $5      
         15        ASSIGN                                           ~6      !1, $5
         16        ECHO                                                     ~6
   28    17        INIT_METHOD_CALL                                         'get_relationship'
         18        SEND_VAR_EX                                              !1
         19        DO_FCALL                                      0  $7      
         20      > RETURN                                                   $7
   30    21    > > RETURN                                                   null

End of function __get

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
227.03 ms | 1400 KiB | 19 Q