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) { return new \DateTimeImmutable(); } return $this->timestamp; } } 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; } } function entity2array($entity, $recursionDepth = 2) { $result = array(); $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] = entity2array($subValue, $recursionDepth - 1); } else { $result[$propertyName][$name] = "***"; //stop recursion } continue; } if (is_array($subValue)) { $result[$propertyName][$name] = $subValue; //stop recursion continue; } $result[$propertyName][$name] = $subValue; } continue; } if (is_object($value)) { if ($recursionDepth > 0) { $result[$propertyName] = entity2array($value, $recursionDepth - 1); } else { $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); var_dump( entity2array($foo));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bEiHO
function name:  (null)
number of ops:  20
compiled vars:  !0 = $foo, !1 = $event
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  180     0  E >   NEW                                              $2      'EventRequest'
          1        SEND_VAL_EX                                              'crm_newsletter'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
  183     4        NEW                                              $5      'ReminderPushEvents'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
  184     7        INIT_METHOD_CALL                                         !1, 'addProperties'
          8        SEND_VAL_EX                                              <array>
          9        DO_FCALL                                      0          
  185    10        INIT_METHOD_CALL                                         !0, 'addEvents'
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0          
  187    13        INIT_FCALL                                               'var_dump'
         14        INIT_FCALL                                               'entity2array'
         15        SEND_VAR                                                 !0
         16        DO_FCALL                                      0  $10     
         17        SEND_VAR                                                 $10
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Function entity2array:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 89
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 89
Branch analysis from position: 13
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 88
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 71
Branch analysis from position: 39
2 jumps found. (Code = 77) Position 1 = 40, Position 2 = 69
Branch analysis from position: 40
2 jumps found. (Code = 78) Position 1 = 41, Position 2 = 69
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 59
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 55
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 59
2 jumps found. (Code = 43) Position 1 = 61, Position 2 = 65
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 69
Branch analysis from position: 71
2 jumps found. (Code = 43) Position 1 = 73, Position 2 = 86
Branch analysis from position: 73
2 jumps found. (Code = 43) Position 1 = 75, Position 2 = 83
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 83
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 86
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 88
Branch analysis from position: 24
Branch analysis from position: 89
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 89
filename:       /in/bEiHO
function name:  entity2array
number of ops:  92
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
-------------------------------------------------------------------------------------
  134     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      2
  135     2        ASSIGN                                                   !2, <array>
  136     3        NEW                                              $11     'ReflectionClass'
          4        GET_CLASS                                        ~12     !0
          5        SEND_VAL_EX                                              ~12
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !3, $11
  137     8        INIT_METHOD_CALL                                         !3, 'getMethods'
          9        SEND_VAL_EX                                              1
         10        DO_FCALL                                      0  $15     
         11      > FE_RESET_R                                       $16     $15, ->89
         12    > > FE_FETCH_R                                               $16, !4, ->89
  138    13    >   FETCH_OBJ_R                                      ~17     !4, 'name'
         14        ASSIGN                                                   !5, ~17
  139    15        INIT_FCALL                                               'strpos'
         16        SEND_VAR                                                 !5
         17        SEND_VAL                                                 'get'
         18        DO_ICALL                                         $19     
         19        IS_IDENTICAL                                     ~20     $19, 0
         20      > JMPZ_EX                                          ~20     ~20, ->24
         21    >   STRLEN                                           ~21     !5
         22        IS_SMALLER                                       ~22     3, ~21
         23        BOOL                                             ~20     ~22
         24    > > JMPZ                                                     ~20, ->88
  140    25    >   INIT_FCALL                                               'lcfirst'
         26        INIT_FCALL                                               'substr'
         27        SEND_VAR                                                 !5
         28        SEND_VAL                                                 3
         29        DO_ICALL                                         $23     
         30        SEND_VAR                                                 $23
         31        DO_ICALL                                         $24     
         32        ASSIGN                                                   !6, $24
  141    33        INIT_METHOD_CALL                                         !4, 'invoke'
         34        SEND_VAR_EX                                              !0
         35        DO_FCALL                                      0  $26     
         36        ASSIGN                                                   !7, $26
  143    37        TYPE_CHECK                                  128          !7
         38      > JMPZ                                                     ~28, ->71
  144    39    > > FE_RESET_R                                       $29     !7, ->69
         40    > > FE_FETCH_R                                       ~30     $29, !8, ->69
         41    >   ASSIGN                                                   !9, ~30
  145    42        TYPE_CHECK                                  256          !8
         43      > JMPZ                                                     ~32, ->59
  146    44    >   IS_SMALLER                                               0, !1
         45      > JMPZ                                                     ~33, ->55
  147    46    >   INIT_FCALL_BY_NAME                                       'entity2array'
         47        SEND_VAR_EX                                              !8
         48        SUB                                              ~36     !1, 1
         49        SEND_VAL_EX                                              ~36
         50        DO_FCALL                                      0  $37     
         51        FETCH_DIM_W                                      $34     !2, !6
         52        ASSIGN_DIM                                               $34, !9
         53        OP_DATA                                                  $37
         54      > JMP                                                      ->58
  149    55    >   FETCH_DIM_W                                      $38     !2, !6
         56        ASSIGN_DIM                                               $38, !9
         57        OP_DATA                                                  '%2A%2A%2A'
  151    58    > > JMP                                                      ->40
  153    59    >   TYPE_CHECK                                  128          !8
         60      > JMPZ                                                     ~40, ->65
  154    61    >   FETCH_DIM_W                                      $41     !2, !6
         62        ASSIGN_DIM                                               $41, !9
         63        OP_DATA                                                  !8
  156    64      > JMP                                                      ->40
  159    65    >   FETCH_DIM_W                                      $43     !2, !6
         66        ASSIGN_DIM                                               $43, !9
         67        OP_DATA                                                  !8
  144    68      > JMP                                                      ->40
         69    >   FE_FREE                                                  $29
  162    70      > JMP                                                      ->12
  165    71    >   TYPE_CHECK                                  256          !7
         72      > JMPZ                                                     ~45, ->86
  166    73    >   IS_SMALLER                                               0, !1
         74      > JMPZ                                                     ~46, ->83
  167    75    >   INIT_FCALL_BY_NAME                                       'entity2array'
         76        SEND_VAR_EX                                              !7
         77        SUB                                              ~48     !1, 1
         78        SEND_VAL_EX                                              ~48
         79        DO_FCALL                                      0  $49     
         80        ASSIGN_DIM                                               !2, !6
         81        OP_DATA                                                  $49
         82      > JMP                                                      ->85
  169    83    >   ASSIGN_DIM                                               !2, !6
         84        OP_DATA                                                  '%2A%2A%2A'
  171    85    > > JMP                                                      ->12
  174    86    >   ASSIGN_DIM                                               !2, !6
         87        OP_DATA                                                  !7
  137    88    > > JMP                                                      ->12
         89    >   FE_FREE                                                  $16
  177    90      > RETURN                                                   !2
  178    91*     > RETURN                                                   null

End of function entity2array

Class ReminderPushEvents:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bEiHO
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/bEiHO
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/bEiHO
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/bEiHO
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 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bEiHO
function name:  getTimestamp
number of ops:  9
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, ->6
   76     3    >   NEW                                              $2      'DateTimeImmutable'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   $2
   79     6    >   FETCH_OBJ_R                                      ~4      'timestamp'
          7      > RETURN                                                   ~4
   80     8*     > 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/bEiHO
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/bEiHO
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/bEiHO
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/bEiHO
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

End of class EventRequest.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.47 ms | 1419 KiB | 22 Q