3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ReminderPushEvents { /** * @var array */ private $properties; /** * @var string */ private $event = 'reminder_push_event'; /** * @var \DateTimeInterface */ private $timestamp; /** * Constructor. */ public function __construct() { $this->properties = ['customers' => []]; } /** * [ * 'customers' => [ * ['customerId' => 1213], * ['customerId' => 1212] * ] * ] * * @param array $properties * * @return $this */ public function addProperties(array $properties) { $this->properties['customers'] = $properties; return $this; } /** * @return array */ public function getProperties() { if (!$this->properties) { throw new \RuntimeException(); } return $this->properties; } /** * @return string */ public function getEvent() { if (!$this->event) { throw new \RuntimeException(); } return $this->event; } /** * @return \DateTimeInterface */ public function getTimestamp() { if (!$this->timestamp) { $this->timestamp = new \DateTimeImmutable(); } return $this->timestamp->format('c'); } } class EventRequest { /** * @var string */ private $providerId; /** * @var array */ private $events; /** * Constructor. */ public function __construct($providerId) { $this->providerId = $providerId; $this->events = []; } /** * @return string */ public function getProviderId() { return $this->providerId; } /** * @return array */ public function getEvents() { return $this->events; } /** * @param EventsInterface $events * * @return $this */ public function addEvents( $events) { $this->events[] = $events; return $this; } public function serialize($entity = null, $recursionDepth = 2) { $entity = $entity?: $this; $result = []; $class = new \ReflectionClass(get_class($entity)); foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { $methodName = $method->name; if (strpos($methodName, "get") === 0 && strlen($methodName) > 3) { $propertyName = lcfirst(substr($methodName, 3)); $value = $method->invoke($entity); if (is_array($value)) { foreach ($value as $name => $subValue) { if (is_object($subValue)) { if ($recursionDepth > 0) { $result[$propertyName][$name] = $this->serialize($subValue, $recursionDepth - 1); continue; } $result[$propertyName][$name] = "***"; continue; } if (is_array($subValue)) { $result[$propertyName][$name] = $subValue; continue; } $result[$propertyName][$name] = $subValue; } continue; } if (is_object($value)) { if ($recursionDepth > 0) { $result[$propertyName] = $this->serialize($value, $recursionDepth - 1); continue; } $result[$propertyName] = "***"; //stop recursion continue; } $result[$propertyName] = $value; } } return $result; } } $foo = new EventRequest('crm_newsletter'); $event = new ReminderPushEvents(); $event->addProperties( [['customerId' => 1213], ['customerId' => 1212]]); $foo->addEvents($event); $foo->addEvents($event); var_dump( $foo->serialize());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GXMsS
function name:  (null)
number of ops:  22
compiled vars:  !0 = $foo, !1 = $event
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  187     0  E >   NEW                                              $2      'EventRequest'
          1        SEND_VAL_EX                                              'crm_newsletter'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
  190     4        NEW                                              $5      'ReminderPushEvents'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
  191     7        INIT_METHOD_CALL                                         !1, 'addProperties'
          8        SEND_VAL_EX                                              <array>
          9        DO_FCALL                                      0          
  192    10        INIT_METHOD_CALL                                         !0, 'addEvents'
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0          
  193    13        INIT_METHOD_CALL                                         !0, 'addEvents'
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0          
  195    16        INIT_FCALL                                               'var_dump'
         17        INIT_METHOD_CALL                                         !0, 'serialize'
         18        DO_FCALL                                      0  $11     
         19        SEND_VAR                                                 $11
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Class ReminderPushEvents:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GXMsS
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   ASSIGN_OBJ                                               'properties'
          1        OP_DATA                                                  <array>
   25     2      > RETURN                                                   null

End of function __construct

Function addproperties:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GXMsS
function name:  addProperties
number of ops:  7
compiled vars:  !0 = $properties
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
   41     1        FETCH_OBJ_W                                      $1      'properties'
          2        ASSIGN_DIM                                               $1, 'customers'
          3        OP_DATA                                                  !0
   43     4        FETCH_THIS                                       ~3      
          5      > RETURN                                                   ~3
   44     6*     > RETURN                                                   null

End of function addproperties

Function getproperties:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GXMsS
function name:  getProperties
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   FETCH_OBJ_R                                      ~0      'properties'
          1        BOOL_NOT                                         ~1      ~0
          2      > JMPZ                                                     ~1, ->6
   52     3    >   NEW                                              $2      'RuntimeException'
          4        DO_FCALL                                      0          
          5      > THROW                                         0          $2
   55     6    >   FETCH_OBJ_R                                      ~4      'properties'
          7      > RETURN                                                   ~4
   56     8*     > RETURN                                                   null

End of function getproperties

Function getevent:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GXMsS
function name:  getEvent
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E >   FETCH_OBJ_R                                      ~0      'event'
          1        BOOL_NOT                                         ~1      ~0
          2      > JMPZ                                                     ~1, ->6
   64     3    >   NEW                                              $2      'RuntimeException'
          4        DO_FCALL                                      0          
          5      > THROW                                         0          $2
   67     6    >   FETCH_OBJ_R                                      ~4      'event'
          7      > RETURN                                                   ~4
   68     8*     > RETURN                                                   null

End of function getevent

Function gettimestamp:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/GXMsS
function name:  getTimestamp
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   75     0  E >   FETCH_OBJ_R                                      ~0      'timestamp'
          1        BOOL_NOT                                         ~1      ~0
          2      > JMPZ                                                     ~1, ->7
   76     3    >   NEW                                              $3      'DateTimeImmutable'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               'timestamp'
          6        OP_DATA                                                  $3
   79     7    >   FETCH_OBJ_R                                      ~5      'timestamp'
          8        INIT_METHOD_CALL                                         ~5, 'format'
          9        SEND_VAL_EX                                              'c'
         10        DO_FCALL                                      0  $6      
         11      > RETURN                                                   $6
   80    12*     > RETURN                                                   null

End of function gettimestamp

End of class ReminderPushEvents.

Class EventRequest:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GXMsS
function name:  __construct
number of ops:  6
compiled vars:  !0 = $providerId
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   97     0  E >   RECV                                             !0      
   99     1        ASSIGN_OBJ                                               'providerId'
          2        OP_DATA                                                  !0
  100     3        ASSIGN_OBJ                                               'events'
          4        OP_DATA                                                  <array>
  101     5      > RETURN                                                   null

End of function __construct

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

End of function getproviderid

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

End of function getevents

Function addevents:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GXMsS
function name:  addEvents
number of ops:  7
compiled vars:  !0 = $events
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  124     0  E >   RECV                                             !0      
  126     1        FETCH_OBJ_W                                      $1      'events'
          2        ASSIGN_DIM                                               $1
          3        OP_DATA                                                  !0
  128     4        FETCH_THIS                                       ~3      
          5      > RETURN                                                   ~3
  129     6*     > RETURN                                                   null

End of function addevents

Function serialize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 93
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 93
Branch analysis from position: 17
2 jumps found. (Code = 46) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 92
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 75
Branch analysis from position: 43
2 jumps found. (Code = 77) Position 1 = 44, Position 2 = 73
Branch analysis from position: 44
2 jumps found. (Code = 78) Position 1 = 45, Position 2 = 73
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 63
Branch analysis from position: 48
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 59
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 69
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 73
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 73
Branch analysis from position: 75
2 jumps found. (Code = 43) Position 1 = 77, Position 2 = 90
Branch analysis from position: 77
2 jumps found. (Code = 43) Position 1 = 79, Position 2 = 87
Branch analysis from position: 79
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 87
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 90
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 92
Branch analysis from position: 28
Branch analysis from position: 93
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 93
filename:       /in/GXMsS
function name:  serialize
number of ops:  96
compiled vars:  !0 = $entity, !1 = $recursionDepth, !2 = $result, !3 = $class, !4 = $method, !5 = $methodName, !6 = $propertyName, !7 = $value, !8 = $subValue, !9 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  130     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      2
  132     2        JMP_SET                                          ~10     !0, ->5
          3        FETCH_THIS                                       ~11     
          4        QM_ASSIGN                                        ~10     ~11
          5        ASSIGN                                                   !0, ~10
  133     6        ASSIGN                                                   !2, <array>
  134     7        NEW                                              $14     'ReflectionClass'
          8        GET_CLASS                                        ~15     !0
          9        SEND_VAL_EX                                              ~15
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !3, $14
  135    12        INIT_METHOD_CALL                                         !3, 'getMethods'
         13        SEND_VAL_EX                                              1
         14        DO_FCALL                                      0  $18     
         15      > FE_RESET_R                                       $19     $18, ->93
         16    > > FE_FETCH_R                                               $19, !4, ->93
  136    17    >   FETCH_OBJ_R                                      ~20     !4, 'name'
         18        ASSIGN                                                   !5, ~20
  137    19        INIT_FCALL                                               'strpos'
         20        SEND_VAR                                                 !5
         21        SEND_VAL                                                 'get'
         22        DO_ICALL                                         $22     
         23        IS_IDENTICAL                                     ~23     $22, 0
         24      > JMPZ_EX                                          ~23     ~23, ->28
         25    >   STRLEN                                           ~24     !5
         26        IS_SMALLER                                       ~25     3, ~24
         27        BOOL                                             ~23     ~25
         28    > > JMPZ                                                     ~23, ->92
  138    29    >   INIT_FCALL                                               'lcfirst'
         30        INIT_FCALL                                               'substr'
         31        SEND_VAR                                                 !5
         32        SEND_VAL                                                 3
         33        DO_ICALL                                         $26     
         34        SEND_VAR                                                 $26
         35        DO_ICALL                                         $27     
         36        ASSIGN                                                   !6, $27
  139    37        INIT_METHOD_CALL                                         !4, 'invoke'
         38        SEND_VAR_EX                                              !0
         39        DO_FCALL                                      0  $29     
         40        ASSIGN                                                   !7, $29
  141    41        TYPE_CHECK                                  128          !7
         42      > JMPZ                                                     ~31, ->75
  142    43    > > FE_RESET_R                                       $32     !7, ->73
         44    > > FE_FETCH_R                                       ~33     $32, !8, ->73
         45    >   ASSIGN                                                   !9, ~33
  143    46        TYPE_CHECK                                  256          !8
         47      > JMPZ                                                     ~35, ->63
  144    48    >   IS_SMALLER                                               0, !1
         49      > JMPZ                                                     ~36, ->59
  145    50    >   INIT_METHOD_CALL                                         'serialize'
         51        SEND_VAR_EX                                              !8
         52        SUB                                              ~39     !1, 1
         53        SEND_VAL_EX                                              ~39
         54        DO_FCALL                                      0  $40     
         55        FETCH_DIM_W                                      $37     !2, !6
         56        ASSIGN_DIM                                               $37, !9
         57        OP_DATA                                                  $40
  147    58      > JMP                                                      ->44
  150    59    >   FETCH_DIM_W                                      $41     !2, !6
         60        ASSIGN_DIM                                               $41, !9
         61        OP_DATA                                                  '%2A%2A%2A'
  152    62      > JMP                                                      ->44
  155    63    >   TYPE_CHECK                                  128          !8
         64      > JMPZ                                                     ~43, ->69
  156    65    >   FETCH_DIM_W                                      $44     !2, !6
         66        ASSIGN_DIM                                               $44, !9
         67        OP_DATA                                                  !8
  158    68      > JMP                                                      ->44
  161    69    >   FETCH_DIM_W                                      $46     !2, !6
         70        ASSIGN_DIM                                               $46, !9
         71        OP_DATA                                                  !8
  142    72      > JMP                                                      ->44
         73    >   FE_FREE                                                  $32
  164    74      > JMP                                                      ->16
  167    75    >   TYPE_CHECK                                  256          !7
         76      > JMPZ                                                     ~48, ->90
  168    77    >   IS_SMALLER                                               0, !1
         78      > JMPZ                                                     ~49, ->87
  169    79    >   INIT_METHOD_CALL                                         'serialize'
         80        SEND_VAR_EX                                              !7
         81        SUB                                              ~51     !1, 1
         82        SEND_VAL_EX                                              ~51
         83        DO_FCALL                                      0  $52     
         84        ASSIGN_DIM                                               !2, !6
         85        OP_DATA                                                  $52
  171    86      > JMP                                                      ->16
  174    87    >   ASSIGN_DIM                                               !2, !6
         88        OP_DATA                                                  '%2A%2A%2A'
  176    89      > JMP                                                      ->16
  179    90    >   ASSIGN_DIM                                               !2, !6
         91        OP_DATA                                                  !7
  135    92    > > JMP                                                      ->16
         93    >   FE_FREE                                                  $19
  182    94      > RETURN                                                   !2
  183    95*     > RETURN                                                   null

End of function serialize

End of class EventRequest.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.35 ms | 1416 KiB | 21 Q