3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface ToolSetFactory { public function createGeneral(): General; public function createArrows(): Arrows; public function createFlowchart(): Flowchart; public function createUML(): UML; public function createEntityRelation(): EntityRelation; public function createMisc(): Misc; } class BasicToolSetFactory implements ToolSetFactory { public function createGeneral(): General { return new GeneralProduct(); } public function createArrows(): Arrows { return new ArrowsProduct(); } public function createFlowchart(): Flowchart { return new NullFlowchartProduct(); } public function createUML(): UML { return new NullUMLProduct(); } public function createEntityRelation(): EntityRelation { return new NullEntityRelationProduct(); } public function createMisc(): Misc { return new MiscProduct(); } } // Interfaces interface Drawable { public function draw(): void; } interface General extends Drawable {} interface Arrows extends Drawable {} interface Flowchart extends Drawable {} interface UML extends Drawable {} interface EntityRelation extends Drawable {} interface Misc extends Drawable {} // Products class GeneralProduct implements General { public function draw(): void { print "Drawing general elements\n"; } // Other methods } class ArrowsProduct implements Arrows { public function draw(): void { print "Drawing arrows elements\n"; } // Other methods } class MiscProduct implements Misc { public function draw(): void { print "Drawing misc elements\n"; } // Other methods } class NullFlowchartProduct implements Flowchart { public function draw(): void { print ''; } // Other methods } class NullUMLProduct implements UML { public function draw(): void { print ''; } // Other methods } class NullEntityRelationProduct implements EntityRelation { public function draw(): void { print ''; } // Other methods } // Client code class BasicToolSet { public function createToolSet(ToolSetFactory $factory) { $general = $factory->createGeneral(); $arrows = $factory->createArrows(); $misc = $factory->createMisc(); foreach ([ $general, $arrows, $misc ] as $product) { $product->draw(); } } // other stuff } // Usage $basicToolSetFactory = new BasicToolSetFactory(); $basicToolSet = new BasicToolSet(); $basicToolSet->createToolSet($basicToolSetFactory);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  (null)
number of ops:  23
compiled vars:  !0 = $basicToolSetFactory, !1 = $basicToolSet
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   DECLARE_CLASS                                            'basictoolsetfactory'
   58     1        DECLARE_CLASS                                            'general'
   60     2        DECLARE_CLASS                                            'arrows'
   62     3        DECLARE_CLASS                                            'flowchart'
   64     4        DECLARE_CLASS                                            'uml'
   66     5        DECLARE_CLASS                                            'entityrelation'
   68     6        DECLARE_CLASS                                            'misc'
   72     7        DECLARE_CLASS                                            'generalproduct'
   82     8        DECLARE_CLASS                                            'arrowsproduct'
   92     9        DECLARE_CLASS                                            'miscproduct'
  102    10        DECLARE_CLASS                                            'nullflowchartproduct'
  112    11        DECLARE_CLASS                                            'nullumlproduct'
  122    12        DECLARE_CLASS                                            'nullentityrelationproduct'
  154    13        NEW                                              $2      'BasicToolSetFactory'
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !0, $2
  156    16        NEW                                              $5      'BasicToolSet'
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !1, $5
  157    19        INIT_METHOD_CALL                                         !1, 'createToolSet'
         20        SEND_VAR_EX                                              !0
         21        DO_FCALL                                      0          
         22      > RETURN                                                   1

Class ToolSetFactory:
Function creategeneral:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  createGeneral
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   VERIFY_RETURN_TYPE                                       
          1      > RETURN                                                   null

End of function creategeneral

Function createarrows:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  createArrows
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   VERIFY_RETURN_TYPE                                       
          1      > RETURN                                                   null

End of function createarrows

Function createflowchart:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  createFlowchart
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   VERIFY_RETURN_TYPE                                       
          1      > RETURN                                                   null

End of function createflowchart

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

End of function createuml

Function createentityrelation:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  createEntityRelation
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   VERIFY_RETURN_TYPE                                       
          1      > RETURN                                                   null

End of function createentityrelation

Function createmisc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  createMisc
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   VERIFY_RETURN_TYPE                                       
          1      > RETURN                                                   null

End of function createmisc

End of class ToolSetFactory.

Class BasicToolSetFactory:
Function creategeneral:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  createGeneral
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $0      'GeneralProduct'
          1        DO_FCALL                                      0          
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
   23     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function creategeneral

Function createarrows:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  createArrows
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   NEW                                              $0      'ArrowsProduct'
          1        DO_FCALL                                      0          
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
   28     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function createarrows

Function createflowchart:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  createFlowchart
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $0      'NullFlowchartProduct'
          1        DO_FCALL                                      0          
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
   33     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function createflowchart

Function createuml:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  createUML
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   NEW                                              $0      'NullUMLProduct'
          1        DO_FCALL                                      0          
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
   38     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function createuml

Function createentityrelation:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  createEntityRelation
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   NEW                                              $0      'NullEntityRelationProduct'
          1        DO_FCALL                                      0          
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
   43     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function createentityrelation

Function createmisc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  createMisc
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   NEW                                              $0      'MiscProduct'
          1        DO_FCALL                                      0          
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
   48     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function createmisc

End of class BasicToolSetFactory.

Class Drawable:
Function draw:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  draw
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E > > RETURN                                                   null

End of function draw

End of class Drawable.

Class General: [no user functions]
Class Arrows: [no user functions]
Class Flowchart: [no user functions]
Class UML: [no user functions]
Class EntityRelation: [no user functions]
Class Misc: [no user functions]
Class GeneralProduct:
Function draw:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  draw
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   76     0  E >   ECHO                                                     'Drawing+general+elements%0A'
   77     1      > RETURN                                                   null

End of function draw

End of class GeneralProduct.

Class ArrowsProduct:
Function draw:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  draw
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   86     0  E >   ECHO                                                     'Drawing+arrows+elements%0A'
   87     1      > RETURN                                                   null

End of function draw

End of class ArrowsProduct.

Class MiscProduct:
Function draw:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  draw
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   96     0  E >   ECHO                                                     'Drawing+misc+elements%0A'
   97     1      > RETURN                                                   null

End of function draw

End of class MiscProduct.

Class NullFlowchartProduct:
Function draw:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  draw
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  106     0  E >   ECHO                                                     ''
  107     1      > RETURN                                                   null

End of function draw

End of class NullFlowchartProduct.

Class NullUMLProduct:
Function draw:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  draw
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  116     0  E >   ECHO                                                     ''
  117     1      > RETURN                                                   null

End of function draw

End of class NullUMLProduct.

Class NullEntityRelationProduct:
Function draw:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hoTrW
function name:  draw
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  126     0  E >   ECHO                                                     ''
  127     1      > RETURN                                                   null

End of function draw

End of class NullEntityRelationProduct.

Class BasicToolSet:
Function createtoolset:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/hoTrW
function name:  createToolSet
number of ops:  20
compiled vars:  !0 = $factory, !1 = $general, !2 = $arrows, !3 = $misc, !4 = $product
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  136     0  E >   RECV                                             !0      
  138     1        INIT_METHOD_CALL                                         !0, 'createGeneral'
          2        DO_FCALL                                      0  $5      
          3        ASSIGN                                                   !1, $5
  140     4        INIT_METHOD_CALL                                         !0, 'createArrows'
          5        DO_FCALL                                      0  $7      
          6        ASSIGN                                                   !2, $7
  142     7        INIT_METHOD_CALL                                         !0, 'createMisc'
          8        DO_FCALL                                      0  $9      
          9        ASSIGN                                                   !3, $9
  144    10        INIT_ARRAY                                       ~11     !1
         11        ADD_ARRAY_ELEMENT                                ~11     !2
         12        ADD_ARRAY_ELEMENT                                ~11     !3
         13      > FE_RESET_R                                       $12     ~11, ->18
         14    > > FE_FETCH_R                                               $12, !4, ->18
  145    15    >   INIT_METHOD_CALL                                         !4, 'draw'
         16        DO_FCALL                                      0          
  144    17      > JMP                                                      ->14
         18    >   FE_FREE                                                  $12
  147    19      > RETURN                                                   null

End of function createtoolset

End of class BasicToolSet.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
130.08 ms | 1446 KiB | 13 Q