3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User{ var $username; var $created; var $actions = array(); var $sort; var $filterby; var $filtervalue; function __construct($username){ $this->username = $username; $this->created = new DateTime(null); $this->sort = "User::action_sort_name"; $this->filterby=null; $this->filtervalue=null; } function get_username(){ return $this->username; } function add_action($pillname){ array_push($this->actions, new Action($pillname) ); } function set_sort_method($sort_name){ $this->sort = $sort_name; } function get_sort_method(){ return $this->sort; } function sort_actions(){ usort($this->actions, $this->sort); } function get_display_actions(){ if ($this->filtervalue != null){ $res = array_filter($this->actions, $this->filterby); $pr = print_r($res, true); return $res; } return $this->actions; } function get_pill_names(){ $pill_names = array(); foreach($this->actions as $action){ array_push($pill_names, $action->pillname); } return array_unique($pill_names); } function set_filtervalue($val){ $this->filtervalue = $val; } function set_filterby($val){ $this->filterby = $val; } public function action_filter_name($a){ $res = ($a->pillname == $this->filtervalue); return $res; } public function action_filter_time($a){ /* before this time */ if ($a > $this->filtervalue){ return true; } } public static function action_sort_name($a, $b){ if ($a->pillname == $b->pillname){ return 0; } return ($a->pillname < $b->pillname) ? -1 : 1 ; } public static function action_sort_date($a, $b){ if ($a->datetime == $b->datetime){ return 0; } return ($a->datetime < $b->datetime) ? -1 : 1 ; } } class Action{ var $pillname; var $datetime; function __construct($pillname){ $this->pillname = $pillname; $this->datetime = new DateTime(null); } } echo serialize(new User('attack')) ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/viSiV
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   90     0  E >   INIT_FCALL                                               'serialize'
          1        NEW                                              $0      'User'
          2        SEND_VAL_EX                                              'attack'
          3        DO_FCALL                                      0          
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                         $2      
          6        ECHO                                                     $2
   92     7      > RETURN                                                   1

Class User:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/viSiV
function name:  __construct
number of ops:  15
compiled vars:  !0 = $username
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        ASSIGN_OBJ                                               'username'
          2        OP_DATA                                                  !0
   15     3        NEW                                              $3      'DateTime'
          4        SEND_VAL_EX                                              null
          5        DO_FCALL                                      0          
          6        ASSIGN_OBJ                                               'created'
          7        OP_DATA                                                  $3
   16     8        ASSIGN_OBJ                                               'sort'
          9        OP_DATA                                                  'User%3A%3Aaction_sort_name'
   17    10        ASSIGN_OBJ                                               'filterby'
         11        OP_DATA                                                  null
   18    12        ASSIGN_OBJ                                               'filtervalue'
         13        OP_DATA                                                  null
   19    14      > RETURN                                                   null

End of function __construct

Function get_username:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/viSiV
function name:  get_username
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   FETCH_OBJ_R                                      ~0      'username'
          1      > RETURN                                                   ~0
   22     2*     > RETURN                                                   null

End of function get_username

Function add_action:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/viSiV
function name:  add_action
number of ops:  10
compiled vars:  !0 = $pillname
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   24     1        INIT_FCALL                                               'array_push'
          2        FETCH_OBJ_W                                      $1      'actions'
          3        SEND_REF                                                 $1
          4        NEW                                              $2      'Action'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
   25     9      > RETURN                                                   null

End of function add_action

Function set_sort_method:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/viSiV
function name:  set_sort_method
number of ops:  4
compiled vars:  !0 = $sort_name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        ASSIGN_OBJ                                               'sort'
          2        OP_DATA                                                  !0
   28     3      > RETURN                                                   null

End of function set_sort_method

Function get_sort_method:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/viSiV
function name:  get_sort_method
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   FETCH_OBJ_R                                      ~0      'sort'
          1      > RETURN                                                   ~0
   31     2*     > RETURN                                                   null

End of function get_sort_method

Function sort_actions:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/viSiV
function name:  sort_actions
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'usort'
          1        FETCH_OBJ_W                                      $0      'actions'
          2        SEND_REF                                                 $0
          3        FETCH_OBJ_R                                      ~1      'sort'
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                                 
   34     6      > RETURN                                                   null

End of function sort_actions

Function get_display_actions:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/viSiV
function name:  get_display_actions
number of ops:  19
compiled vars:  !0 = $res, !1 = $pr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   FETCH_OBJ_R                                      ~2      'filtervalue'
          1        IS_NOT_EQUAL                                             ~2, null
          2      > JMPZ                                                     ~3, ->16
   37     3    >   INIT_FCALL                                               'array_filter'
          4        FETCH_OBJ_R                                      ~4      'actions'
          5        SEND_VAL                                                 ~4
          6        FETCH_OBJ_R                                      ~5      'filterby'
          7        SEND_VAL                                                 ~5
          8        DO_ICALL                                         $6      
          9        ASSIGN                                                   !0, $6
   38    10        INIT_FCALL                                               'print_r'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 <true>
         13        DO_ICALL                                         $8      
         14        ASSIGN                                                   !1, $8
   39    15      > RETURN                                                   !0
   41    16    >   FETCH_OBJ_R                                      ~10     'actions'
         17      > RETURN                                                   ~10
   42    18*     > RETURN                                                   null

End of function get_display_actions

Function get_pill_names:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/viSiV
function name:  get_pill_names
number of ops:  16
compiled vars:  !0 = $pill_names, !1 = $action
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   ASSIGN                                                   !0, <array>
   45     1        FETCH_OBJ_R                                      ~3      'actions'
          2      > FE_RESET_R                                       $4      ~3, ->10
          3    > > FE_FETCH_R                                               $4, !1, ->10
   46     4    >   INIT_FCALL                                               'array_push'
          5        SEND_REF                                                 !0
          6        FETCH_OBJ_R                                      ~5      !1, 'pillname'
          7        SEND_VAL                                                 ~5
          8        DO_ICALL                                                 
   45     9      > JMP                                                      ->3
         10    >   FE_FREE                                                  $4
   48    11        INIT_FCALL                                               'array_unique'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $7      
         14      > RETURN                                                   $7
   49    15*     > RETURN                                                   null

End of function get_pill_names

Function set_filtervalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/viSiV
function name:  set_filtervalue
number of ops:  4
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   RECV                                             !0      
   51     1        ASSIGN_OBJ                                               'filtervalue'
          2        OP_DATA                                                  !0
   52     3      > RETURN                                                   null

End of function set_filtervalue

Function set_filterby:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/viSiV
function name:  set_filterby
number of ops:  4
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV                                             !0      
   54     1        ASSIGN_OBJ                                               'filterby'
          2        OP_DATA                                                  !0
   55     3      > RETURN                                                   null

End of function set_filterby

Function action_filter_name:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/viSiV
function name:  action_filter_name
number of ops:  7
compiled vars:  !0 = $a, !1 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   RECV                                             !0      
   57     1        FETCH_OBJ_R                                      ~2      !0, 'pillname'
          2        FETCH_OBJ_R                                      ~3      'filtervalue'
          3        IS_EQUAL                                         ~4      ~2, ~3
          4        ASSIGN                                                   !1, ~4
   58     5      > RETURN                                                   !1
   59     6*     > RETURN                                                   null

End of function action_filter_name

Function action_filter_time:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/viSiV
function name:  action_filter_time
number of ops:  6
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   RECV                                             !0      
   62     1        FETCH_OBJ_R                                      ~1      'filtervalue'
          2        IS_SMALLER                                               ~1, !0
          3      > JMPZ                                                     ~2, ->5
   63     4    > > RETURN                                                   <true>
   65     5    > > RETURN                                                   null

End of function action_filter_time

Function action_sort_name:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/viSiV
function name:  action_sort_name
number of ops:  16
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   68     2        FETCH_OBJ_R                                      ~2      !0, 'pillname'
          3        FETCH_OBJ_R                                      ~3      !1, 'pillname'
          4        IS_EQUAL                                                 ~2, ~3
          5      > JMPZ                                                     ~4, ->7
   69     6    > > RETURN                                                   0
   71     7    >   FETCH_OBJ_R                                      ~5      !0, 'pillname'
          8        FETCH_OBJ_R                                      ~6      !1, 'pillname'
          9        IS_SMALLER                                               ~5, ~6
         10      > JMPZ                                                     ~7, ->13
         11    >   QM_ASSIGN                                        ~8      -1
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~8      1
         14    > > RETURN                                                   ~8
   72    15*     > RETURN                                                   null

End of function action_sort_name

Function action_sort_date:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/viSiV
function name:  action_sort_date
number of ops:  16
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   73     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   74     2        FETCH_OBJ_R                                      ~2      !0, 'datetime'
          3        FETCH_OBJ_R                                      ~3      !1, 'datetime'
          4        IS_EQUAL                                                 ~2, ~3
          5      > JMPZ                                                     ~4, ->7
   75     6    > > RETURN                                                   0
   77     7    >   FETCH_OBJ_R                                      ~5      !0, 'datetime'
          8        FETCH_OBJ_R                                      ~6      !1, 'datetime'
          9        IS_SMALLER                                               ~5, ~6
         10      > JMPZ                                                     ~7, ->13
         11    >   QM_ASSIGN                                        ~8      -1
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~8      1
         14    > > RETURN                                                   ~8
   78    15*     > RETURN                                                   null

End of function action_sort_date

End of class User.

Class Action:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/viSiV
function name:  __construct
number of ops:  9
compiled vars:  !0 = $pillname
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   84     0  E >   RECV                                             !0      
   85     1        ASSIGN_OBJ                                               'pillname'
          2        OP_DATA                                                  !0
   86     3        NEW                                              $3      'DateTime'
          4        SEND_VAL_EX                                              null
          5        DO_FCALL                                      0          
          6        ASSIGN_OBJ                                               'datetime'
          7        OP_DATA                                                  $3
   87     8      > RETURN                                                   null

End of function __construct

End of class Action.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.03 ms | 1416 KiB | 25 Q