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_object($value)) { if ($recursionDepth > 0) { $result[$propertyName] = $this->entity2array($value, $recursionDepth - 1); } else { $result[$propertyName] = "***"; //stop recursion } } else { $result[$propertyName] = $value; } } } return $result; } $foo = new Foo('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/HtVhM
function name:  (null)
number of ops:  20
compiled vars:  !0 = $foo, !1 = $event
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  157     0  E >   NEW                                              $2      'Foo'
          1        SEND_VAL_EX                                              'crm_newsletter'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
  160     4        NEW                                              $5      'ReminderPushEvents'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
  161     7        INIT_METHOD_CALL                                         !1, 'addProperties'
          8        SEND_VAL_EX                                              <array>
          9        DO_FCALL                                      0          
  162    10        INIT_METHOD_CALL                                         !0, 'addEvents'
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0          
  164    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 = 56
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 56
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 = 55
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 53
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 50
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 55
Branch analysis from position: 24
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
filename:       /in/HtVhM
function name:  entity2array
number of ops:  59
compiled vars:  !0 = $entity, !1 = $recursionDepth, !2 = $result, !3 = $class, !4 = $method, !5 = $methodName, !6 = $propertyName, !7 = $value
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                                              $9      'ReflectionClass'
          4        GET_CLASS                                        ~10     !0
          5        SEND_VAL_EX                                              ~10
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !3, $9
  137     8        INIT_METHOD_CALL                                         !3, 'getMethods'
          9        SEND_VAL_EX                                              1
         10        DO_FCALL                                      0  $13     
         11      > FE_RESET_R                                       $14     $13, ->56
         12    > > FE_FETCH_R                                               $14, !4, ->56
  138    13    >   FETCH_OBJ_R                                      ~15     !4, 'name'
         14        ASSIGN                                                   !5, ~15
  139    15        INIT_FCALL                                               'strpos'
         16        SEND_VAR                                                 !5
         17        SEND_VAL                                                 'get'
         18        DO_ICALL                                         $17     
         19        IS_IDENTICAL                                     ~18     $17, 0
         20      > JMPZ_EX                                          ~18     ~18, ->24
         21    >   STRLEN                                           ~19     !5
         22        IS_SMALLER                                       ~20     3, ~19
         23        BOOL                                             ~18     ~20
         24    > > JMPZ                                                     ~18, ->55
  140    25    >   INIT_FCALL                                               'lcfirst'
         26        INIT_FCALL                                               'substr'
         27        SEND_VAR                                                 !5
         28        SEND_VAL                                                 3
         29        DO_ICALL                                         $21     
         30        SEND_VAR                                                 $21
         31        DO_ICALL                                         $22     
         32        ASSIGN                                                   !6, $22
  141    33        INIT_METHOD_CALL                                         !4, 'invoke'
         34        SEND_VAR_EX                                              !0
         35        DO_FCALL                                      0  $24     
         36        ASSIGN                                                   !7, $24
  143    37        TYPE_CHECK                                  256          !7
         38      > JMPZ                                                     ~26, ->53
  144    39    >   IS_SMALLER                                               0, !1
         40      > JMPZ                                                     ~27, ->50
  145    41    >   FETCH_THIS                                       $29     
         42        INIT_METHOD_CALL                                         $29, 'entity2array'
         43        SEND_VAR_EX                                              !7
         44        SUB                                              ~30     !1, 1
         45        SEND_VAL_EX                                              ~30
         46        DO_FCALL                                      0  $31     
         47        ASSIGN_DIM                                               !2, !6
         48        OP_DATA                                                  $31
         49      > JMP                                                      ->52
  147    50    >   ASSIGN_DIM                                               !2, !6
         51        OP_DATA                                                  '%2A%2A%2A'
         52    > > JMP                                                      ->55
  150    53    >   ASSIGN_DIM                                               !2, !6
         54        OP_DATA                                                  !7
  137    55    > > JMP                                                      ->12
         56    >   FE_FREE                                                  $14
  154    57      > RETURN                                                   !2
  155    58*     > 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/HtVhM
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/HtVhM
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/HtVhM
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/HtVhM
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/HtVhM
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/HtVhM
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/HtVhM
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/HtVhM
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/HtVhM
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:
184.75 ms | 1415 KiB | 22 Q