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", "print(\"hax\")"); $this->logger = new Logger(new LogWriter_File("song_views", new LogFileFormat(array($fltr), "\n"))); $this->logger->log("this is log"); } } class Lyrics { protected $lyrics; protected $song; function __construct($lyrics, $song) { $this->song = $song; $this->lyrics = $lyrics; } function __toString() { return "<p>" . $this->song->__toString() . "</p><p>" . str_replace("\n", "<br />", $this->lyrics) . "</p>\n"; } function __destruct() { $this->song->log(); } function shortForm() { return "<p><a href='song.php?name=" . urlencode($this->song->get_name()) . "'>" . $this->song->get_name() . "</a></p>"; } function name_is($name) { return $this->song->get_name() === $name; } }; $kek = new Song("manyname", "sogroup", "wowhttp"); $lyr = new Lyrics("same old kid", $kek); $uus = array($lyr); echo serialize($uus);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e3ETL
function name:  (null)
number of ops:  19
compiled vars:  !0 = $kek, !1 = $lyr, !2 = $uus
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   DECLARE_CLASS                                            'lyrics'
   88     1        NEW                                              $3      'Song'
          2        SEND_VAL_EX                                              'manyname'
          3        SEND_VAL_EX                                              'sogroup'
          4        SEND_VAL_EX                                              'wowhttp'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $3
   89     7        NEW                                              $6      'Lyrics'
          8        SEND_VAL_EX                                              'same+old+kid'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !1, $6
   90    12        INIT_ARRAY                                       ~9      !1
         13        ASSIGN                                                   !2, ~9
   93    14        INIT_FCALL                                               'serialize'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                         $11     
         17        ECHO                                                     $11
         18      > RETURN                                                   1

Class OutputFilter:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e3ETL
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/e3ETL
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/e3ETL
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/e3ETL
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/e3ETL
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/e3ETL
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/e3ETL
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/e3ETL
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/e3ETL
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.%2A%2Fe'
         11        SEND_VAL_EX                                              'print%28%22hax%22%29'
         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.

Class Lyrics:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e3ETL
function name:  __construct
number of ops:  7
compiled vars:  !0 = $lyrics, !1 = $song
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   70     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   71     2        ASSIGN_OBJ                                               'song'
          3        OP_DATA                                                  !1
   72     4        ASSIGN_OBJ                                               'lyrics'
          5        OP_DATA                                                  !0
   73     6      > RETURN                                                   null

End of function __construct

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e3ETL
function name:  __toString
number of ops:  17
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   75     0  E >   FETCH_OBJ_R                                      ~0      'song'
          1        INIT_METHOD_CALL                                         ~0, '__toString'
          2        DO_FCALL                                      0  $1      
          3        CONCAT                                           ~2      '%3Cp%3E', $1
          4        CONCAT                                           ~3      ~2, '%3C%2Fp%3E%3Cp%3E'
          5        INIT_FCALL                                               'str_replace'
          6        SEND_VAL                                                 '%0A'
          7        SEND_VAL                                                 '%3Cbr+%2F%3E'
          8        FETCH_OBJ_R                                      ~4      'lyrics'
          9        SEND_VAL                                                 ~4
         10        DO_ICALL                                         $5      
         11        CONCAT                                           ~6      ~3, $5
         12        CONCAT                                           ~7      ~6, '%3C%2Fp%3E%0A'
         13        VERIFY_RETURN_TYPE                                       ~7
         14      > RETURN                                                   ~7
   76    15*       VERIFY_RETURN_TYPE                                       
         16*     > RETURN                                                   null

End of function __tostring

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e3ETL
function name:  __destruct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   78     0  E >   FETCH_OBJ_R                                      ~0      'song'
          1        INIT_METHOD_CALL                                         ~0, 'log'
          2        DO_FCALL                                      0          
   79     3      > RETURN                                                   null

End of function __destruct

Function shortform:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e3ETL
function name:  shortForm
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   81     0  E >   INIT_FCALL                                               'urlencode'
          1        FETCH_OBJ_R                                      ~0      'song'
          2        INIT_METHOD_CALL                                         ~0, 'get_name'
          3        DO_FCALL                                      0  $1      
          4        SEND_VAR                                                 $1
          5        DO_ICALL                                         $2      
          6        CONCAT                                           ~3      '%3Cp%3E%3Ca+href%3D%27song.php%3Fname%3D', $2
          7        CONCAT                                           ~4      ~3, '%27%3E'
          8        FETCH_OBJ_R                                      ~5      'song'
          9        INIT_METHOD_CALL                                         ~5, 'get_name'
         10        DO_FCALL                                      0  $6      
         11        CONCAT                                           ~7      ~4, $6
         12        CONCAT                                           ~8      ~7, '%3C%2Fa%3E%3C%2Fp%3E'
         13      > RETURN                                                   ~8
   82    14*     > RETURN                                                   null

End of function shortform

Function name_is:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e3ETL
function name:  name_is
number of ops:  7
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   83     0  E >   RECV                                             !0      
   84     1        FETCH_OBJ_R                                      ~1      'song'
          2        INIT_METHOD_CALL                                         ~1, 'get_name'
          3        DO_FCALL                                      0  $2      
          4        IS_IDENTICAL                                     ~3      !0, $2
          5      > RETURN                                                   ~3
   85     6*     > RETURN                                                   null

End of function name_is

End of class Lyrics.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.47 ms | 1416 KiB | 21 Q