3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); class Company { public $companyName; public $companyDepartments = []; public $companySalary; public function __construct($companyName, $companyDepartments) { $this->companyName = $companyName; $this->companyDepartments = $companyDepartments; } public function createDepartment($departmentName) { return new $departmentName; } /*public function getCompanySalary($departments) { foreach ($departments as $department) { $result += $department->getDepartmentSalary(); } return $result; }*/ } class Department { public $departmentName; public $employees = []; public function __construct($departmentName) { $this->departmentName = $departmentName; } public function setDepartmentEmployees($departmentName, $department) { $this->departmentName = $departmentName; $employees[] = 0; for ($i = 1; $i < count($department) - 1; $i++) { $employees[] = $department[$i][$i - 1]; $department->employees = $employees; } } public function getDepartmentSalary($department) { return $department->getDepartmentSalary(); } } class Profession { public $professionName; public $coffee; public $pages; public $salary; public function __construct($professionName) { $this->professionName = $professionName; } public function setCoffee($boss) { switch($this->professionName){ case 'Man': $this->coffee = 20; break; case 'Mar': $this->coffee = 15; break; case 'Eng': $this->coffee = 5; break; case 'Ana': $this->coffee = 50; break; } if ($boss == true) { return $this->coffee * 2; } else { return $this->coffee; } } public function setPages($boss) { switch($this->professionName){ case 'Man': $this->pages = 200; break; case 'Mar': $this->pages = 150; break; case 'Eng': $this->pages = 50; break; case 'Ana': $this->pages = 5; break; } if ($boss == true) { return $this->pages = 0; } else { return $this->pages; } } public function setSalary($boss) { switch($this->professionName){ case 'Man': $this->salary = 500; break; case 'Mar': $this->salary = 400; break; case 'Eng': $this->salary = 200; break; case 'Ana': $this->salary = 800; break; } if ($boss == true) { return $this->salary * 1.5; } else { return $this->salary; } } } $departments = []; $purchaseDepartment = ['Name' => 'Purchase', 'man1' => 9, 'man2' => 3, 'man3' => 2, 'mar1' => 2, 'boss' => 'man2']; $departments[] = $purchaseDepartment; $saleDepartment = ['Name' => 'Sale', 'man1' => 12, 'mar1' => 6, 'ana1' => 3, 'ana2' => 2, 'boss' => 'mar2']; $departments[] = $saleDepartment; $advertisingDepartment = ['Name' => 'Advertising', 'mar1' => 15, 'mar2' => 10, 'man1' => 8, 'eng1' => 2, 'boss' => 'mar3']; $departments[] = $advertisingDepartment; $logisticsDepartment = ['Name' => 'Logistics', 'man1' => 13, 'man2' => 5, 'eng1' => 5, 'boss' => 'man1']; $departments[] = $logisticsDepartment; function createEmployees($departments) { } $vector = new Company('Vector', $departments); foreach ($departments as $department) { $vector->createDepartment($department['Name']); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 29
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 29
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/pF6Mm
function name:  (null)
number of ops:  31
compiled vars:  !0 = $departments, !1 = $purchaseDepartment, !2 = $saleDepartment, !3 = $advertisingDepartment, !4 = $logisticsDepartment, !5 = $vector, !6 = $department
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 -1
          2        DO_ICALL                                                 
  121     3        ASSIGN                                                   !0, <array>
  122     4        ASSIGN                                                   !1, <array>
  123     5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  !1
  124     7        ASSIGN                                                   !2, <array>
  125     8        ASSIGN_DIM                                               !0
          9        OP_DATA                                                  !2
  126    10        ASSIGN                                                   !3, <array>
  127    11        ASSIGN_DIM                                               !0
         12        OP_DATA                                                  !3
  128    13        ASSIGN                                                   !4, <array>
  129    14        ASSIGN_DIM                                               !0
         15        OP_DATA                                                  !4
  133    16        NEW                                              $17     'Company'
         17        SEND_VAL_EX                                              'Vector'
         18        SEND_VAR_EX                                              !0
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !5, $17
  134    21      > FE_RESET_R                                       $20     !0, ->29
         22    > > FE_FETCH_R                                               $20, !6, ->29
  135    23    >   INIT_METHOD_CALL                                         !5, 'createDepartment'
         24        CHECK_FUNC_ARG                                           
         25        FETCH_DIM_FUNC_ARG                               $21     !6, 'Name'
         26        SEND_FUNC_ARG                                            $21
         27        DO_FCALL                                      0          
  134    28      > JMP                                                      ->22
         29    >   FE_FREE                                                  $20
  136    30      > RETURN                                                   1

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

End of function createemployees

Class Company:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pF6Mm
function name:  __construct
number of ops:  7
compiled vars:  !0 = $companyName, !1 = $companyDepartments
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        ASSIGN_OBJ                                               'companyName'
          3        OP_DATA                                                  !0
   13     4        ASSIGN_OBJ                                               'companyDepartments'
          5        OP_DATA                                                  !1
   14     6      > RETURN                                                   null

End of function __construct

Function createdepartment:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pF6Mm
function name:  createDepartment
number of ops:  6
compiled vars:  !0 = $departmentName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        FETCH_CLASS                                   0  $1      !0
          2        NEW                                              $2      $1
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $2
   17     5*     > RETURN                                                   null

End of function createdepartment

End of class Company.

Class Department:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pF6Mm
function name:  __construct
number of ops:  4
compiled vars:  !0 = $departmentName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1        ASSIGN_OBJ                                               'departmentName'
          2        OP_DATA                                                  !0
   32     3      > RETURN                                                   null

End of function __construct

Function setdepartmentemployees:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 8
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 8
Branch analysis from position: 20
Branch analysis from position: 8
filename:       /in/pF6Mm
function name:  setDepartmentEmployees
number of ops:  21
compiled vars:  !0 = $departmentName, !1 = $department, !2 = $employees, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   35     2        ASSIGN_OBJ                                               'departmentName'
          3        OP_DATA                                                  !0
   36     4        ASSIGN_DIM                                               !2
          5        OP_DATA                                                  0
   37     6        ASSIGN                                                   !3, 1
          7      > JMP                                                      ->16
   38     8    >   SUB                                              ~9      !3, 1
          9        FETCH_DIM_R                                      ~8      !1, !3
         10        FETCH_DIM_R                                      ~10     ~8, ~9
         11        ASSIGN_DIM                                               !2
         12        OP_DATA                                                  ~10
   39    13        ASSIGN_OBJ                                               !1, 'employees'
         14        OP_DATA                                                  !2
   37    15        PRE_INC                                                  !3
         16    >   COUNT                                            ~13     !1
         17        SUB                                              ~14     ~13, 1
         18        IS_SMALLER                                               !3, ~14
         19      > JMPNZ                                                    ~15, ->8
   41    20    > > RETURN                                                   null

End of function setdepartmentemployees

Function getdepartmentsalary:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pF6Mm
function name:  getDepartmentSalary
number of ops:  5
compiled vars:  !0 = $department
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV                                             !0      
   43     1        INIT_METHOD_CALL                                         !0, 'getDepartmentSalary'
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
   44     4*     > RETURN                                                   null

End of function getdepartmentsalary

End of class Department.

Class Profession:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pF6Mm
function name:  __construct
number of ops:  4
compiled vars:  !0 = $professionName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV                                             !0      
   55     1        ASSIGN_OBJ                                               'professionName'
          2        OP_DATA                                                  !0
   56     3      > RETURN                                                   null

End of function __construct

Function setcoffee:
Finding entry points
Branch analysis from position: 0
6 jumps found. (Code = 188) Position 1 = 12, Position 2 = 15, Position 3 = 18, Position 4 = 21, Position 5 = 24, Position 6 = 3
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 24
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 21
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 21
Branch analysis from position: 18
Branch analysis from position: 15
Branch analysis from position: 12
filename:       /in/pF6Mm
function name:  setCoffee
number of ops:  34
compiled vars:  !0 = $boss
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   RECV                                             !0      
   58     1        FETCH_OBJ_R                                      ~1      'professionName'
          2      > SWITCH_STRING                                            ~1, [ 'Man':->12, 'Mar':->15, 'Eng':->18, 'Ana':->21, ], ->24
   59     3    >   CASE                                                     ~1, 'Man'
          4      > JMPNZ                                                    ~2, ->12
   62     5    >   CASE                                                     ~1, 'Mar'
          6      > JMPNZ                                                    ~2, ->15
   65     7    >   CASE                                                     ~1, 'Eng'
          8      > JMPNZ                                                    ~2, ->18
   68     9    >   CASE                                                     ~1, 'Ana'
         10      > JMPNZ                                                    ~2, ->21
         11    > > JMP                                                      ->24
   60    12    >   ASSIGN_OBJ                                               'coffee'
         13        OP_DATA                                                  20
   61    14      > JMP                                                      ->24
   63    15    >   ASSIGN_OBJ                                               'coffee'
         16        OP_DATA                                                  15
   64    17      > JMP                                                      ->24
   66    18    >   ASSIGN_OBJ                                               'coffee'
         19        OP_DATA                                                  5
   67    20      > JMP                                                      ->24
   69    21    >   ASSIGN_OBJ                                               'coffee'
         22        OP_DATA                                                  50
   70    23      > JMP                                                      ->24
         24    >   FREE                                                     ~1
   72    25        BOOL                                             ~7      !0
         26      > JMPZ                                                     ~7, ->31
   73    27    >   FETCH_OBJ_R                                      ~8      'coffee'
         28        MUL                                              ~9      ~8, 2
         29      > RETURN                                                   ~9
   72    30*       JMP                                                      ->33
   75    31    >   FETCH_OBJ_R                                      ~10     'coffee'
         32      > RETURN                                                   ~10
   77    33*     > RETURN                                                   null

End of function setcoffee

Function setpages:
Finding entry points
Branch analysis from position: 0
6 jumps found. (Code = 188) Position 1 = 12, Position 2 = 15, Position 3 = 18, Position 4 = 21, Position 5 = 24, Position 6 = 3
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 24
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 21
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 21
Branch analysis from position: 18
Branch analysis from position: 15
Branch analysis from position: 12
filename:       /in/pF6Mm
function name:  setPages
number of ops:  34
compiled vars:  !0 = $boss
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   78     0  E >   RECV                                             !0      
   79     1        FETCH_OBJ_R                                      ~1      'professionName'
          2      > SWITCH_STRING                                            ~1, [ 'Man':->12, 'Mar':->15, 'Eng':->18, 'Ana':->21, ], ->24
   80     3    >   CASE                                                     ~1, 'Man'
          4      > JMPNZ                                                    ~2, ->12
   83     5    >   CASE                                                     ~1, 'Mar'
          6      > JMPNZ                                                    ~2, ->15
   86     7    >   CASE                                                     ~1, 'Eng'
          8      > JMPNZ                                                    ~2, ->18
   89     9    >   CASE                                                     ~1, 'Ana'
         10      > JMPNZ                                                    ~2, ->21
         11    > > JMP                                                      ->24
   81    12    >   ASSIGN_OBJ                                               'pages'
         13        OP_DATA                                                  200
   82    14      > JMP                                                      ->24
   84    15    >   ASSIGN_OBJ                                               'pages'
         16        OP_DATA                                                  150
   85    17      > JMP                                                      ->24
   87    18    >   ASSIGN_OBJ                                               'pages'
         19        OP_DATA                                                  50
   88    20      > JMP                                                      ->24
   90    21    >   ASSIGN_OBJ                                               'pages'
         22        OP_DATA                                                  5
   91    23      > JMP                                                      ->24
         24    >   FREE                                                     ~1
   93    25        BOOL                                             ~7      !0
         26      > JMPZ                                                     ~7, ->31
   94    27    >   ASSIGN_OBJ                                       ~8      'pages'
         28        OP_DATA                                                  0
         29      > RETURN                                                   ~8
   93    30*       JMP                                                      ->33
   96    31    >   FETCH_OBJ_R                                      ~9      'pages'
         32      > RETURN                                                   ~9
   98    33*     > RETURN                                                   null

End of function setpages

Function setsalary:
Finding entry points
Branch analysis from position: 0
6 jumps found. (Code = 188) Position 1 = 12, Position 2 = 15, Position 3 = 18, Position 4 = 21, Position 5 = 24, Position 6 = 3
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 24
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 21
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 21
Branch analysis from position: 18
Branch analysis from position: 15
Branch analysis from position: 12
filename:       /in/pF6Mm
function name:  setSalary
number of ops:  34
compiled vars:  !0 = $boss
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   99     0  E >   RECV                                             !0      
  100     1        FETCH_OBJ_R                                      ~1      'professionName'
          2      > SWITCH_STRING                                            ~1, [ 'Man':->12, 'Mar':->15, 'Eng':->18, 'Ana':->21, ], ->24
  101     3    >   CASE                                                     ~1, 'Man'
          4      > JMPNZ                                                    ~2, ->12
  104     5    >   CASE                                                     ~1, 'Mar'
          6      > JMPNZ                                                    ~2, ->15
  107     7    >   CASE                                                     ~1, 'Eng'
          8      > JMPNZ                                                    ~2, ->18
  110     9    >   CASE                                                     ~1, 'Ana'
         10      > JMPNZ                                                    ~2, ->21
         11    > > JMP                                                      ->24
  102    12    >   ASSIGN_OBJ                                               'salary'
         13        OP_DATA                                                  500
  103    14      > JMP                                                      ->24
  105    15    >   ASSIGN_OBJ                                               'salary'
         16        OP_DATA                                                  400
  106    17      > JMP                                                      ->24
  108    18    >   ASSIGN_OBJ                                               'salary'
         19        OP_DATA                                                  200
  109    20      > JMP                                                      ->24
  111    21    >   ASSIGN_OBJ                                               'salary'
         22        OP_DATA                                                  800
  112    23      > JMP                                                      ->24
         24    >   FREE                                                     ~1
  114    25        BOOL                                             ~7      !0
         26      > JMPZ                                                     ~7, ->31
  115    27    >   FETCH_OBJ_R                                      ~8      'salary'
         28        MUL                                              ~9      ~8, 1.5
         29      > RETURN                                                   ~9
  114    30*       JMP                                                      ->33
  117    31    >   FETCH_OBJ_R                                      ~10     'salary'
         32      > RETURN                                                   ~10
  119    33*     > RETURN                                                   null

End of function setsalary

End of class Profession.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
243.96 ms | 1027 KiB | 14 Q