3v4l.org

run code in 200+ PHP versions simultaneously
<?php interface Employee {} class SteelFactoryEmployee implements Employee {} class CarsFactoryEmployee implements Employee {} interface Factory { public function hire(Employee $employee): bool; } class SteelFactory implements Factory { public function hire(Employee $employee): bool { if (! $employee instanceof SteelFactoryEmployee) { throw new InvalidArgumentException('Employee should be ' . SteelFactoryEmployee::class); } return true; } } class CarsFactory implements Factory { public function hire(Employee $employee): bool { if (! $employee instanceof CarsFactoryEmployee) { throw new InvalidArgumentException('Employee should be ' . CarsFactoryEmployee::class); } return true; } } class EmploymentDepartment { public function hireNewEmployee(Factory $factory, Employee $employee): void { $factory->hire($employee); } } $someNewEmployee = new SteelFactoryEmployee(); $someFactory = new SteelFactory(); $employmentDepartment = new EmploymentDepartment(); $employmentDepartment->hireNewEmployee($someFactory, $someNewEmployee);
based on ajgqR
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gq0vC
function name:  (null)
number of ops:  18
compiled vars:  !0 = $someNewEmployee, !1 = $someFactory, !2 = $employmentDepartment
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   5     0  E >   ADD_INTERFACE                                            'steelfactoryemployee'
   6     1        ADD_INTERFACE                                            'carsfactoryemployee'
  13     2        ADD_INTERFACE                                            'steelfactory'
  25     3        ADD_INTERFACE                                            'carsfactory'
  45     4        NEW                                              $3      :31
         5        DO_FCALL                                      0          
         6        QM_ASSIGN                                                !0
  46     7        NEW                                              $6      :27
         8        DO_FCALL                                      0          
         9        QM_ASSIGN                                                !1
  48    10        NEW                                              $9      :23
        11        DO_FCALL                                      0          
        12        QM_ASSIGN                                                !2
  49    13        INIT_METHOD_CALL                                         !2, 'hireNewEmployee'
        14        SEND_VAR_EX                                              !1
        15        SEND_VAR_EX                                              !0
        16        DO_FCALL                                      0          
        17      > RETURN                                                   1

Class Employee: [no user functions]
Class SteelFactoryEmployee: [no user functions]
Class CarsFactoryEmployee: [no user functions]
Class Factory:
Function hire:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gq0vC
function name:  hire
number of ops:  3
compiled vars:  !0 = $employee
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  10     0  E >   RECV                                             !0      
         1        VERIFY_RETURN_TYPE                                       
         2      > RETURN                                                   null

End of function hire

End of class Factory.

Class SteelFactory:
Function hire:
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/Gq0vC
function name:  hire
number of ops:  11
compiled vars:  !0 = $employee
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  15     0  E >   RECV                                             !0      
  17     1        INSTANCEOF                                       ~1      !0, 'SteelFactoryEmployee'
         2        BOOL_XOR                                         ~2      ~1
         3      > JMPZ                                                     ~2, ->8
  18     4    >   NEW                                              $3      :11
         5        SEND_VAL_EX                                              'Employee+should+be+SteelFactoryEmployee'
         6        DO_FCALL                                      0          
         7      > THROW                                         0          $3
  21     8    > > RETURN                                                   <true>
  22     9*       VERIFY_RETURN_TYPE                                       
        10*     > RETURN                                                   null

End of function hire

End of class SteelFactory.

Class CarsFactory:
Function hire:
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/Gq0vC
function name:  hire
number of ops:  11
compiled vars:  !0 = $employee
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  27     0  E >   RECV                                             !0      
  29     1        INSTANCEOF                                       ~1      !0, 'CarsFactoryEmployee'
         2        BOOL_XOR                                         ~2      ~1
         3      > JMPZ                                                     ~2, ->8
  30     4    >   NEW                                              $3      :11
         5        SEND_VAL_EX                                              'Employee+should+be+CarsFactoryEmployee'
         6        DO_FCALL                                      0          
         7      > THROW                                         0          $3
  33     8    > > RETURN                                                   <true>
  34     9*       VERIFY_RETURN_TYPE                                       
        10*     > RETURN                                                   null

End of function hire

End of class CarsFactory.

Class EmploymentDepartment:
Function hirenewemployee:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gq0vC
function name:  hireNewEmployee
number of ops:  6
compiled vars:  !0 = $factory, !1 = $employee
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  39     0  E >   RECV                                             !0      
         1        RECV                                             !1      
  41     2        INIT_METHOD_CALL                                         !0, 'hire'
         3        SEND_VAR_EX                                              !1
         4        DO_FCALL                                      0          
  42     5      > RETURN                                                   null

End of function hirenewemployee

End of class EmploymentDepartment.

Generated using Vulcan Logic Dumper, using php 7.4.0