3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace RefactoringGuru\AbstractFactory\RealWorld; /** * Паттерн Абстрактная Фабрика * * Назначение: Предоставляет интерфейс для создания семейств связанных или * зависимых объектов, без привязки к их конкретным классам. * * Пример: В этом примере паттерн Абстрактная Фабрика предоставляет * инфраструктуру для создания нескольких разновидностей шаблонов для одних и * тех же элементов веб-страницы. * * Чтобы веб-приложение могло поддерживать сразу несколько разных движков * рендеринга страниц, его классы должны работать с шаблонами только через * интерфейсы, не привязываясь к конкретным классам. Чтобы этого достичь, * объекты приложения не должны создавать шаблоны напрямую, а поручать создание * специальным объектам-фабрикам, с которыми тоже надо работать через * абстрактный интерфейс. * * Благодаря этому, вы можете подать в приложение фабрику, соответствующую * одному из движков рендеринга, зная, что с этого момента, все шаблоны будут * порождаться именно этой фабрикой, и будут соответствовать движку рендеринга * этой фабрики. Если вы захотите сменить движок рендеринга, то всё что нужно * будет сделать — это подать в приложение объект фабрики другого типа и ничего * при этом не сломается. */ /** * Интерфейс Абстрактной фабрики объявляет создающие методы для каждого * определённого типа продукта. */ interface TemplateFactory { public function createTitleTemplate(): TitleTemplate; public function createPageTemplate(): PageTemplate; public function getRenderer(): TemplateRenderer; } /** * Каждая Конкретная Фабрика соответствует определённому варианту (или * семейству) продуктов. * * Эта Конкретная Фабрика создает шаблоны Twig. */ class TwigTemplateFactory implements TemplateFactory { public function createTitleTemplate(): TitleTemplate { return new TwigTitleTemplate(); } public function createPageTemplate(): PageTemplate { return new TwigPageTemplate($this->createTitleTemplate()); } public function getRenderer(): TemplateRenderer { return new TwigRenderer(); } } /** * А эта Конкретная Фабрика создает шаблоны PHPTemplate. */ class PHPTemplateFactory implements TemplateFactory { public function createTitleTemplate(): TitleTemplate { return new PHPTemplateTitleTemplate(); } public function createPageTemplate(): PageTemplate { return new PHPTemplatePageTemplate($this->createTitleTemplate()); } public function getRenderer(): TemplateRenderer { return new PHPTemplateRenderer(); } } /** * Каждый отдельный тип продукта должен иметь отдельный интерфейс. Все варианты * продукта должны соответствовать одному интерфейсу. * * Например, этот интерфейс Абстрактного Продукта описывает поведение шаблонов * заголовков страниц. */ interface TitleTemplate { public function getTemplateString(): string; } /** * Этот Конкретный Продукт предоставляет шаблоны заголовков страниц Twig. */ class TwigTitleTemplate implements TitleTemplate { public function getTemplateString(): string { return "<h1>{{ title }}</h1>"; } } /** * А этот Конкретный Продукт предоставляет шаблоны заголовков страниц * PHPTemplate. */ class PHPTemplateTitleTemplate implements TitleTemplate { public function getTemplateString(): string { return "<h1><?= \$title; ?></h1>"; } } /** * Это еще один тип Абстрактного Продукта, который описывает шаблоны целых * страниц. */ interface PageTemplate { public function getTemplateString(): string; } /** * Шаблон страниц использует под-шаблон заголовков, поэтому мы должны * предоставить способ установить объект для этого под-шаблона. Абстрактная * фабрика позаботится о том, чтобы подать сюда под-шаблон подходящего типа. */ abstract class BasePageTemplate implements PageTemplate { protected $titleTemplate; public function __construct(TitleTemplate $titleTemplate) { $this->titleTemplate = $titleTemplate; } } /** * Вариант шаблонов страниц Twig. */ class TwigPageTemplate extends BasePageTemplate { public function getTemplateString(): string { $renderedTitle = $this->titleTemplate->getTemplateString(); return <<<HTML <div class="page"> $renderedTitle <article class="content">{{ content }}</article> </div> HTML; } } /** * Вариант шаблонов страниц PHPTemplate. */ class PHPTemplatePageTemplate extends BasePageTemplate { public function getTemplateString(): string { $renderedTitle = $this->titleTemplate->getTemplateString(); return <<<HTML <div class="page"> $renderedTitle <article class="content"><?= \$content; ?></article> </div> HTML; } } /** * Классы отрисовки отвечают за преобразовании строк шаблонов в конечный HTML * код. Каждый такой класс устроен по-раному и ожидает на входе шаблоны только * своего типа. Работа с шаблонами через фабрику позволяет вам избавиться от * риска подать в отрисовщик шаблон не того типа. */ interface TemplateRenderer { public function render(string $templateString, array $arguments = []): string; } /** * Отрисовщик шаблонов Twig. */ class TwigRenderer implements TemplateRenderer { public function render(string $templateString, array $arguments = []): string { return \Twig::render($templateString, $arguments); } } /** * Отрисовщик шаблонов PHPTemplate. Оговорюсь, что эта реализация очень простая, * если не примитивная. В реальных проектах используйте `eval` с * осмотрительностью, т.к. неправильное использование этой функции может * привести к дырам безопасности. */ class PHPTemplateRenderer implements TemplateRenderer { public function render(string $templateString, array $arguments = []): string { extract($arguments); ob_start(); eval(' ?>' . $templateString . '<?php '); $result = ob_get_contents(); ob_end_clean(); return $result; } } /** * Клиентский код. Обратите внимание, что он принимает класс Абстрактной Фабрики * в качестве параметра, что позволяет клиенту работать с любым типом конкретной * фабрики. */ class Page { public $title; public $content; public function __construct($title, $content) { $this->title = $title; $this->content = $content; } // Вот как вы бы использовали этот шаблон в дальнейшем. Обратите внимание, // что класс страницы не зависит ни от классов шаблонов, ни от классов // отрисовки. public function render(TemplateFactory $factory): string { $pageTemplate = $factory->createPageTemplate(); $renderer = $factory->getRenderer(); return $renderer->render($pageTemplate->getTemplateString(), [ 'title' => $this->title, 'content' => $this->content ]); } } /** * Теперь в других частях приложения клиентский код может принимать фабричные * объекты любого типа. */ $page = new Page('Sample page', 'This it the body.'); echo "Testing actual rendering with the PHPTemplate factory:\n"; echo $page->render(new PHPTemplateFactory()); // Можете убрать комментарии, если у вас установлен Twig. // echo "Testing rendering with the Twig factory:\n"; echo $page->render(new // TwigTemplateFactory());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  (null)
number of ops:  22
compiled vars:  !0 = $page
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   DECLARE_CLASS                                            'refactoringguru%5Cabstractfactory%5Crealworld%5Ctwigtemplatefactory'
   70     1        DECLARE_CLASS                                            'refactoringguru%5Cabstractfactory%5Crealworld%5Cphptemplatefactory'
  103     2        DECLARE_CLASS                                            'refactoringguru%5Cabstractfactory%5Crealworld%5Ctwigtitletemplate'
  115     3        DECLARE_CLASS                                            'refactoringguru%5Cabstractfactory%5Crealworld%5Cphptemplatetitletemplate'
  137     4        DECLARE_CLASS                                            'refactoringguru%5Cabstractfactory%5Crealworld%5Cbasepagetemplate'
  150     5        DECLARE_CLASS                                            'refactoringguru%5Cabstractfactory%5Crealworld%5Ctwigpagetemplate', 'refactoringguru%5Cabstractfactory%5Crealworld%5Cbasepagetemplate'
  168     6        DECLARE_CLASS                                            'refactoringguru%5Cabstractfactory%5Crealworld%5Cphptemplatepagetemplate', 'refactoringguru%5Cabstractfactory%5Crealworld%5Cbasepagetemplate'
  197     7        DECLARE_CLASS                                            'refactoringguru%5Cabstractfactory%5Crealworld%5Ctwigrenderer'
  211     8        DECLARE_CLASS                                            'refactoringguru%5Cabstractfactory%5Crealworld%5Cphptemplaterenderer'
  264     9        NEW                                              $1      'RefactoringGuru%5CAbstractFactory%5CRealWorld%5CPage'
         10        SEND_VAL_EX                                              'Sample+page'
         11        SEND_VAL_EX                                              'This+it+the+body.'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !0, $1
  266    14        ECHO                                                     'Testing+actual+rendering+with+the+PHPTemplate+factory%3A%0A'
  267    15        INIT_METHOD_CALL                                         !0, 'render'
         16        NEW                                              $4      'RefactoringGuru%5CAbstractFactory%5CRealWorld%5CPHPTemplateFactory'
         17        DO_FCALL                                      0          
         18        SEND_VAR_NO_REF_EX                                       $4
         19        DO_FCALL                                      0  $6      
         20        ECHO                                                     $6
  273    21      > RETURN                                                   1

Class RefactoringGuru\AbstractFactory\RealWorld\TemplateFactory:
Function createtitletemplate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  createTitleTemplate
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   VERIFY_RETURN_TYPE                                       
          1      > RETURN                                                   null

End of function createtitletemplate

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

End of function createpagetemplate

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

End of function getrenderer

End of class RefactoringGuru\AbstractFactory\RealWorld\TemplateFactory.

Class RefactoringGuru\AbstractFactory\RealWorld\TwigTemplateFactory:
Function createtitletemplate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  createTitleTemplate
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   NEW                                              $0      'RefactoringGuru%5CAbstractFactory%5CRealWorld%5CTwigTitleTemplate'
          1        DO_FCALL                                      0          
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
   54     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function createtitletemplate

Function createpagetemplate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  createPageTemplate
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   58     0  E >   NEW                                              $0      'RefactoringGuru%5CAbstractFactory%5CRealWorld%5CTwigPageTemplate'
          1        INIT_METHOD_CALL                                         'createTitleTemplate'
          2        DO_FCALL                                      0  $1      
          3        SEND_VAR_NO_REF_EX                                       $1
          4        DO_FCALL                                      0          
          5        VERIFY_RETURN_TYPE                                       $0
          6      > RETURN                                                   $0
   59     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function createpagetemplate

Function getrenderer:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  getRenderer
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E >   NEW                                              $0      'RefactoringGuru%5CAbstractFactory%5CRealWorld%5CTwigRenderer'
          1        DO_FCALL                                      0          
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
   64     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function getrenderer

End of class RefactoringGuru\AbstractFactory\RealWorld\TwigTemplateFactory.

Class RefactoringGuru\AbstractFactory\RealWorld\PHPTemplateFactory:
Function createtitletemplate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  createTitleTemplate
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   74     0  E >   NEW                                              $0      'RefactoringGuru%5CAbstractFactory%5CRealWorld%5CPHPTemplateTitleTemplate'
          1        DO_FCALL                                      0          
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
   75     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function createtitletemplate

Function createpagetemplate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  createPageTemplate
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   79     0  E >   NEW                                              $0      'RefactoringGuru%5CAbstractFactory%5CRealWorld%5CPHPTemplatePageTemplate'
          1        INIT_METHOD_CALL                                         'createTitleTemplate'
          2        DO_FCALL                                      0  $1      
          3        SEND_VAR_NO_REF_EX                                       $1
          4        DO_FCALL                                      0          
          5        VERIFY_RETURN_TYPE                                       $0
          6      > RETURN                                                   $0
   80     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function createpagetemplate

Function getrenderer:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  getRenderer
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   84     0  E >   NEW                                              $0      'RefactoringGuru%5CAbstractFactory%5CRealWorld%5CPHPTemplateRenderer'
          1        DO_FCALL                                      0          
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
   85     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function getrenderer

End of class RefactoringGuru\AbstractFactory\RealWorld\PHPTemplateFactory.

Class RefactoringGuru\AbstractFactory\RealWorld\TitleTemplate:
Function gettemplatestring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  getTemplateString
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   97     0  E >   VERIFY_RETURN_TYPE                                       
          1      > RETURN                                                   null

End of function gettemplatestring

End of class RefactoringGuru\AbstractFactory\RealWorld\TitleTemplate.

Class RefactoringGuru\AbstractFactory\RealWorld\TwigTitleTemplate:
Function gettemplatestring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  getTemplateString
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  107     0  E > > RETURN                                                   '%3Ch1%3E%7B%7B+title+%7D%7D%3C%2Fh1%3E'
  108     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function gettemplatestring

End of class RefactoringGuru\AbstractFactory\RealWorld\TwigTitleTemplate.

Class RefactoringGuru\AbstractFactory\RealWorld\PHPTemplateTitleTemplate:
Function gettemplatestring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  getTemplateString
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  119     0  E > > RETURN                                                   '%3Ch1%3E%3C%3F%3D+%24title%3B+%3F%3E%3C%2Fh1%3E'
  120     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function gettemplatestring

End of class RefactoringGuru\AbstractFactory\RealWorld\PHPTemplateTitleTemplate.

Class RefactoringGuru\AbstractFactory\RealWorld\PageTemplate:
Function gettemplatestring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  getTemplateString
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  129     0  E >   VERIFY_RETURN_TYPE                                       
          1      > RETURN                                                   null

End of function gettemplatestring

End of class RefactoringGuru\AbstractFactory\RealWorld\PageTemplate.

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

End of function __construct

End of class RefactoringGuru\AbstractFactory\RealWorld\BasePageTemplate.

Class RefactoringGuru\AbstractFactory\RealWorld\TwigPageTemplate:
Function gettemplatestring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  getTemplateString
number of ops:  11
compiled vars:  !0 = $renderedTitle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  154     0  E >   FETCH_OBJ_R                                      ~1      'titleTemplate'
          1        INIT_METHOD_CALL                                         ~1, 'getTemplateString'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
  157     4        ROPE_INIT                                     3  ~5      '%3Cdiv+class%3D%22page%22%3E%0A++++'
  158     5        ROPE_ADD                                      1  ~5      ~5, !0
          6        ROPE_END                                      2  ~4      ~5, '%0A++++%3Carticle+class%3D%22content%22%3E%7B%7B+content+%7D%7D%3C%2Farticle%3E%0A%3C%2Fdiv%3E'
          7        VERIFY_RETURN_TYPE                                       ~4
          8      > RETURN                                                   ~4
  162     9*       VERIFY_RETURN_TYPE                                       
         10*     > RETURN                                                   null

End of function gettemplatestring

End of class RefactoringGuru\AbstractFactory\RealWorld\TwigPageTemplate.

Class RefactoringGuru\AbstractFactory\RealWorld\PHPTemplatePageTemplate:
Function gettemplatestring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  getTemplateString
number of ops:  11
compiled vars:  !0 = $renderedTitle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  172     0  E >   FETCH_OBJ_R                                      ~1      'titleTemplate'
          1        INIT_METHOD_CALL                                         ~1, 'getTemplateString'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
  175     4        ROPE_INIT                                     3  ~5      '%3Cdiv+class%3D%22page%22%3E%0A++++'
  176     5        ROPE_ADD                                      1  ~5      ~5, !0
          6        ROPE_END                                      2  ~4      ~5, '%0A++++%3Carticle+class%3D%22content%22%3E%3C%3F%3D+%24content%3B+%3F%3E%3C%2Farticle%3E%0A%3C%2Fdiv%3E'
          7        VERIFY_RETURN_TYPE                                       ~4
          8      > RETURN                                                   ~4
  180     9*       VERIFY_RETURN_TYPE                                       
         10*     > RETURN                                                   null

End of function gettemplatestring

End of class RefactoringGuru\AbstractFactory\RealWorld\PHPTemplatePageTemplate.

Class RefactoringGuru\AbstractFactory\RealWorld\TemplateRenderer:
Function render:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  render
number of ops:  4
compiled vars:  !0 = $templateString, !1 = $arguments
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  191     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
          2        VERIFY_RETURN_TYPE                                       
          3      > RETURN                                                   null

End of function render

End of class RefactoringGuru\AbstractFactory\RealWorld\TemplateRenderer.

Class RefactoringGuru\AbstractFactory\RealWorld\TwigRenderer:
Function render:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  render
number of ops:  10
compiled vars:  !0 = $templateString, !1 = $arguments
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  199     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
  201     2        INIT_STATIC_METHOD_CALL                                  'Twig', 'render'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $2      
          6        VERIFY_RETURN_TYPE                                       $2
          7      > RETURN                                                   $2
  202     8*       VERIFY_RETURN_TYPE                                       
          9*     > RETURN                                                   null

End of function render

End of class RefactoringGuru\AbstractFactory\RealWorld\TwigRenderer.

Class RefactoringGuru\AbstractFactory\RealWorld\PHPTemplateRenderer:
Function render:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  render
number of ops:  19
compiled vars:  !0 = $templateString, !1 = $arguments, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  213     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
  215     2        INIT_NS_FCALL_BY_NAME                                    'RefactoringGuru%5CAbstractFactory%5CRealWorld%5Cextract'
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0          
  217     5        INIT_NS_FCALL_BY_NAME                                    'RefactoringGuru%5CAbstractFactory%5CRealWorld%5Cob_start'
          6        DO_FCALL                                      0          
  218     7        CONCAT                                           ~5      '+%3F%3E', !0
          8        CONCAT                                           ~6      ~5, '%3C%3Fphp+'
          9        INCLUDE_OR_EVAL                                          ~6, EVAL
  219    10        INIT_NS_FCALL_BY_NAME                                    'RefactoringGuru%5CAbstractFactory%5CRealWorld%5Cob_get_contents'
         11        DO_FCALL                                      0  $8      
         12        ASSIGN                                                   !2, $8
  220    13        INIT_NS_FCALL_BY_NAME                                    'RefactoringGuru%5CAbstractFactory%5CRealWorld%5Cob_end_clean'
         14        DO_FCALL                                      0          
  222    15        VERIFY_RETURN_TYPE                                       !2
         16      > RETURN                                                   !2
  223    17*       VERIFY_RETURN_TYPE                                       
         18*     > RETURN                                                   null

End of function render

End of class RefactoringGuru\AbstractFactory\RealWorld\PHPTemplateRenderer.

Class RefactoringGuru\AbstractFactory\RealWorld\Page:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  __construct
number of ops:  7
compiled vars:  !0 = $title, !1 = $content
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  238     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  240     2        ASSIGN_OBJ                                               'title'
          3        OP_DATA                                                  !0
  241     4        ASSIGN_OBJ                                               'content'
          5        OP_DATA                                                  !1
  242     6      > RETURN                                                   null

End of function __construct

Function render:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44JLl
function name:  render
number of ops:  21
compiled vars:  !0 = $factory, !1 = $pageTemplate, !2 = $renderer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  247     0  E >   RECV                                             !0      
  249     1        INIT_METHOD_CALL                                         !0, 'createPageTemplate'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !1, $3
  251     4        INIT_METHOD_CALL                                         !0, 'getRenderer'
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !2, $5
  253     7        INIT_METHOD_CALL                                         !2, 'render'
          8        INIT_METHOD_CALL                                         !1, 'getTemplateString'
          9        DO_FCALL                                      0  $7      
         10        SEND_VAR_NO_REF_EX                                       $7
  254    11        FETCH_OBJ_R                                      ~8      'title'
         12        INIT_ARRAY                                       ~9      ~8, 'title'
  255    13        FETCH_OBJ_R                                      ~10     'content'
         14        ADD_ARRAY_ELEMENT                                ~9      ~10, 'content'
         15        SEND_VAL_EX                                              ~9
         16        DO_FCALL                                      0  $11     
         17        VERIFY_RETURN_TYPE                                       $11
         18      > RETURN                                                   $11
  257    19*       VERIFY_RETURN_TYPE                                       
         20*     > RETURN                                                   null

End of function render

End of class RefactoringGuru\AbstractFactory\RealWorld\Page.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175 ms | 1412 KiB | 21 Q