3v4l.org

run code in 300+ PHP versions simultaneously
<?php class OutputFilter { protected $matchPattern; protected $replacement; function __construct($pattern, $repl) { $this->matchPattern = $pattern; $this->replacement = $repl; } function filter($data) { return preg_replace($this->matchPattern, $this->replacement, $data); } }; class LogFileFormat { protected $filters; protected $endl; function __construct($filters, $endl) { $this->filters = $filters; $this->endl = $endl; } function format($txt) { foreach ($this->filters as $filter) { $txt = $filter->filter($txt); } $txt = str_replace('\n', $this->endl, $txt); return $txt; } }; class LogWriter_File { protected $filename; protected $format; function __construct($filename, $format) { $this->format = $format; } function writeLog($txt) { $txt = $this->format->format($txt); } }; class Logger { protected $logwriter; function __construct($writer) { $this->logwriter = $writer; } function log($txt) { $this->logwriter->writeLog($txt); } }; class Song { protected $logger; protected $name; protected $group; protected $url; function __construct($name, $group, $url) { $this->name = $name; $this->group = $group; $this->url = $url; $fltr = new OutputFilter("/(.*)/e", "echo wowow"); $this->logger = new Logger(new LogWriter_File("song_views", new LogFileFormat(array($fltr), "\n"))); $this->logger->log("this is log"); } } $kek = new Song("manyname", "sogroup", "wowhttp");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1VBu
function name:  (null)
number of ops:  7
compiled vars:  !0 = $kek
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   NEW                                              $1      'Song'
          1        SEND_VAL_EX                                              'manyname'
          2        SEND_VAL_EX                                              'sogroup'
          3        SEND_VAL_EX                                              'wowhttp'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
          6      > RETURN                                                   1

Class OutputFilter:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1VBu
function name:  __construct
number of ops:  7
compiled vars:  !0 = $pattern, !1 = $repl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        ASSIGN_OBJ                                               'matchPattern'
          3        OP_DATA                                                  !0
    8     4        ASSIGN_OBJ                                               'replacement'
          5        OP_DATA                                                  !1
    9     6      > RETURN                                                   null

End of function __construct

Function filter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1VBu
function name:  filter
number of ops:  10
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'preg_replace'
          2        FETCH_OBJ_R                                      ~1      'matchPattern'
          3        SEND_VAL                                                 ~1
          4        FETCH_OBJ_R                                      ~2      'replacement'
          5        SEND_VAL                                                 ~2
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $3      
          8      > RETURN                                                   $3
   12     9*     > RETURN                                                   null

End of function filter

End of class OutputFilter.

Class LogFileFormat:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1VBu
function name:  __construct
number of ops:  7
compiled vars:  !0 = $filters, !1 = $endl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        ASSIGN_OBJ                                               'filters'
          3        OP_DATA                                                  !0
   20     4        ASSIGN_OBJ                                               'endl'
          5        OP_DATA                                                  !1
   21     6      > RETURN                                                   null

End of function __construct

Function format:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/f1VBu
function name:  format
number of ops:  19
compiled vars:  !0 = $txt, !1 = $filter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        FETCH_OBJ_R                                      ~2      'filters'
          2      > FE_RESET_R                                       $3      ~2, ->9
          3    > > FE_FETCH_R                                               $3, !1, ->9
   24     4    >   INIT_METHOD_CALL                                         !1, 'filter'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $4      
          7        ASSIGN                                                   !0, $4
   23     8      > JMP                                                      ->3
          9    >   FE_FREE                                                  $3
   26    10        INIT_FCALL                                               'str_replace'
         11        SEND_VAL                                                 '%5Cn'
         12        FETCH_OBJ_R                                      ~6      'endl'
         13        SEND_VAL                                                 ~6
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $7      
         16        ASSIGN                                                   !0, $7
   27    17      > RETURN                                                   !0
   28    18*     > RETURN                                                   null

End of function format

End of class LogFileFormat.

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

End of function __construct

Function writelog:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1VBu
function name:  writeLog
number of ops:  7
compiled vars:  !0 = $txt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
   38     1        FETCH_OBJ_R                                      ~1      'format'
          2        INIT_METHOD_CALL                                         ~1, 'format'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   39     6      > RETURN                                                   null

End of function writelog

End of class LogWriter_File.

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

End of function __construct

Function log:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1VBu
function name:  log
number of ops:  6
compiled vars:  !0 = $txt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   RECV                                             !0      
   48     1        FETCH_OBJ_R                                      ~1      'logwriter'
          2        INIT_METHOD_CALL                                         ~1, 'writeLog'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
   49     5      > RETURN                                                   null

End of function log

End of class Logger.

Class Song:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1VBu
function name:  __construct
number of ops:  33
compiled vars:  !0 = $name, !1 = $group, !2 = $url, !3 = $fltr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   58     3        ASSIGN_OBJ                                               'name'
          4        OP_DATA                                                  !0
          5        ASSIGN_OBJ                                               'group'
          6        OP_DATA                                                  !1
   59     7        ASSIGN_OBJ                                               'url'
          8        OP_DATA                                                  !2
   60     9        NEW                                              $7      'OutputFilter'
         10        SEND_VAL_EX                                              '%2F%28.%2A%29%2Fe'
         11        SEND_VAL_EX                                              'echo+wowow'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !3, $7
   61    14        NEW                                              $11     'Logger'
         15        NEW                                              $12     'LogWriter_File'
         16        SEND_VAL_EX                                              'song_views'
         17        NEW                                              $13     'LogFileFormat'
         18        INIT_ARRAY                                       ~14     !3
         19        SEND_VAL_EX                                              ~14
         20        SEND_VAL_EX                                              '%0A'
         21        DO_FCALL                                      0          
         22        SEND_VAR_NO_REF_EX                                       $13
         23        DO_FCALL                                      0          
         24        SEND_VAR_NO_REF_EX                                       $12
         25        DO_FCALL                                      0          
         26        ASSIGN_OBJ                                               'logger'
         27        OP_DATA                                                  $11
   62    28        FETCH_OBJ_R                                      ~18     'logger'
         29        INIT_METHOD_CALL                                         ~18, 'log'
         30        SEND_VAL_EX                                              'this+is+log'
         31        DO_FCALL                                      0          
   64    32      > RETURN                                                   null

End of function __construct

End of class Song.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.47 ms | 1408 KiB | 17 Q