3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * This is a proxy class for calling PrefsManager methods using a fixed * user ID. * * @package ManipleCore_Prefs */ class ManipleCore_Prefs_UserPrefs { /** * @var ManipleCore_Prefs_PrefManagerInterface */ protected $_prefManager; /** * @var array */ protected $_prefNames; /** * @var int|string */ protected $_userId; /** * Constructor. * * @param ManipleCore_Prefs_PrefManagerInterface $prefsManager * @param int|string $userId * @param bool|string $load */ public function __construct(ManipleCore_Prefs_PrefManagerInterface $prefManager, $userId, $load = true) { if (!is_int($userId) && !is_string($userId)) { throw new InvalidArgumentException('User ID must either be an integer or a string'); } $this->_prefManager = $prefManager; $this->_userId = $userId; if ($load) { $prefix = is_string($load) ? $load : null; $names = $this->_prefManager->loadUserPrefs($userId, $prefix); $this->_prefNames = array_flip($names); } } /** * Get user preference. * * @param string $name * @param mixed $defaultValue * @return mixed */ public function get($name, $defaultValue = null) { $value = $this->_prefManager->getUserPref($this->_userId, $name, $defaultValue); $this->_prefNames[(string) $name] = true; return $value; } /** * @param string $name * @param bool $defaultValue OPTIONAL * @return bool|null */ public function getBool($name, $defaultValue = null) { $value = $this->get($name, $defaultValue); if ($value !== null) { $value = (bool) $value; } return $value; } /** * @param string $name * @param int $defaultValue OPTIONAL * @return int|null */ public function getInt($name, $defaultValue = null) { $value = $this->get($name, $defaultValue); if ($value !== null) { $value = (int) $value; } return $value; } /** * @param string $name * @param float $defaultValue OPTIONAL * @return float|null */ public function getFloat($name, $defaultValue = null) { $value = $this->get($name, $defaultValue); if ($value !== null) { $value = (float) $value; } return $value; } /** * @param string $name * @param string $defaultValue OPTIONAL * @return string|null */ public function getString($name, $defaultValue = null) { $value = $this->get($name, $defaultValue); if ($value !== null) { $value = (string) $value; } return $value; } /** * Set user preference. * * @param string $name * @param mixed $value * @return ManipleCore_Prefs_UserPrefs */ public function set($name, $value) { $this->_prefManager->setUserPref($this->_userId, $name, $value); $this->_prefNames[(string) $name] = true; return $this; } /** * Reset user preference. * * @param string $name * @return ManipleCore_Prefs_UserPrefs */ public function reset($name) { $this->_prefManager->resetUserPref($this->_userId, $name); unset($this->_prefNames[(string) $name]); return $this; } /** * Persist user preferences. * * @return ManipleCore_Prefs_UserPrefs */ public function save() { $this->_prefManager->saveUserPrefs($this->_userId); return $this; } /** * Return names of loaded preferences. * * @return string[] */ public function getNames() { return array_keys((array) $this->_prefNames); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TVNJI
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  166     0  E > > RETURN                                                   1

Class ManipleCore_Prefs_UserPrefs:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 36
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
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: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
Branch analysis from position: 9
filename:       /in/TVNJI
function name:  __construct
number of ops:  37
compiled vars:  !0 = $prefManager, !1 = $userId, !2 = $load, !3 = $prefix, !4 = $names
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <true>
   35     3        TYPE_CHECK                                   16  ~5      !1
          4        BOOL_NOT                                         ~6      ~5
          5      > JMPZ_EX                                          ~6      ~6, ->9
          6    >   TYPE_CHECK                                   64  ~7      !1
          7        BOOL_NOT                                         ~8      ~7
          8        BOOL                                             ~6      ~8
          9    > > JMPZ                                                     ~6, ->14
   36    10    >   NEW                                              $9      'InvalidArgumentException'
         11        SEND_VAL_EX                                              'User+ID+must+either+be+an+integer+or+a+string'
         12        DO_FCALL                                      0          
         13      > THROW                                         0          $9
   39    14    >   ASSIGN_OBJ                                               '_prefManager'
         15        OP_DATA                                                  !0
   40    16        ASSIGN_OBJ                                               '_userId'
         17        OP_DATA                                                  !1
   42    18      > JMPZ                                                     !2, ->36
   43    19    >   TYPE_CHECK                                   64          !2
         20      > JMPZ                                                     ~13, ->23
         21    >   QM_ASSIGN                                        ~14     !2
         22      > JMP                                                      ->24
         23    >   QM_ASSIGN                                        ~14     null
         24    >   ASSIGN                                                   !3, ~14
   44    25        FETCH_OBJ_R                                      ~16     '_prefManager'
         26        INIT_METHOD_CALL                                         ~16, 'loadUserPrefs'
         27        SEND_VAR_EX                                              !1
         28        SEND_VAR_EX                                              !3
         29        DO_FCALL                                      0  $17     
         30        ASSIGN                                                   !4, $17
   45    31        INIT_FCALL                                               'array_flip'
         32        SEND_VAR                                                 !4
         33        DO_ICALL                                         $20     
         34        ASSIGN_OBJ                                               '_prefNames'
         35        OP_DATA                                                  $20
   47    36    > > RETURN                                                   null

End of function __construct

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TVNJI
function name:  get
number of ops:  17
compiled vars:  !0 = $name, !1 = $defaultValue, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   58     2        FETCH_OBJ_R                                      ~3      '_prefManager'
          3        INIT_METHOD_CALL                                         ~3, 'getUserPref'
          4        CHECK_FUNC_ARG                                           
          5        FETCH_OBJ_FUNC_ARG                               $4      '_userId'
          6        SEND_FUNC_ARG                                            $4
          7        SEND_VAR_EX                                              !0
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0  $5      
         10        ASSIGN                                                   !2, $5
   59    11        CAST                                          6  ~8      !0
         12        FETCH_OBJ_W                                      $7      '_prefNames'
         13        ASSIGN_DIM                                               $7, ~8
         14        OP_DATA                                                  <true>
   60    15      > RETURN                                                   !2
   61    16*     > RETURN                                                   null

End of function get

Function getbool:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/TVNJI
function name:  getBool
number of ops:  13
compiled vars:  !0 = $name, !1 = $defaultValue, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   68     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   70     2        INIT_METHOD_CALL                                         'get'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !2, $3
   71     7        TYPE_CHECK                                  1020          !2
          8      > JMPZ                                                     ~5, ->11
   72     9    >   BOOL                                             ~6      !2
         10        ASSIGN                                                   !2, ~6
   74    11    > > RETURN                                                   !2
   75    12*     > RETURN                                                   null

End of function getbool

Function getint:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/TVNJI
function name:  getInt
number of ops:  13
compiled vars:  !0 = $name, !1 = $defaultValue, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   82     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   84     2        INIT_METHOD_CALL                                         'get'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !2, $3
   85     7        TYPE_CHECK                                  1020          !2
          8      > JMPZ                                                     ~5, ->11
   86     9    >   CAST                                          4  ~6      !2
         10        ASSIGN                                                   !2, ~6
   88    11    > > RETURN                                                   !2
   89    12*     > RETURN                                                   null

End of function getint

Function getfloat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/TVNJI
function name:  getFloat
number of ops:  13
compiled vars:  !0 = $name, !1 = $defaultValue, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   96     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   98     2        INIT_METHOD_CALL                                         'get'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !2, $3
   99     7        TYPE_CHECK                                  1020          !2
          8      > JMPZ                                                     ~5, ->11
  100     9    >   CAST                                          5  ~6      !2
         10        ASSIGN                                                   !2, ~6
  102    11    > > RETURN                                                   !2
  103    12*     > RETURN                                                   null

End of function getfloat

Function getstring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/TVNJI
function name:  getString
number of ops:  13
compiled vars:  !0 = $name, !1 = $defaultValue, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  110     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
  112     2        INIT_METHOD_CALL                                         'get'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !2, $3
  113     7        TYPE_CHECK                                  1020          !2
          8      > JMPZ                                                     ~5, ->11
  114     9    >   CAST                                          6  ~6      !2
         10        ASSIGN                                                   !2, ~6
  116    11    > > RETURN                                                   !2
  117    12*     > RETURN                                                   null

End of function getstring

Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TVNJI
function name:  set
number of ops:  17
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  126     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  128     2        FETCH_OBJ_R                                      ~2      '_prefManager'
          3        INIT_METHOD_CALL                                         ~2, 'setUserPref'
          4        CHECK_FUNC_ARG                                           
          5        FETCH_OBJ_FUNC_ARG                               $3      '_userId'
          6        SEND_FUNC_ARG                                            $3
          7        SEND_VAR_EX                                              !0
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
  129    10        CAST                                          6  ~6      !0
         11        FETCH_OBJ_W                                      $5      '_prefNames'
         12        ASSIGN_DIM                                               $5, ~6
         13        OP_DATA                                                  <true>
  130    14        FETCH_THIS                                       ~8      
         15      > RETURN                                                   ~8
  131    16*     > RETURN                                                   null

End of function set

Function reset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TVNJI
function name:  reset
number of ops:  14
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  139     0  E >   RECV                                             !0      
  141     1        FETCH_OBJ_R                                      ~1      '_prefManager'
          2        INIT_METHOD_CALL                                         ~1, 'resetUserPref'
          3        CHECK_FUNC_ARG                                           
          4        FETCH_OBJ_FUNC_ARG                               $2      '_userId'
          5        SEND_FUNC_ARG                                            $2
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
  142     8        CAST                                          6  ~5      !0
          9        FETCH_OBJ_UNSET                                  $4      '_prefNames'
         10        UNSET_DIM                                                $4, ~5
  143    11        FETCH_THIS                                       ~6      
         12      > RETURN                                                   ~6
  144    13*     > RETURN                                                   null

End of function reset

Function save:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TVNJI
function name:  save
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  153     0  E >   FETCH_OBJ_R                                      ~0      '_prefManager'
          1        INIT_METHOD_CALL                                         ~0, 'saveUserPrefs'
          2        CHECK_FUNC_ARG                                           
          3        FETCH_OBJ_FUNC_ARG                               $1      '_userId'
          4        SEND_FUNC_ARG                                            $1
          5        DO_FCALL                                      0          
  154     6        FETCH_THIS                                       ~3      
          7      > RETURN                                                   ~3
  155     8*     > RETURN                                                   null

End of function save

Function getnames:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TVNJI
function name:  getNames
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  164     0  E >   INIT_FCALL                                               'array_keys'
          1        FETCH_OBJ_R                                      ~0      '_prefNames'
          2        CAST                                          7  ~1      ~0
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5      > RETURN                                                   $2
  165     6*     > RETURN                                                   null

End of function getnames

End of class ManipleCore_Prefs_UserPrefs.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.85 ms | 1412 KiB | 17 Q