3v4l.org

run code in 500+ PHP versions simultaneously
<?php // @source https://refactoring.guru/ru/design-patterns/decorator/php/example#example-1 namespace RefactoringGuru\Decorator\RealWorld; /** * Интерфейс Компонента объявляет метод фильтрации, который должен быть * реализован всеми конкретными компонентами и декораторами. */ interface InputFormat { public function formatText(string $text): string; } /** * Конкретный Компонент является основным элементом декорирования. Он содержит * исходный текст как есть, без какой-либо фильтрации или форматирования. */ class TextInput implements InputFormat { public function formatText(string $text): string { return $text; } } /** * Базовый класс Декоратора не содержит реальной логики фильтрации или * форматирования. Его основная цель – реализовать базовую инфраструктуру * декорирования: поле для хранения обёрнутого компонента или другого декоратора * и базовый метод форматирования, который делегирует работу обёрнутому объекту. * Реальная работа по форматированию выполняется подклассами. */ class TextFormat implements InputFormat { /** * @var InputFormat */ protected $inputFormat; public function __construct(InputFormat $inputFormat) { $this->inputFormat = $inputFormat; } /** * Декоратор делегирует всю работу обёрнутому компоненту. */ public function formatText(string $text): string { return $this->inputFormat->formatText($text); } } /** * Этот Конкретный Декоратор удаляет все теги HTML из данного текста. */ class PlainTextFilter extends TextFormat { public function formatText(string $text): string { $text = parent::formatText($text); return strip_tags($text); } } /** * Этот Конкретный Декоратор удаляет только опасные теги и атрибуты HTML, * которые могут привести к XSS-уязвимости. */ class DangerousHTMLTagsFilter extends TextFormat { private $dangerousTagPatterns = [ "|<script.*?>([\s\S]*)?</script>|i", // ... ]; private $dangerousAttributes = [ "onclick", "onkeypress", // ... ]; public function formatText(string $text): string { $text = parent::formatText($text); foreach ($this->dangerousTagPatterns as $pattern) { $text = preg_replace($pattern, '', $text); } foreach ($this->dangerousAttributes as $attribute) { $text = preg_replace_callback('|<(.*?)>|', function ($matches) use ($attribute) { $result = preg_replace("|$attribute=|i", '', $matches[1]); return "<" . $result . ">"; }, $text); } return $text; } } /** * Этот Конкретный Декоратор предоставляет элементарное преобразование Markdown * → HTML. */ class MarkdownFormat extends TextFormat { public function formatText(string $text): string { $text = parent::formatText($text); // Форматирование элементов блока. $chunks = preg_split('|\n\n|', $text); foreach ($chunks as &$chunk) { // Форматирование заголовков. if (preg_match('|^#+|', $chunk)) { $chunk = preg_replace_callback('|^(#+)(.*?)$|', function ($matches) { $h = strlen($matches[1]); return "<h$h>" . trim($matches[2]) . "</h$h>"; }, $chunk); } // Форматирование параграфов. else { $chunk = "<p>$chunk</p>"; } } $text = implode("\n\n", $chunks); // Форматирование встроенных элементов. $text = preg_replace("|__(.*?)__|", '<strong>$1</strong>', $text); $text = preg_replace("|\*\*(.*?)\*\*|", '<strong>$1</strong>', $text); $text = preg_replace("|_(.*?)_|", '<em>$1</em>', $text); $text = preg_replace("|\*(.*?)\*|", '<em>$1</em>', $text); return $text; } } ///////////////////////////////////////////////////////////////////////////////////////// /** * Клиентский код может быть частью реального веб-сайта, который отображает * создаваемый пользователями контент. Поскольку он работает с модулями * форматирования через интерфейс компонента, ему всё равно, получает ли он * простой объект компонента или обёрнутый. */ function displayCommentAsAWebsite(InputFormat $format, string $text) { // .. echo $format->formatText($text); // .. } /** * Модули форматирования пользовательского ввода очень удобны при работе с * контентом, создаваемым пользователями. Отображение такого контента «как есть» * может быть очень опасным, особенно когда его могут создавать анонимные * пользователи (например, комментарии). Ваш сайт не только рискует получить * массу спам-ссылок, но также может быть подвергнут XSS-атакам. */ $dangerousComment = <<<HERE Hello! Nice blog post! Please visit my <a href='http://www.iwillhackyou.com'>homepage</a>. <script src="http://www.iwillhackyou.com/script.js"> performXSSAttack(); </script> HERE; ///////////////////////////////////////////////////////////////////////////////////////// /** * Наивное отображение комментариев (небезопасное). */ $naiveInput = new TextInput(); echo "Website renders comments without filtering (unsafe):\n"; displayCommentAsAWebsite($naiveInput, $dangerousComment); echo "\n\n\n"; ///////////////////////////////////////////////////////////////////////////////////////// /** * Отфильтрованное отображение комментариев (безопасное). */ $filteredInput = new PlainTextFilter($naiveInput); echo "Website renders comments after stripping all tags (safe):\n"; displayCommentAsAWebsite($filteredInput, $dangerousComment); echo "\n\n\n"; ///////////////////////////////////////////////////////////////////////////////////////// /** * Декоратор позволяет складывать несколько входных форматов для получения * точного контроля над отображаемым содержимым. */ $dangerousForumPost = <<<HERE # Welcome This is my first post on this **gorgeous** forum. <script src="http://www.iwillhackyou.com/script.js"> performXSSAttack(); </script> HERE; /** * Наивное отображение сообщений (небезопасное, без форматирования). */ $naiveInput = new TextInput(); echo "Website renders a forum post without filtering and formatting (unsafe, ugly):\n"; displayCommentAsAWebsite($naiveInput, $dangerousForumPost); echo "\n\n\n"; /** * Форматтер Markdown + фильтрация опасных тегов (безопасно, красиво). */ $text = new TextInput(); $markdown = new MarkdownFormat($text); $filteredInput = new DangerousHTMLTagsFilter($markdown); //$filteredInput = new PlainTextFilter($filteredInput); echo "Website renders a forum post after translating markdown markup" . " and filtering some dangerous HTML tags and attributes (safe, pretty):\n"; displayCommentAsAWebsite($filteredInput, $dangerousForumPost); echo "\n\n\n"; /////////////////////////////////////////////////////////////////////////////////////////
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Zcrcj
function name:  (null)
number of ops:  53
compiled vars:  !0 = $dangerousComment, !1 = $naiveInput, !2 = $filteredInput, !3 = $dangerousForumPost, !4 = $text, !5 = $markdown
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   DECLARE_CLASS                                                'refactoringguru%5Cdecorator%5Crealworld%5Ctextinput'
   35     1        DECLARE_CLASS                                                'refactoringguru%5Cdecorator%5Crealworld%5Ctextformat'
   59     2        DECLARE_CLASS                                                'refactoringguru%5Cdecorator%5Crealworld%5Cplaintextfilter', 'refactoringguru%5Cdecorator%5Crealworld%5Ctextformat'
   72     3        DECLARE_CLASS                                                'refactoringguru%5Cdecorator%5Crealworld%5Cdangeroushtmltagsfilter', 'refactoringguru%5Cdecorator%5Crealworld%5Ctextformat'
  106     4        DECLARE_CLASS                                                'refactoringguru%5Cdecorator%5Crealworld%5Cmarkdownformat', 'refactoringguru%5Cdecorator%5Crealworld%5Ctextformat'
  162     5        ASSIGN                                                       !0, 'Hello%21+Nice+blog+post%21%0APlease+visit+my+%3Ca+href%3D%27http%3A%2F%2Fwww.iwillhackyou.com%27%3Ehomepage%3C%2Fa%3E.%0A%3Cscript+src%3D%22http%3A%2F%2Fwww.iwillhackyou.com%2Fscript.js%22%3E%0A++performXSSAttack%28%29%3B%0A%3C%2Fscript%3E'
  175     6        NEW                                                  $7      'RefactoringGuru%5CDecorator%5CRealWorld%5CTextInput'
          7        DO_FCALL                                          0          
          8        ASSIGN                                                       !1, $7
  176     9        ECHO                                                         'Website+renders+comments+without+filtering+%28unsafe%29%3A%0A'
  177    10        INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5CdisplayCommentAsAWebsite'
         11        SEND_VAR_EX                                                  !1
         12        SEND_VAR_EX                                                  !0
         13        DO_FCALL                                          0          
  178    14        ECHO                                                         '%0A%0A%0A'
  185    15        NEW                                                  $11     'RefactoringGuru%5CDecorator%5CRealWorld%5CPlainTextFilter'
         16        SEND_VAR_EX                                                  !1
         17        DO_FCALL                                          0          
         18        ASSIGN                                                       !2, $11
  186    19        ECHO                                                         'Website+renders+comments+after+stripping+all+tags+%28safe%29%3A%0A'
  187    20        INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5CdisplayCommentAsAWebsite'
         21        SEND_VAR_EX                                                  !2
         22        SEND_VAR_EX                                                  !0
         23        DO_FCALL                                          0          
  188    24        ECHO                                                         '%0A%0A%0A'
  196    25        ASSIGN                                                       !3, '%23+Welcome%0A%0AThis+is+my+first+post+on+this+%2A%2Agorgeous%2A%2A+forum.%0A%0A%3Cscript+src%3D%22http%3A%2F%2Fwww.iwillhackyou.com%2Fscript.js%22%3E%0A++performXSSAttack%28%29%3B%0A%3C%2Fscript%3E'
  209    26        NEW                                                  $16     'RefactoringGuru%5CDecorator%5CRealWorld%5CTextInput'
         27        DO_FCALL                                          0          
         28        ASSIGN                                                       !1, $16
  210    29        ECHO                                                         'Website+renders+a+forum+post+without+filtering+and+formatting+%28unsafe%2C+ugly%29%3A%0A'
  211    30        INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5CdisplayCommentAsAWebsite'
         31        SEND_VAR_EX                                                  !1
         32        SEND_VAR_EX                                                  !3
         33        DO_FCALL                                          0          
  212    34        ECHO                                                         '%0A%0A%0A'
  217    35        NEW                                                  $20     'RefactoringGuru%5CDecorator%5CRealWorld%5CTextInput'
         36        DO_FCALL                                          0          
         37        ASSIGN                                                       !4, $20
  218    38        NEW                                                  $23     'RefactoringGuru%5CDecorator%5CRealWorld%5CMarkdownFormat'
         39        SEND_VAR_EX                                                  !4
         40        DO_FCALL                                          0          
         41        ASSIGN                                                       !5, $23
  219    42        NEW                                                  $26     'RefactoringGuru%5CDecorator%5CRealWorld%5CDangerousHTMLTagsFilter'
         43        SEND_VAR_EX                                                  !5
         44        DO_FCALL                                          0          
         45        ASSIGN                                                       !2, $26
  222    46        ECHO                                                         'Website+renders+a+forum+post+after+translating+markdown+markup+and+filtering+some+dangerous+HTML+tags+and+attributes+%28safe%2C+pretty%29%3A%0A'
  223    47        INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5CdisplayCommentAsAWebsite'
         48        SEND_VAR_EX                                                  !2
         49        SEND_VAR_EX                                                  !3
         50        DO_FCALL                                          0          
  224    51        ECHO                                                         '%0A%0A%0A'
  226    52      > RETURN                                                       1

Function refactoringguru%5Cdecorator%5Crealworld%5Cdisplaycommentasawebsite:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Zcrcj
function name:  RefactoringGuru\Decorator\RealWorld\displayCommentAsAWebsite
number of ops:  7
compiled vars:  !0 = $format, !1 = $text
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  146     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
  150     2        INIT_METHOD_CALL                                             !0, 'formatText'
          3        SEND_VAR_EX                                                  !1
          4        DO_FCALL                                          0  $2      
          5        ECHO                                                         $2
  153     6      > RETURN                                                       null

End of function refactoringguru%5Cdecorator%5Crealworld%5Cdisplaycommentasawebsite

Class RefactoringGuru\Decorator\RealWorld\InputFormat:
Function formattext:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Zcrcj
function name:  formatText
number of ops:  3
compiled vars:  !0 = $text
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
          1        VERIFY_RETURN_TYPE                                           
          2      > RETURN                                                       null

End of function formattext

End of class RefactoringGuru\Decorator\RealWorld\InputFormat.

Class RefactoringGuru\Decorator\RealWorld\TextInput:
Function formattext:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Zcrcj
function name:  formatText
number of ops:  5
compiled vars:  !0 = $text
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   RECV                                                 !0      
   24     1        VERIFY_RETURN_TYPE                                           !0
          2      > RETURN                                                       !0
   25     3*       VERIFY_RETURN_TYPE                                           
          4*     > RETURN                                                       null

End of function formattext

End of class RefactoringGuru\Decorator\RealWorld\TextInput.

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

End of function __construct

Function formattext:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Zcrcj
function name:  formatText
number of ops:  9
compiled vars:  !0 = $text
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   50     0  E >   RECV                                                 !0      
   52     1        FETCH_OBJ_R                                          ~1      'inputFormat'
          2        INIT_METHOD_CALL                                             ~1, 'formatText'
          3        SEND_VAR_EX                                                  !0
          4        DO_FCALL                                          0  $2      
          5        VERIFY_RETURN_TYPE                                           $2
          6      > RETURN                                                       $2
   53     7*       VERIFY_RETURN_TYPE                                           
          8*     > RETURN                                                       null

End of function formattext

End of class RefactoringGuru\Decorator\RealWorld\TextFormat.

Class RefactoringGuru\Decorator\RealWorld\PlainTextFilter:
Function formattext:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Zcrcj
function name:  formatText
number of ops:  12
compiled vars:  !0 = $text
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   61     0  E >   RECV                                                 !0      
   63     1        INIT_STATIC_METHOD_CALL                                      'formatText'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0  $1      
          4        ASSIGN                                                       !0, $1
   64     5        INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5Cstrip_tags'
          6        SEND_VAR_EX                                                  !0
          7        DO_FCALL                                          0  $3      
          8        VERIFY_RETURN_TYPE                                           $3
          9      > RETURN                                                       $3
   65    10*       VERIFY_RETURN_TYPE                                           
         11*     > RETURN                                                       null

End of function formattext

End of class RefactoringGuru\Decorator\RealWorld\PlainTextFilter.

Class RefactoringGuru\Decorator\RealWorld\DangerousHTMLTagsFilter:
Function formattext:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 19
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
2 jumps found. (Code = 208) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 19
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 32
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 32
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
Branch analysis from position: 19
filename:       /in/Zcrcj
function name:  formatText
number of ops:  37
compiled vars:  !0 = $text, !1 = $pattern, !2 = $attribute
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   83     0  E >   RECV                                                 !0      
   85     1        INIT_STATIC_METHOD_CALL                                      'formatText'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0  $3      
          4        ASSIGN                                                       !0, $3
   87     5        FETCH_OBJ_R                                          ~5      'dangerousTagPatterns'
          6      > FE_RESET_R                                           $6      ~5, ->19
          7    > > FE_FETCH_R                                                   $6, !1, ->19
   88     8    > > JMP_FRAMELESS                                   s48          'refactoringguru%5Cdecorator%5Crealworld%5Cpreg_replace', ->15
          9    >   INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5Cpreg_replace'
         10        SEND_VAR_EX                                                  !1
         11        SEND_VAL_EX                                                  ''
         12        SEND_VAR_EX                                                  !0
         13        DO_FCALL                                          0  $7      
         14      > JMP                                                          ->17
         15    >   FRAMELESS_ICALL_3                preg_replace        $7      !1, ''
         16        OP_DATA                                                      !0
         17    >   ASSIGN                                                       !0, $7
   87    18      > JMP                                                          ->7
         19    >   FE_FREE                                                      $6
   91    20        FETCH_OBJ_R                                          ~9      'dangerousAttributes'
         21      > FE_RESET_R                                           $10     ~9, ->32
         22    > > FE_FETCH_R                                                   $10, !2, ->32
   92    23    >   INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5Cpreg_replace_callback'
         24        SEND_VAL_EX                                                  '%7C%3C%28.%2A%3F%29%3E%7C'
         25        DECLARE_LAMBDA_FUNCTION                              ~11     [0]
         26        BIND_LEXICAL                                                 ~11, !2
   95    27        SEND_VAL_EX                                                  ~11
   92    28        SEND_VAR_EX                                                  !0
         29        DO_FCALL                                          0  $12     
         30        ASSIGN                                                       !0, $12
   91    31      > JMP                                                          ->22
         32    >   FE_FREE                                                      $10
   98    33        VERIFY_RETURN_TYPE                                           !0
         34      > RETURN                                                       !0
   99    35*       VERIFY_RETURN_TYPE                                           
         36*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 208) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Zcrcj
function name:  {closure:RefactoringGuru\Decorator\RealWorld\DangerousHTMLTagsFilter::formatText():92}
number of ops:  25
compiled vars:  !0 = $matches, !1 = $attribute, !2 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   92     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
   93     2      > JMP_FRAMELESS                                   s8           'refactoringguru%5Cdecorator%5Crealworld%5Cpreg_replace', ->14
          3    >   INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5Cpreg_replace'
          4        ROPE_INIT                                         3  ~4      '%7C'
          5        ROPE_ADD                                          1  ~4      ~4, !1
          6        ROPE_END                                          2  ~3      ~4, '%3D%7Ci'
          7        SEND_VAL_EX                                                  ~3
          8        SEND_VAL_EX                                                  ''
          9        CHECK_FUNC_ARG                                               
         10        FETCH_DIM_FUNC_ARG                                   $6      !0, 1
         11        SEND_FUNC_ARG                                                $6
         12        DO_FCALL                                          0  $7      
         13      > JMP                                                          ->20
         14    >   ROPE_INIT                                         3  ~9      '%7C'
         15        ROPE_ADD                                          1  ~9      ~9, !1
         16        ROPE_END                                          2  ~8      ~9, '%3D%7Ci'
         17        FETCH_DIM_R                                          ~11     !0, 1
         18        FRAMELESS_ICALL_3                preg_replace        $7      ~8, ''
         19        OP_DATA                                                      ~11
         20    >   ASSIGN                                                       !2, $7
   94    21        CONCAT                                               ~13     '%3C', !2
         22        CONCAT                                               ~14     ~13, '%3E'
         23      > RETURN                                                       ~14
   95    24*     > RETURN                                                       null

End of Dynamic Function 0

End of function formattext

End of class RefactoringGuru\Decorator\RealWorld\DangerousHTMLTagsFilter.

Class RefactoringGuru\Decorator\RealWorld\MarkdownFormat:
Function formattext:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 11, Position 2 = 33
Branch analysis from position: 11
2 jumps found. (Code = 126) Position 1 = 12, Position 2 = 33
Branch analysis from position: 12
2 jumps found. (Code = 208) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
Branch analysis from position: 28
Branch analysis from position: 33
2 jumps found. (Code = 208) Position 1 = 35, Position 2 = 40
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 208) Position 1 = 43, Position 2 = 49
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 208) Position 1 = 53, Position 2 = 59
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
2 jumps found. (Code = 208) Position 1 = 63, Position 2 = 69
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
2 jumps found. (Code = 208) Position 1 = 73, Position 2 = 79
Branch analysis from position: 73
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 79
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 69
2 jumps found. (Code = 208) Position 1 = 73, Position 2 = 79
Branch analysis from position: 73
Branch analysis from position: 79
Branch analysis from position: 59
2 jumps found. (Code = 208) Position 1 = 63, Position 2 = 69
Branch analysis from position: 63
Branch analysis from position: 69
Branch analysis from position: 49
2 jumps found. (Code = 208) Position 1 = 53, Position 2 = 59
Branch analysis from position: 53
Branch analysis from position: 59
Branch analysis from position: 40
2 jumps found. (Code = 208) Position 1 = 43, Position 2 = 49
Branch analysis from position: 43
Branch analysis from position: 49
Branch analysis from position: 33
filename:       /in/Zcrcj
function name:  formatText
number of ops:  86
compiled vars:  !0 = $text, !1 = $chunks, !2 = $chunk
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  108     0  E >   RECV                                                 !0      
  110     1        INIT_STATIC_METHOD_CALL                                      'formatText'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0  $3      
          4        ASSIGN                                                       !0, $3
  113     5        INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5Cpreg_split'
          6        SEND_VAL_EX                                                  '%7C%5Cn%5Cn%7C'
          7        SEND_VAR_EX                                                  !0
          8        DO_FCALL                                          0  $5      
          9        ASSIGN                                                       !1, $5
  114    10      > FE_RESET_RW                                          $7      !1, ->33
         11    > > FE_FETCH_RW                                                  $7, !2, ->33
  116    12    > > JMP_FRAMELESS                                   s32          'refactoringguru%5Cdecorator%5Crealworld%5Cpreg_match', ->18
         13    >   INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5Cpreg_match'
         14        SEND_VAL_EX                                                  '%7C%5E%23%2B%7C'
         15        SEND_VAR_EX                                                  !2
         16        DO_FCALL                                          0  $8      
         17      > JMP                                                          ->19
         18    >   FRAMELESS_ICALL_2                preg_match          $8      '%7C%5E%23%2B%7C', !2
         19    > > JMPZ                                                         $8, ->28
  117    20    >   INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5Cpreg_replace_callback'
         21        SEND_VAL_EX                                                  '%7C%5E%28%23%2B%29%28.%2A%3F%29%24%7C'
         22        DECLARE_LAMBDA_FUNCTION                              ~9      [0]
  120    23        SEND_VAL_EX                                                  ~9
  117    24        SEND_VAR_EX                                                  !2
         25        DO_FCALL                                          0  $10     
         26        ASSIGN                                                       !2, $10
  116    27      > JMP                                                          ->32
  123    28    >   ROPE_INIT                                         3  ~13     '%3Cp%3E'
         29        ROPE_ADD                                          1  ~13     ~13, !2
         30        ROPE_END                                          2  ~12     ~13, '%3C%2Fp%3E'
         31        ASSIGN                                                       !2, ~12
  114    32    > > JMP                                                          ->11
         33    >   FE_FREE                                                      $7
  126    34      > JMP_FRAMELESS                                   s56          'refactoringguru%5Cdecorator%5Crealworld%5Cimplode', ->40
         35    >   INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5Cimplode'
         36        SEND_VAL_EX                                                  '%0A%0A'
         37        SEND_VAR_EX                                                  !1
         38        DO_FCALL                                          0  $16     
         39      > JMP                                                          ->41
         40    >   FRAMELESS_ICALL_2                implode             $16     '%0A%0A', !1
         41    >   ASSIGN                                                       !0, $16
  129    42      > JMP_FRAMELESS                                   s72          'refactoringguru%5Cdecorator%5Crealworld%5Cpreg_replace', ->49
         43    >   INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5Cpreg_replace'
         44        SEND_VAL_EX                                                  '%7C__%28.%2A%3F%29__%7C'
         45        SEND_VAL_EX                                                  '%3Cstrong%3E%241%3C%2Fstrong%3E'
         46        SEND_VAR_EX                                                  !0
         47        DO_FCALL                                          0  $18     
         48      > JMP                                                          ->51
         49    >   FRAMELESS_ICALL_3                preg_replace        $18     '%7C__%28.%2A%3F%29__%7C', '%3Cstrong%3E%241%3C%2Fstrong%3E'
         50        OP_DATA                                                      !0
         51    >   ASSIGN                                                       !0, $18
  130    52      > JMP_FRAMELESS                                   s88          'refactoringguru%5Cdecorator%5Crealworld%5Cpreg_replace', ->59
         53    >   INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5Cpreg_replace'
         54        SEND_VAL_EX                                                  '%7C%5C%2A%5C%2A%28.%2A%3F%29%5C%2A%5C%2A%7C'
         55        SEND_VAL_EX                                                  '%3Cstrong%3E%241%3C%2Fstrong%3E'
         56        SEND_VAR_EX                                                  !0
         57        DO_FCALL                                          0  $20     
         58      > JMP                                                          ->61
         59    >   FRAMELESS_ICALL_3                preg_replace        $20     '%7C%5C%2A%5C%2A%28.%2A%3F%29%5C%2A%5C%2A%7C', '%3Cstrong%3E%241%3C%2Fstrong%3E'
         60        OP_DATA                                                      !0
         61    >   ASSIGN                                                       !0, $20
  131    62      > JMP_FRAMELESS                                   s104         'refactoringguru%5Cdecorator%5Crealworld%5Cpreg_replace', ->69
         63    >   INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5Cpreg_replace'
         64        SEND_VAL_EX                                                  '%7C_%28.%2A%3F%29_%7C'
         65        SEND_VAL_EX                                                  '%3Cem%3E%241%3C%2Fem%3E'
         66        SEND_VAR_EX                                                  !0
         67        DO_FCALL                                          0  $22     
         68      > JMP                                                          ->71
         69    >   FRAMELESS_ICALL_3                preg_replace        $22     '%7C_%28.%2A%3F%29_%7C', '%3Cem%3E%241%3C%2Fem%3E'
         70        OP_DATA                                                      !0
         71    >   ASSIGN                                                       !0, $22
  132    72      > JMP_FRAMELESS                                   s120         'refactoringguru%5Cdecorator%5Crealworld%5Cpreg_replace', ->79
         73    >   INIT_NS_FCALL_BY_NAME                                        'RefactoringGuru%5CDecorator%5CRealWorld%5Cpreg_replace'
         74        SEND_VAL_EX                                                  '%7C%5C%2A%28.%2A%3F%29%5C%2A%7C'
         75        SEND_VAL_EX                                                  '%3Cem%3E%241%3C%2Fem%3E'
         76        SEND_VAR_EX                                                  !0
         77        DO_FCALL                                          0  $24     
         78      > JMP                                                          ->81
         79    >   FRAMELESS_ICALL_3                preg_replace        $24     '%7C%5C%2A%28.%2A%3F%29%5C%2A%7C', '%3Cem%3E%241%3C%2Fem%3E'
         80        OP_DATA                                                      !0
         81    >   ASSIGN                                                       !0, $24
  134    82        VERIFY_RETURN_TYPE                                           !0
         83      > RETURN                                                       !0
  13

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.07 ms | 2245 KiB | 23 Q