3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Profile { private $active = false; public function activate() { $this->active = true; } public function isActive() { return $this->active; } } interface Event { function execute($object); } class ProfileWasActivated implements Event { public function execute($profile) { if(!($profile instanceof Profile2)) { throw new \InvalidArgumentException('Only Profiles allowed!'); } $profile->activate(); } } class EventDomainObjectLoader { public static function load($object, array $events) { foreach($events as $event) { if(!($event instanceof Event)) { throw new \InvalidArgumentException('Only Events allowed!'); } $event->execute($object); } return $object; } } $profile = EventDomainObjectLoader::load(new Profile(), [new ProfileWasActivated()]); var_dump($profile->isActive());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cOmgN
function name:  (null)
number of ops:  17
compiled vars:  !0 = $profile
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   DECLARE_CLASS                                            'profilewasactivated'
   41     1        INIT_STATIC_METHOD_CALL                                  'EventDomainObjectLoader', 'load'
          2        NEW                                              $1      'Profile'
          3        DO_FCALL                                      0          
          4        SEND_VAR                                                 $1
          5        NEW                                              $3      'ProfileWasActivated'
          6        DO_FCALL                                      0          
          7        INIT_ARRAY                                       ~5      $3
          8        SEND_VAL                                                 ~5
          9        DO_FCALL                                      0  $6      
         10        ASSIGN                                                   !0, $6
   42    11        INIT_FCALL                                               'var_dump'
         12        INIT_METHOD_CALL                                         !0, 'isActive'
         13        DO_FCALL                                      0  $8      
         14        SEND_VAR                                                 $8
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Class Profile:
Function activate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cOmgN
function name:  activate
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN_OBJ                                               'active'
          1        OP_DATA                                                  <true>
    8     2      > RETURN                                                   null

End of function activate

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

End of function isactive

End of class Profile.

Class Event:
Function execute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cOmgN
function name:  execute
number of ops:  2
compiled vars:  !0 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function execute

End of class Event.

Class ProfileWasActivated:
Function execute:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cOmgN
function name:  execute
number of ops:  11
compiled vars:  !0 = $profile
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        INSTANCEOF                                       ~1      !0, 'Profile2'
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->8
   22     4    >   NEW                                              $3      'InvalidArgumentException'
          5        SEND_VAL_EX                                              'Only+Profiles+allowed%21'
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $3
   25     8    >   INIT_METHOD_CALL                                         !0, 'activate'
          9        DO_FCALL                                      0          
   26    10      > RETURN                                                   null

End of function execute

End of class ProfileWasActivated.

Class EventDomainObjectLoader:
Function load:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/cOmgN
function name:  load
number of ops:  18
compiled vars:  !0 = $object, !1 = $events, !2 = $event
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   31     2      > FE_RESET_R                                       $3      !1, ->15
          3    > > FE_FETCH_R                                               $3, !2, ->15
   32     4    >   INSTANCEOF                                       ~4      !2, 'Event'
          5        BOOL_NOT                                         ~5      ~4
          6      > JMPZ                                                     ~5, ->11
   33     7    >   NEW                                              $6      'InvalidArgumentException'
          8        SEND_VAL_EX                                              'Only+Events+allowed%21'
          9        DO_FCALL                                      0          
         10      > THROW                                         0          $6
   35    11    >   INIT_METHOD_CALL                                         !2, 'execute'
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0          
   31    14      > JMP                                                      ->3
         15    >   FE_FREE                                                  $3
   37    16      > RETURN                                                   !0
   38    17*     > RETURN                                                   null

End of function load

End of class EventDomainObjectLoader.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.11 ms | 1400 KiB | 15 Q