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 Gq0vC
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t01Ir
function name:  (null)
number of ops:  29
compiled vars:  !0 = $someNewEmployee, !1 = $someFactory, !2 = $employmentDepartment
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
   5     1        DECLARE_CLASS                                    $4      'steelfactoryemployee'
         2        ADD_INTERFACE                                            $4, 'Employee'
         3        VERIFY_ABSTRACT_CLASS                                    $4
   6     4        DECLARE_CLASS                                    $5      'carsfactoryemployee'
         5        ADD_INTERFACE                                            $5, 'Employee'
         6        VERIFY_ABSTRACT_CLASS                                    $5
   8     7        NOP                                                      
  13     8        DECLARE_CLASS                                    $7      'steelfactory'
         9        ADD_INTERFACE                                            $7, 'Factory'
        10        VERIFY_ABSTRACT_CLASS                                    $7
  25    11        DECLARE_CLASS                                    $8      'carsfactory'
        12        ADD_INTERFACE                                            $8, 'Factory'
        13        VERIFY_ABSTRACT_CLASS                                    $8
  37    14        NOP                                                      
  45    15        NEW                                              $10     :39
        16        DO_FCALL                                      0          
        17        ASSIGN                                                   !0, $10
  46    18        NEW                                              $13     :35
        19        DO_FCALL                                      0          
        20        ASSIGN                                                   !1, $13
  48    21        NEW                                              $16     :31
        22        DO_FCALL                                      0          
        23        ASSIGN                                                   !2, $16
  49    24        INIT_METHOD_CALL                                         !2, 'hireNewEmployee'
        25        SEND_VAR_EX                                              !1
        26        SEND_VAR_EX                                              !0
        27        DO_FCALL                                      0          
        28      > 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/t01Ir
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/t01Ir
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_NOT                                         ~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/t01Ir
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_NOT                                         ~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/t01Ir
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.3.0