3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Student { private $classes; public function __construct($classes) { $this->classes = $classes; } public function getClasses() { return $this->classes; } public function combineClasses(Student $otherStudent) { $allClasses = array_unique(array_merge($this->classes, $otherStudent->classes)); $this->classes = $allClasses; $otherStudent->classes = $allClasses; } } $mary = new Student(['CompSci2001', 'CompSci2002']); $john = new Student(['CompSci2002', 'CompSci2003']); $mary->combineClasses($john); var_dump($mary->getClasses()); var_dump($john->getClasses());
based on 3nLfb
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/iGG8S
function name:  (null)
number of ops:  23
compiled vars:  !0 = $mary, !1 = $john
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  27     1        NEW                                              $3      :-6
         2        SEND_VAL_EX                                              <array>
         3        DO_FCALL                                      0          
         4        ASSIGN                                                   !0, $3
  28     5        NEW                                              $6      :-3
         6        SEND_VAL_EX                                              <array>
         7        DO_FCALL                                      0          
         8        ASSIGN                                                   !1, $6
  30     9        INIT_METHOD_CALL                                         !0, 'combineClasses'
        10        SEND_VAR_EX                                              !1
        11        DO_FCALL                                      0          
  32    12        INIT_FCALL                                               'var_dump'
        13        INIT_METHOD_CALL                                         !0, 'getClasses'
        14        DO_FCALL                                      0  $10     
        15        SEND_VAR                                                 $10
        16        DO_ICALL                                                 
  33    17        INIT_FCALL                                               'var_dump'
        18        INIT_METHOD_CALL                                         !1, 'getClasses'
        19        DO_FCALL                                      0  $12     
        20        SEND_VAR                                                 $12
        21        DO_ICALL                                                 
        22      > RETURN                                                   1

Class Student:
Function __construct:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/iGG8S
function name:  __construct
number of ops:  4
compiled vars:  !0 = $classes
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   7     0  E >   RECV                                             !0      
   9     1        ASSIGN_OBJ                                               'classes'
         2        OP_DATA                                                  !0
  10     3      > RETURN                                                   null

End of function __construct

Function getclasses:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/iGG8S
function name:  getClasses
number of ops:  3
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  14     0  E >   FETCH_OBJ_R                                      $0      'classes'
         1      > RETURN                                                   $0
  15     2*     > RETURN                                                   null

End of function getclasses

Function combineclasses:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/iGG8S
function name:  combineClasses
number of ops:  16
compiled vars:  !0 = $otherStudent, !1 = $allClasses
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  17     0  E >   RECV                                             !0      
  19     1        INIT_FCALL                                               'array_unique'
         2        INIT_FCALL                                               'array_merge'
         3        FETCH_OBJ_R                                      $2      'classes'
         4        SEND_VAR                                                 $2
         5        FETCH_OBJ_R                                      $3      !0, 'classes'
         6        SEND_VAR                                                 $3
         7        DO_ICALL                                         $4      
         8        SEND_VAR                                                 $4
         9        DO_ICALL                                         $5      
        10        ASSIGN                                                   !1, $5
  21    11        ASSIGN_OBJ                                               'classes'
        12        OP_DATA                                                  !1
  22    13        ASSIGN_OBJ                                               !0, 'classes'
        14        OP_DATA                                                  !1
  23    15      > RETURN                                                   null

End of function combineclasses

End of class Student.

Generated using Vulcan Logic Dumper, using php 7.1.0