3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait iaSplSubject { protected $iaSubjectTag = ''; protected $iaSubjectEvent = ''; protected $iaObserverQueue = []; public function get_iaSubjectTag() {return $this->iaSubjectTag;} public function set_iaSubjectTag($subjectTag) {$this->iaSubjectTag = $subjectTag;} public function get_iaSubjectEvent() {return $this->iaSubjectEvent;} public function set_iaSubjectEvent($subjectEvent) {$this->iaSubjectEvent->iaSubjectEvent;} public function attach(SplObserver $SplObserver) { $this->iaObserverQueue[spl_object_hash($SplObserver)] = [ count($this->iaObserverQueue), $SplObserver]; if(method_exists($SplObserver, 'get_priority')) { uasort($this->iaObserverQueue, array($this, 'iaObserverQueueCmp')); } } protected function iaObserverQueueCmp($a, $b) { if(method_exists($a[1], 'get_priority') && method_exists($b[1], 'get_priority') && $a[1]->get_priority() != $b[1]->get_priority()) { return $a->get_priority() - $b->get_priority(); } return $a[0] - $b[0]; } public function detach(SplObserver $SplObserver) { unset($this->iaObserverQueue[spl_object_hash($SplObserver)]); } public function notifyEvent($subjectEvent) { $this->set_iaSubjectEvent($subjectEvent); $this->notify(); $this->iaSubjectEvent = ''; } public function notify() { foreach($this->iaObserverQueue as $notify) { $notify[1]->update($this); } } } trait iaSplObserver { protected $iaSplObserverPriority = 1000; public function set_iaSplObserverPriority($priority) {$this->iaSplObserverPriority = $priority;} public function get_iaSplObserverPriority() {return $this->iaSplObserverPriority;} public function iaSplSubject_attach(SplSubject $SplSubject, $priority = 1000) { $this->set_iaSplObserverPriority($priority); $SplSubject->attach($this); } public function iaSplSubject_getTag(SplSubject $SplSubject) { return method_exists($SplSubject,'get_iaSubjectTag') ? $SplSubject->get_iaSubjectTag() : ''; } public function iaSplSubject_getEvent(SplSubject $SplSubject) { return method_exists($SplSubject,'get_iaSubjectEvent') ? $SplSubject->get_iaSubjectEvent() : ''; } } class veo implements SplObserver { use iaSplObserver; private $rata=1; public function dime() {echo "dice ".$this->rata;} public function update(SplSubject $SplSubject) { // $tag = $this->SplSubject_getTag(SplSubject $SplSubject); // $event = $this->$SplSubject->get_iaSubjectEvent(); } } class aviso implements SplSubject { use iaSplSubject; } $t = new veo(); $t->dime(); $a = new aviso();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GPCS5
function name:  (null)
number of ops:  11
compiled vars:  !0 = $t, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E >   DECLARE_CLASS                                            'veo'
   75     1        DECLARE_CLASS                                            'aviso'
   79     2        NEW                                              $2      'veo'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   80     5        INIT_METHOD_CALL                                         !0, 'dime'
          6        DO_FCALL                                      0          
   82     7        NEW                                              $6      'aviso'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !1, $6
         10      > RETURN                                                   1

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

End of function get_iasubjecttag

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

End of function set_iasubjecttag

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

End of function get_iasubjectevent

Function set_iasubjectevent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GPCS5
function name:  set_iaSubjectEvent
number of ops:  5
compiled vars:  !0 = $subjectEvent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        FETCH_OBJ_R                                      ~1      'iaSubjectEvent'
          2        FETCH_OBJ_R                                      ~2      ~1, 'iaSubjectEvent'
          3        FREE                                                     ~2
          4      > RETURN                                                   null

End of function set_iasubjectevent

Function attach:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 24
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/GPCS5
function name:  attach
number of ops:  25
compiled vars:  !0 = $SplObserver
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'spl_object_hash'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        FETCH_OBJ_R                                      ~4      'iaObserverQueue'
          5        COUNT                                            ~5      ~4
          6        INIT_ARRAY                                       ~6      ~5
          7        ADD_ARRAY_ELEMENT                                ~6      !0
          8        FETCH_OBJ_W                                      $1      'iaObserverQueue'
          9        ASSIGN_DIM                                               $1, $2
         10        OP_DATA                                                  ~6
   16    11        INIT_FCALL                                               'method_exists'
         12        SEND_VAR                                                 !0
         13        SEND_VAL                                                 'get_priority'
         14        DO_ICALL                                         $7      
         15      > JMPZ                                                     $7, ->24
   17    16    >   INIT_FCALL                                               'uasort'
         17        FETCH_OBJ_W                                      $8      'iaObserverQueue'
         18        SEND_REF                                                 $8
         19        FETCH_THIS                                       ~9      
         20        INIT_ARRAY                                       ~10     ~9
         21        ADD_ARRAY_ELEMENT                                ~10     'iaObserverQueueCmp'
         22        SEND_VAL                                                 ~10
         23        DO_ICALL                                                 
   19    24    > > RETURN                                                   null

End of function attach

Function iaobserverqueuecmp:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 23
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 30
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 14
filename:       /in/GPCS5
function name:  iaObserverQueueCmp
number of ops:  35
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   22     2        INIT_FCALL                                               'method_exists'
          3        FETCH_DIM_R                                      ~2      !0, 1
          4        SEND_VAL                                                 ~2
          5        SEND_VAL                                                 'get_priority'
          6        DO_ICALL                                         $3      
          7      > JMPZ_EX                                          ~4      $3, ->14
          8    >   INIT_FCALL                                               'method_exists'
          9        FETCH_DIM_R                                      ~5      !1, 1
         10        SEND_VAL                                                 ~5
         11        SEND_VAL                                                 'get_priority'
         12        DO_ICALL                                         $6      
         13        BOOL                                             ~4      $6
         14    > > JMPZ_EX                                          ~4      ~4, ->23
         15    >   FETCH_DIM_R                                      ~7      !0, 1
         16        INIT_METHOD_CALL                                         ~7, 'get_priority'
         17        DO_FCALL                                      0  $8      
         18        FETCH_DIM_R                                      ~9      !1, 1
         19        INIT_METHOD_CALL                                         ~9, 'get_priority'
         20        DO_FCALL                                      0  $10     
         21        IS_NOT_EQUAL                                     ~11     $8, $10
         22        BOOL                                             ~4      ~11
         23    > > JMPZ                                                     ~4, ->30
   23    24    >   INIT_METHOD_CALL                                         !0, 'get_priority'
         25        DO_FCALL                                      0  $12     
         26        INIT_METHOD_CALL                                         !1, 'get_priority'
         27        DO_FCALL                                      0  $13     
         28        SUB                                              ~14     $12, $13
         29      > RETURN                                                   ~14
   25    30    >   FETCH_DIM_R                                      ~15     !0, 0
         31        FETCH_DIM_R                                      ~16     !1, 0
         32        SUB                                              ~17     ~15, ~16
         33      > RETURN                                                   ~17
   26    34*     > RETURN                                                   null

End of function iaobserverqueuecmp

Function detach:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GPCS5
function name:  detach
number of ops:  7
compiled vars:  !0 = $SplObserver
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   29     1        INIT_FCALL                                               'spl_object_hash'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        FETCH_OBJ_UNSET                                  $1      'iaObserverQueue'
          5        UNSET_DIM                                                $1, $2
   30     6      > RETURN                                                   null

End of function detach

Function notifyevent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GPCS5
function name:  notifyEvent
number of ops:  9
compiled vars:  !0 = $subjectEvent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
   33     1        INIT_METHOD_CALL                                         'set_iaSubjectEvent'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   34     4        INIT_METHOD_CALL                                         'notify'
          5        DO_FCALL                                      0          
   35     6        ASSIGN_OBJ                                               'iaSubjectEvent'
          7        OP_DATA                                                  ''
   36     8      > RETURN                                                   null

End of function notifyevent

Function notify:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 9
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/GPCS5
function name:  notify
number of ops:  11
compiled vars:  !0 = $notify
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   FETCH_OBJ_R                                      ~1      'iaObserverQueue'
          1      > FE_RESET_R                                       $2      ~1, ->9
          2    > > FE_FETCH_R                                               $2, !0, ->9
   40     3    >   FETCH_DIM_R                                      ~3      !0, 1
          4        INIT_METHOD_CALL                                         ~3, 'update'
          5        FETCH_THIS                                       $4      
          6        SEND_VAR_EX                                              $4
          7        DO_FCALL                                      0          
   39     8      > JMP                                                      ->2
          9    >   FE_FREE                                                  $2
   42    10      > RETURN                                                   null

End of function notify

End of class iaSplSubject.

Class iaSplObserver:
Function set_iasplobserverpriority:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GPCS5
function name:  set_iaSplObserverPriority
number of ops:  4
compiled vars:  !0 = $priority
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ                                               'iaSplObserverPriority'
          2        OP_DATA                                                  !0
          3      > RETURN                                                   null

End of function set_iasplobserverpriority

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

End of function get_iasplobserverpriority

Function iasplsubject_attach:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GPCS5
function name:  iaSplSubject_attach
number of ops:  10
compiled vars:  !0 = $SplSubject, !1 = $priority
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      1000
   51     2        INIT_METHOD_CALL                                         'set_iaSplObserverPriority'
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0          
   52     5        INIT_METHOD_CALL                                         !0, 'attach'
          6        FETCH_THIS                                       $3      
          7        SEND_VAR_EX                                              $3
          8        DO_FCALL                                      0          
   53     9      > RETURN                                                   null

End of function iasplsubject_attach

Function iasplsubject_gettag:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GPCS5
function name:  iaSplSubject_getTag
number of ops:  13
compiled vars:  !0 = $SplSubject
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   RECV                                             !0      
   56     1        INIT_FCALL                                               'method_exists'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'get_iaSubjectTag'
          4        DO_ICALL                                         $1      
          5      > JMPZ                                                     $1, ->10
          6    >   INIT_METHOD_CALL                                         !0, 'get_iaSubjectTag'
          7        DO_FCALL                                      0  $2      
          8        QM_ASSIGN                                        ~3      $2
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~3      ''
         11    > > RETURN                                                   ~3
   57    12*     > RETURN                                                   null

End of function iasplsubject_gettag

Function iasplsubject_getevent:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GPCS5
function name:  iaSplSubject_getEvent
number of ops:  13
compiled vars:  !0 = $SplSubject
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   59     0  E >   RECV                                             !0      
   60     1        INIT_FCALL                                               'method_exists'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'get_iaSubjectEvent'
          4        DO_ICALL                                         $1      
          5      > JMPZ                                                     $1, ->10
          6    >   INIT_METHOD_CALL                                         !0, 'get_iaSubjectEvent'
          7        DO_FCALL                                      0  $2      
          8        QM_ASSIGN                                        ~3      $2
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~3      ''
         11    > > RETURN                                                   ~3
   61    12*     > RETURN                                                   null

End of function iasplsubject_getevent

End of class iaSplObserver.

Class veo:
Function dime:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GPCS5
function name:  dime
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   68     0  E >   FETCH_OBJ_R                                      ~0      'rata'
          1        CONCAT                                           ~1      'dice+', ~0
          2        ECHO                                                     ~1
          3      > RETURN                                                   null

End of function dime

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

End of function update

End of class veo.

Class aviso: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.5 ms | 1416 KiB | 19 Q