3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Maniple_Model { /** * @param array $data OPTIONAL * @return void */ public function __construct(array $data = null) // {{{ { if ($data) { $this->setFromArray($data); } } // }}} /** * @param array $data * @return Maniple_Model */ public function setFromArray(array $data) // {{{ { foreach ($data as $key => $value) { $this->__set($key, $value, false); } return $this; } // }}} /** * @param string $key * @param mixed $value * @param bool $throw OPTIONAL * @return Maniple_Model * @throws InvalidArgumentException */ protected function _setProperty($key, $value, $throw = true) // {{{ { $key = self::toCamelCase($key); $setter = 'set' . $key; if (method_exists($this, $setter)) { $this->{$setter}($value); return $this; } $property = '_' . $key; if (property_exists($this, $property)) { $this->{$property} = $value; return $this; } throw new InvalidArgumentException(sprintf('Invalid property: %s', $key)); return false; } // }}} /** * @param string $key * @param bool $throw OPTIONAL * @return mixed * @throws InvalidArgumentException */ protected function _getProperty($key, $throw = true) // {{{ { $getter = 'get' . $key; if (method_exists($this, $getter)) { return $this->{$getter}(); } $property = '_' . $key; if (property_exists($this, $property)) { return $property; } if ($throw) { throw new InvalidArgumentException(sprintf('Invalid property: %s', $key)); } } // }}} /** * @param string $key * @return bool */ public function has($key) // {{{ { return property_exists($this, '_' . self::toCamelCase($key)); } // }}} /** * @param string $key * @return bool */ public function __isset($key) // {{{ { return isset($this->{'_' . self::toCamelCase($key)}); } // }}} /** * @param string $key * @return mixed * @throws InvalidArgumentException */ public function __get($key) // {{{ { return $this->_getProperty($key, true); } // }}} /** * @param string $key * @param mixed $value * @return void * @throws InvalidArgumentException */ public function __set($key, $value) // {{{ { return $this->_setProperty($key, $value, true); } // }}} /** * Transform given string to camel-case. * * @param string $str * @return string */ public static function toCamelCase($str) // {{{ { if (is_array($str) && isset($str[1])) { return strtoupper($str[1]); } return preg_replace_callback( '/_(\w)/', array(__CLASS__, __FUNCTION__), (string) $str ); } // }}} }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NFnH0
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  133     0  E > > RETURN                                                   1

Class Maniple_Model:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 5
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/NFnH0
function name:  __construct
number of ops:  6
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV_INIT                                        !0      null
   11     1      > JMPZ                                                     !0, ->5
   12     2    >   INIT_METHOD_CALL                                         'setFromArray'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
   14     5    > > RETURN                                                   null

End of function __construct

Function setfromarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 10
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/NFnH0
function name:  setFromArray
number of ops:  14
compiled vars:  !0 = $data, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1      > FE_RESET_R                                       $3      !0, ->10
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->10
          3    >   ASSIGN                                                   !2, ~4
   23     4        INIT_METHOD_CALL                                         '__set'
          5        SEND_VAR_EX                                              !2
          6        SEND_VAR_EX                                              !1
          7        SEND_VAL_EX                                              <false>
          8        DO_FCALL                                      0          
   22     9      > JMP                                                      ->2
         10    >   FE_FREE                                                  $3
   25    11        FETCH_THIS                                       ~7      
         12      > RETURN                                                   ~7
   26    13*     > RETURN                                                   null

End of function setfromarray

Function _setproperty:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/NFnH0
function name:  _setProperty
number of ops:  42
compiled vars:  !0 = $key, !1 = $value, !2 = $throw, !3 = $setter, !4 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <true>
   37     3        INIT_STATIC_METHOD_CALL                                  'toCamelCase'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !0, $5
   39     7        CONCAT                                           ~7      'set', !0
          8        ASSIGN                                                   !3, ~7
   40     9        INIT_FCALL                                               'method_exists'
         10        FETCH_THIS                                       ~9      
         11        SEND_VAL                                                 ~9
         12        SEND_VAR                                                 !3
         13        DO_ICALL                                         $10     
         14      > JMPZ                                                     $10, ->20
   41    15    >   INIT_METHOD_CALL                                         !3
         16        SEND_VAR_EX                                              !1
         17        DO_FCALL                                      0          
   42    18        FETCH_THIS                                       ~12     
         19      > RETURN                                                   ~12
   45    20    >   CONCAT                                           ~13     '_', !0
         21        ASSIGN                                                   !4, ~13
   46    22        INIT_FCALL                                               'property_exists'
         23        FETCH_THIS                                       ~15     
         24        SEND_VAL                                                 ~15
         25        SEND_VAR                                                 !4
         26        DO_ICALL                                         $16     
         27      > JMPZ                                                     $16, ->32
   47    28    >   ASSIGN_OBJ                                               !4
         29        OP_DATA                                                  !1
   48    30        FETCH_THIS                                       ~18     
         31      > RETURN                                                   ~18
   51    32    >   NEW                                              $19     'InvalidArgumentException'
         33        INIT_FCALL                                               'sprintf'
         34        SEND_VAL                                                 'Invalid+property%3A+%25s'
         35        SEND_VAR                                                 !0
         36        DO_ICALL                                         $20     
         37        SEND_VAR_NO_REF_EX                                       $20
         38        DO_FCALL                                      0          
         39      > THROW                                         0          $19
   53    40*       RETURN                                                   <false>
   54    41*     > RETURN                                                   null

End of function _setproperty

Function _getproperty:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 31
Branch analysis from position: 23
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NFnH0
function name:  _getProperty
number of ops:  32
compiled vars:  !0 = $key, !1 = $throw, !2 = $getter, !3 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   62     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <true>
   64     2        CONCAT                                           ~4      'get', !0
          3        ASSIGN                                                   !2, ~4
   65     4        INIT_FCALL                                               'method_exists'
          5        FETCH_THIS                                       ~6      
          6        SEND_VAL                                                 ~6
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $7      
          9      > JMPZ                                                     $7, ->13
   66    10    >   INIT_METHOD_CALL                                         !2
         11        DO_FCALL                                      0  $8      
         12      > RETURN                                                   $8
   69    13    >   CONCAT                                           ~9      '_', !0
         14        ASSIGN                                                   !3, ~9
   70    15        INIT_FCALL                                               'property_exists'
         16        FETCH_THIS                                       ~11     
         17        SEND_VAL                                                 ~11
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                         $12     
         20      > JMPZ                                                     $12, ->22
   71    21    > > RETURN                                                   !3
   74    22    > > JMPZ                                                     !1, ->31
   75    23    >   NEW                                              $13     'InvalidArgumentException'
         24        INIT_FCALL                                               'sprintf'
         25        SEND_VAL                                                 'Invalid+property%3A+%25s'
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                         $14     
         28        SEND_VAR_NO_REF_EX                                       $14
         29        DO_FCALL                                      0          
         30      > THROW                                         0          $13
   77    31    > > RETURN                                                   null

End of function _getproperty

Function has:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NFnH0
function name:  has
number of ops:  12
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   83     0  E >   RECV                                             !0      
   85     1        INIT_FCALL                                               'property_exists'
          2        FETCH_THIS                                       ~1      
          3        SEND_VAL                                                 ~1
          4        INIT_STATIC_METHOD_CALL                                  'toCamelCase'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $2      
          7        CONCAT                                           ~3      '_', $2
          8        SEND_VAL                                                 ~3
          9        DO_ICALL                                         $4      
         10      > RETURN                                                   $4
   86    11*     > RETURN                                                   null

End of function has

Function __isset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NFnH0
function name:  __isset
number of ops:  8
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   92     0  E >   RECV                                             !0      
   94     1        INIT_STATIC_METHOD_CALL                                  'toCamelCase'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4        CONCAT                                           ~2      '_', $1
          5        ISSET_ISEMPTY_PROP_OBJ                           ~3      ~2
          6      > RETURN                                                   ~3
   95     7*     > RETURN                                                   null

End of function __isset

Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NFnH0
function name:  __get
number of ops:  7
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  102     0  E >   RECV                                             !0      
  104     1        INIT_METHOD_CALL                                         '_getProperty'
          2        SEND_VAR_EX                                              !0
          3        SEND_VAL_EX                                              <true>
          4        DO_FCALL                                      0  $1      
          5      > RETURN                                                   $1
  105     6*     > RETURN                                                   null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NFnH0
function name:  __set
number of ops:  9
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  113     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  115     2        INIT_METHOD_CALL                                         '_setProperty'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        SEND_VAL_EX                                              <true>
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
  116     8*     > RETURN                                                   null

End of function __set

Function tocamelcase:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/NFnH0
function name:  toCamelCase
number of ops:  19
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  124     0  E >   RECV                                             !0      
  126     1        TYPE_CHECK                                  128  ~1      !0
          2      > JMPZ_EX                                          ~1      ~1, ->5
          3    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~2      !0, 1
          4        BOOL                                             ~1      ~2
          5    > > JMPZ                                                     ~1, ->11
  127     6    >   INIT_FCALL                                               'strtoupper'
          7        FETCH_DIM_R                                      ~3      !0, 1
          8        SEND_VAL                                                 ~3
          9        DO_ICALL                                         $4      
         10      > RETURN                                                   $4
  129    11    >   INIT_FCALL                                               'preg_replace_callback'
  130    12        SEND_VAL                                                 '%2F_%28%5Cw%29%2F'
         13        SEND_VAL                                                 <array>
         14        CAST                                          6  ~5      !0
         15        SEND_VAL                                                 ~5
         16        DO_ICALL                                         $6      
         17      > RETURN                                                   $6
  132    18*     > RETURN                                                   null

End of function tocamelcase

End of class Maniple_Model.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.89 ms | 1404 KiB | 23 Q