3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace SimonEq; interface ImageInterface { function getFileName(); } class Image implements ImageInterface { private $fileName; public function __construct($fileName) { $this->fileName = $fileName; } public function getFileName() { return $this->fileName; } } interface TransformationInterface { function transform(ImageInterface $image); } class TransformationAggregate implements TransformationInterface { private $transformationArray = []; public function __construct($transformationArray) { $this->transformationArray = $transformationArray; } public function transform(ImageInterface $image) { foreach ($this->transformationArray as $transformation) { $transformation->transform($image); } } } class CropTransformation implements TransformationInterface { private $width; private $height; public function __construct($width, $height) { $this->width = (int) $width; $this->height = (int) $height; } public function transform(ImageInterface $image) { printf('Image "%s" transformed with %s' . PHP_EOL, $image->getFileName(), print_r($this, true)); } } class ResizeTransformation implements TransformationInterface { private $width; private $height; private $resample; public function __construct($width, $height, $resample) { $this->width = (int) $width; $this->height = (int) $height; $this->resample = (bool) $resample; } public function transform(ImageInterface $image) { printf('Image "%s" transformed with %s' . PHP_EOL, $image->getFileName(), print_r($this, true)); } } class WatermarkTransformation implements TransformationInterface { private $image; public function __construct(ImageInterface $image) { $this->image = $image; } public function transform(ImageInterface $image) { printf('Image "%s" transformed with %s' . PHP_EOL, $image->getFileName(), print_r($this, true)); } } $image = new Image('FluffyCat.jpg'); $transformation = new TransformationAggregate([ new CropTransformation(200, 400), new WatermarkTransformation(new Image('MyWaterMark.png')), new ResizeTransformation(100, 200, true), ]); $transformation->transform($image);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rjN2W
function name:  (null)
number of ops:  35
compiled vars:  !0 = $image, !1 = $transformation
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   DECLARE_CLASS                                            'simoneq%5Cimage'
   36     1        DECLARE_CLASS                                            'simoneq%5Ctransformationaggregate'
   56     2        DECLARE_CLASS                                            'simoneq%5Ccroptransformation'
   75     3        DECLARE_CLASS                                            'simoneq%5Cresizetransformation'
   96     4        DECLARE_CLASS                                            'simoneq%5Cwatermarktransformation'
  113     5        NEW                                              $2      'SimonEq%5CImage'
          6        SEND_VAL_EX                                              'FluffyCat.jpg'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !0, $2
  115     9        NEW                                              $5      'SimonEq%5CTransformationAggregate'
  116    10        NEW                                              $6      'SimonEq%5CCropTransformation'
         11        SEND_VAL_EX                                              200
         12        SEND_VAL_EX                                              400
         13        DO_FCALL                                      0          
         14        INIT_ARRAY                                       ~8      $6
  117    15        NEW                                              $9      'SimonEq%5CWatermarkTransformation'
         16        NEW                                              $10     'SimonEq%5CImage'
         17        SEND_VAL_EX                                              'MyWaterMark.png'
         18        DO_FCALL                                      0          
         19        SEND_VAR_NO_REF_EX                                       $10
         20        DO_FCALL                                      0          
         21        ADD_ARRAY_ELEMENT                                ~8      $9
  118    22        NEW                                              $13     'SimonEq%5CResizeTransformation'
         23        SEND_VAL_EX                                              100
         24        SEND_VAL_EX                                              200
         25        SEND_VAL_EX                                              <true>
         26        DO_FCALL                                      0          
         27        ADD_ARRAY_ELEMENT                                ~8      $13
         28        SEND_VAL_EX                                              ~8
         29        DO_FCALL                                      0          
  115    30        ASSIGN                                                   !1, $5
  121    31        INIT_METHOD_CALL                                         !1, 'transform'
         32        SEND_VAR_EX                                              !0
         33        DO_FCALL                                      0          
         34      > RETURN                                                   1

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

End of function getfilename

End of class SimonEq\ImageInterface.

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

End of function __construct

Function getfilename:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rjN2W
function name:  getFileName
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   FETCH_OBJ_R                                      ~0      'fileName'
          1      > RETURN                                                   ~0
   25     2*     > RETURN                                                   null

End of function getfilename

End of class SimonEq\Image.

Class SimonEq\TransformationInterface:
Function transform:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rjN2W
function name:  transform
number of ops:  2
compiled vars:  !0 = $image
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function transform

End of class SimonEq\TransformationInterface.

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

End of function __construct

Function transform:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/rjN2W
function name:  transform
number of ops:  10
compiled vars:  !0 = $image, !1 = $transformation
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
   48     1        FETCH_OBJ_R                                      ~2      'transformationArray'
          2      > FE_RESET_R                                       $3      ~2, ->8
          3    > > FE_FETCH_R                                               $3, !1, ->8
   50     4    >   INIT_METHOD_CALL                                         !1, 'transform'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   48     7      > JMP                                                      ->3
          8    >   FE_FREE                                                  $3
   52     9      > RETURN                                                   null

End of function transform

End of class SimonEq\TransformationAggregate.

Class SimonEq\CropTransformation:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rjN2W
function name:  __construct
number of ops:  9
compiled vars:  !0 = $width, !1 = $height
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   62     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   64     2        CAST                                          4  ~3      !0
          3        ASSIGN_OBJ                                               'width'
          4        OP_DATA                                                  ~3
   65     5        CAST                                          4  ~5      !1
          6        ASSIGN_OBJ                                               'height'
          7        OP_DATA                                                  ~5
   66     8      > RETURN                                                   null

End of function __construct

Function transform:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rjN2W
function name:  transform
number of ops:  16
compiled vars:  !0 = $image
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   68     0  E >   RECV                                             !0      
   70     1        INIT_NS_FCALL_BY_NAME                                    'SimonEq%5Cprintf'
          2        FETCH_CONSTANT                                   ~1      'SimonEq%5CPHP_EOL'
          3        CONCAT                                           ~2      'Image+%22%25s%22+transformed+with+%25s', ~1
          4        SEND_VAL_EX                                              ~2
          5        INIT_METHOD_CALL                                         !0, 'getFileName'
          6        DO_FCALL                                      0  $3      
          7        SEND_VAR_NO_REF_EX                                       $3
          8        INIT_NS_FCALL_BY_NAME                                    'SimonEq%5Cprint_r'
          9        FETCH_THIS                                       $4      
         10        SEND_VAR_EX                                              $4
         11        SEND_VAL_EX                                              <true>
         12        DO_FCALL                                      0  $5      
         13        SEND_VAR_NO_REF_EX                                       $5
         14        DO_FCALL                                      0          
   71    15      > RETURN                                                   null

End of function transform

End of class SimonEq\CropTransformation.

Class SimonEq\ResizeTransformation:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rjN2W
function name:  __construct
number of ops:  13
compiled vars:  !0 = $width, !1 = $height, !2 = $resample
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   82     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   84     3        CAST                                          4  ~4      !0
          4        ASSIGN_OBJ                                               'width'
          5        OP_DATA                                                  ~4
   85     6        CAST                                          4  ~6      !1
          7        ASSIGN_OBJ                                               'height'
          8        OP_DATA                                                  ~6
   86     9        BOOL                                             ~8      !2
         10        ASSIGN_OBJ                                               'resample'
         11        OP_DATA                                                  ~8
   87    12      > RETURN                                                   null

End of function __construct

Function transform:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rjN2W
function name:  transform
number of ops:  16
compiled vars:  !0 = $image
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   89     0  E >   RECV                                             !0      
   91     1        INIT_NS_FCALL_BY_NAME                                    'SimonEq%5Cprintf'
          2        FETCH_CONSTANT                                   ~1      'SimonEq%5CPHP_EOL'
          3        CONCAT                                           ~2      'Image+%22%25s%22+transformed+with+%25s', ~1
          4        SEND_VAL_EX                                              ~2
          5        INIT_METHOD_CALL                                         !0, 'getFileName'
          6        DO_FCALL                                      0  $3      
          7        SEND_VAR_NO_REF_EX                                       $3
          8        INIT_NS_FCALL_BY_NAME                                    'SimonEq%5Cprint_r'
          9        FETCH_THIS                                       $4      
         10        SEND_VAR_EX                                              $4
         11        SEND_VAL_EX                                              <true>
         12        DO_FCALL                                      0  $5      
         13        SEND_VAR_NO_REF_EX                                       $5
         14        DO_FCALL                                      0          
   92    15      > RETURN                                                   null

End of function transform

End of class SimonEq\ResizeTransformation.

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

End of function __construct

Function transform:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rjN2W
function name:  transform
number of ops:  16
compiled vars:  !0 = $image
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  106     0  E >   RECV                                             !0      
  108     1        INIT_NS_FCALL_BY_NAME                                    'SimonEq%5Cprintf'
          2        FETCH_CONSTANT                                   ~1      'SimonEq%5CPHP_EOL'
          3        CONCAT                                           ~2      'Image+%22%25s%22+transformed+with+%25s', ~1
          4        SEND_VAL_EX                                              ~2
          5        INIT_METHOD_CALL                                         !0, 'getFileName'
          6        DO_FCALL                                      0  $3      
          7        SEND_VAR_NO_REF_EX                                       $3
          8        INIT_NS_FCALL_BY_NAME                                    'SimonEq%5Cprint_r'
          9        FETCH_THIS                                       $4      
         10        SEND_VAR_EX                                              $4
         11        SEND_VAL_EX                                              <true>
         12        DO_FCALL                                      0  $5      
         13        SEND_VAR_NO_REF_EX                                       $5
         14        DO_FCALL                                      0          
  109    15      > RETURN                                                   null

End of function transform

End of class SimonEq\WatermarkTransformation.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.84 ms | 1412 KiB | 17 Q