3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace RefactoringGuru\Command\RealWorld; /** * Интерфейс Команды объявляет основной метод выполнения, а также несколько * вспомогательных методов для получения метаданных команды. */ interface Command { public function execute(): void; public function getId(): int; public function getStatus(): int; } /** * Базовая Команда скрейпинга устанавливает базовую инфраструктуру загрузки, * общую для всех конкретных команд скрейпинга. */ abstract class WebScrapingCommand implements Command { public $id; public $status = 0; /** * @var string URL для скрейпинга. */ public $url; public function __construct(string $url) { $this->url = $url; } public function getId(): int { return $this->id; } public function getStatus(): int { return $this->status; } public function getURL(): string { return $this->url; } /** * Поскольку методы выполнения для всех команд скрейпинга очень похожи, мы * можем предоставить реализацию по умолчанию, позволив подклассам * переопределить её при необходимости. * * Шш! Наблюдательный читатель может обнаружить здесь другой поведенческий * паттерн в действии. */ public function execute(): void { $html = $this->download(); $this->parse($html); $this->complete(); } public function download(): string { $html = file_get_contents($this->getURL()); echo "WebScrapingCommand: Downloaded {$this->url}\n"; return $html; } abstract public function parse(string $html): void; public function complete(): void { $this->status = 1; Queue::get()->completeCommand($this); } } /** * Конкретная Команда для извлечения списка жанров фильма. */ class IMDBGenresScrapingCommand extends WebScrapingCommand { public function __construct() { $this->url = "https://www.imdb.com/feature/genre/"; } /** * Извлечение всех жанров и их поисковых URL со страницы: * https://www.imdb.com/feature/genre/ */ public function parse($html): void { preg_match_all("|href=\"(https://www.imdb.com/search/title\?genres=.*?)\"|", $html, $matches); echo "IMDBGenresScrapingCommand: Discovered " . count($matches[1]) . " genres.\n"; foreach ($matches[1] as $genre) { Queue::get()->add(new IMDBGenrePageScrapingCommand($genre)); } } } /** * Конкретная Команда для извлечения списка фильмов определённого жанра. */ class IMDBGenrePageScrapingCommand extends WebScrapingCommand { private $page; public function __construct(string $url, int $page = 1) { parent::__construct($url); $this->page = $page; } public function getURL(): string { return $this->url . '?page=' . $this->page; } /** * Извлечение всех фильмов со страницы вроде этой: * https://www.imdb.com/search/title?genres=sci-fi&explore=title_type,genres */ public function parse(string $html): void { preg_match_all("|href=\"(/title/.*?/)\?ref_=adv_li_tt\"|", $html, $matches); echo "IMDBGenrePageScrapingCommand: Discovered " . count($matches[1]) . " movies.\n"; foreach ($matches[1] as $moviePath) { $url = "https://www.imdb.com" . $moviePath; Queue::get()->add(new IMDBMovieScrapingCommand($url)); } // Извлечение URL следующей страницы. if (preg_match("|Next &#187;</a>|", $html)) { Queue::get()->add(new IMDBGenrePageScrapingCommand($this->url, $this->page + 1)); } } } /** * Конкретная Команда для извлечения подробных сведений о фильме. */ class IMDBMovieScrapingCommand extends WebScrapingCommand { /** * Получить информацию о фильме с подобной страницы: * https://www.imdb.com/title/tt4154756/ */ public function parse(string $html): void { if (preg_match("|<h1 itemprop=\"name\" class=\"\">(.*?)</h1>|", $html, $matches)) { $title = $matches[1]; } echo "IMDBMovieScrapingCommand: Parsed movie $title.\n"; } } /** * Класс Очередь действует как Отправитель. Он складывает объекты команд в стек * и выполняет их поочерёдно. Если выполнение скрипта внезапно завершится, * очередь и все её команды можно будет легко восстановить, и вам не придётся * повторять все выполненные команды. * * Обратите внимание, что это очень примитивная реализация очереди команд, * которая хранит команды в локальной базе данных SQLite. Существуют десятки * надёжных реализаций очереди, доступных для использования в реальных * приложениях. */ class Queue { private $db; public function __construct() { $this->db = new \SQLite3(__DIR__ . '/commands.sqlite', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE); $this->db->query('CREATE TABLE IF NOT EXISTS "commands" ( "id" INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL, "command" TEXT, "status" INTEGER )'); } public function isEmpty(): bool { $query = 'SELECT COUNT("id") FROM "commands" WHERE status = 0'; return $this->db->querySingle($query) === 0; } public function add(Command $command): void { $query = 'INSERT INTO commands (command, status) VALUES (:command, :status)'; $statement = $this->db->prepare($query); $statement->bindValue(':command', base64_encode(serialize($command))); $statement->bindValue(':status', $command->getStatus()); $statement->execute(); } public function getCommand(): Command { $query = 'SELECT * FROM "commands" WHERE "status" = 0 LIMIT 1'; $record = $this->db->querySingle($query, true); $command = unserialize(base64_decode($record["command"])); $command->id = $record['id']; return $command; } public function completeCommand(Command $command): void { $query = 'UPDATE commands SET status = :status WHERE id = :id'; $statement = $this->db->prepare($query); $statement->bindValue(':status', $command->getStatus()); $statement->bindValue(':id', $command->getId()); $statement->execute(); } public function work(): void { while (!$this->isEmpty()) { $command = $this->getCommand(); $command->execute(); } } /** * Для удобства объект Очереди является Одиночкой. */ public static function get(): Queue { static $instance; if (!$instance) { $instance = new Queue(); } return $instance; } } /** * Клиентский код. */ $queue = Queue::get(); if ($queue->isEmpty()) { $queue->add(new IMDBGenresScrapingCommand()); } $queue->work();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/336C9
function name:  (null)
number of ops:  18
compiled vars:  !0 = $queue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   DECLARE_CLASS                                            'refactoringguru%5Ccommand%5Crealworld%5Cwebscrapingcommand'
   88     1        DECLARE_CLASS                                            'refactoringguru%5Ccommand%5Crealworld%5Cimdbgenresscrapingcommand', 'refactoringguru%5Ccommand%5Crealworld%5Cwebscrapingcommand'
  113     2        DECLARE_CLASS                                            'refactoringguru%5Ccommand%5Crealworld%5Cimdbgenrepagescrapingcommand', 'refactoringguru%5Ccommand%5Crealworld%5Cwebscrapingcommand'
  152     3        DECLARE_CLASS                                            'refactoringguru%5Ccommand%5Crealworld%5Cimdbmoviescrapingcommand', 'refactoringguru%5Ccommand%5Crealworld%5Cwebscrapingcommand'
  255     4        INIT_STATIC_METHOD_CALL                                  'RefactoringGuru%5CCommand%5CRealWorld%5CQueue', 'get'
          5        DO_FCALL                                      0  $1      
          6        ASSIGN                                                   !0, $1
  257     7        INIT_METHOD_CALL                                         !0, 'isEmpty'
          8        DO_FCALL                                      0  $3      
          9      > JMPZ                                                     $3, ->15
  258    10    >   INIT_METHOD_CALL                                         !0, 'add'
         11        NEW                                              $4      'RefactoringGuru%5CCommand%5CRealWorld%5CIMDBGenresScrapingCommand'
         12        DO_FCALL                                      0          
         13        SEND_VAR_NO_REF_EX                                       $4
         14        DO_FCALL                                      0          
  261    15    >   INIT_METHOD_CALL                                         !0, 'work'
         16        DO_FCALL                                      0          
         17      > RETURN                                                   1

Class RefactoringGuru\Command\RealWorld\Command:
Function execute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  execute
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E > > RETURN                                                   null

End of function execute

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

End of function getid

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

End of function getstatus

End of class RefactoringGuru\Command\RealWorld\Command.

Class RefactoringGuru\Command\RealWorld\WebScrapingCommand:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  __construct
number of ops:  4
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   35     1        ASSIGN_OBJ                                               'url'
          2        OP_DATA                                                  !0
   36     3      > RETURN                                                   null

End of function __construct

Function getid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  getId
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   FETCH_OBJ_R                                      ~0      'id'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   41     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getid

Function getstatus:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  getStatus
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   FETCH_OBJ_R                                      ~0      'status'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   46     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getstatus

Function geturl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  getURL
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   FETCH_OBJ_R                                      ~0      'url'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   51     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function geturl

Function execute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  execute
number of ops:  9
compiled vars:  !0 = $html
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E >   INIT_METHOD_CALL                                         'download'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   64     3        INIT_METHOD_CALL                                         'parse'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
   65     6        INIT_METHOD_CALL                                         'complete'
          7        DO_FCALL                                      0          
   66     8      > RETURN                                                   null

End of function execute

Function download:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  download
number of ops:  15
compiled vars:  !0 = $html
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   70     0  E >   INIT_NS_FCALL_BY_NAME                                    'RefactoringGuru%5CCommand%5CRealWorld%5Cfile_get_contents'
          1        INIT_METHOD_CALL                                         'getURL'
          2        DO_FCALL                                      0  $1      
          3        SEND_VAR_NO_REF_EX                                       $1
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   71     6        ROPE_INIT                                     3  ~6      'WebScrapingCommand%3A+Downloaded+'
          7        FETCH_OBJ_R                                      ~4      'url'
          8        ROPE_ADD                                      1  ~6      ~6, ~4
          9        ROPE_END                                      2  ~5      ~6, '%0A'
         10        ECHO                                                     ~5
   73    11        VERIFY_RETURN_TYPE                                       !0
         12      > RETURN                                                   !0
   74    13*       VERIFY_RETURN_TYPE                                       
         14*     > RETURN                                                   null

End of function download

Function parse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  parse
number of ops:  2
compiled vars:  !0 = $html
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   76     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function parse

Function complete:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  complete
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   80     0  E >   ASSIGN_OBJ                                               'status'
          1        OP_DATA                                                  1
   81     2        INIT_STATIC_METHOD_CALL                                  'RefactoringGuru%5CCommand%5CRealWorld%5CQueue', 'get'
          3        DO_FCALL                                      0  $1      
          4        INIT_METHOD_CALL                                         $1, 'completeCommand'
          5        FETCH_THIS                                       $2      
          6        SEND_VAR_EX                                              $2
          7        DO_FCALL                                      0          
   82     8      > RETURN                                                   null

End of function complete

End of class RefactoringGuru\Command\RealWorld\WebScrapingCommand.

Class RefactoringGuru\Command\RealWorld\IMDBGenresScrapingCommand:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   92     0  E >   ASSIGN_OBJ                                               'url'
          1        OP_DATA                                                  'https%3A%2F%2Fwww.imdb.com%2Ffeature%2Fgenre%2F'
   93     2      > RETURN                                                   null

End of function __construct

Function parse:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 26
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/336C9
function name:  parse
number of ops:  28
compiled vars:  !0 = $html, !1 = $matches, !2 = $genre
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   99     0  E >   RECV                                             !0      
  101     1        INIT_NS_FCALL_BY_NAME                                    'RefactoringGuru%5CCommand%5CRealWorld%5Cpreg_match_all'
          2        SEND_VAL_EX                                              '%7Chref%3D%22%28https%3A%2F%2Fwww.imdb.com%2Fsearch%2Ftitle%5C%3Fgenres%3D.%2A%3F%29%22%7C'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0          
  102     6        INIT_NS_FCALL_BY_NAME                                    'RefactoringGuru%5CCommand%5CRealWorld%5Ccount'
          7        CHECK_FUNC_ARG                                           
          8        FETCH_DIM_FUNC_ARG                               $4      !1, 1
          9        SEND_FUNC_ARG                                            $4
         10        DO_FCALL                                      0  $5      
         11        CONCAT                                           ~6      'IMDBGenresScrapingCommand%3A+Discovered+', $5
         12        CONCAT                                           ~7      ~6, '+genres.%0A'
         13        ECHO                                                     ~7
  104    14        FETCH_DIM_R                                      ~8      !1, 1
         15      > FE_RESET_R                                       $9      ~8, ->26
         16    > > FE_FETCH_R                                               $9, !2, ->26
  105    17    >   INIT_STATIC_METHOD_CALL                                  'RefactoringGuru%5CCommand%5CRealWorld%5CQueue', 'get'
         18        DO_FCALL                                      0  $10     
         19        INIT_METHOD_CALL                                         $10, 'add'
         20        NEW                                              $11     'RefactoringGuru%5CCommand%5CRealWorld%5CIMDBGenrePageScrapingCommand'
         21        SEND_VAR_EX                                              !2
         22        DO_FCALL                                      0          
         23        SEND_VAR_NO_REF_EX                                       $11
         24        DO_FCALL                                      0          
  104    25      > JMP                                                      ->16
         26    >   FE_FREE                                                  $9
  107    27      > RETURN                                                   null

End of function parse

End of class RefactoringGuru\Command\RealWorld\IMDBGenresScrapingCommand.

Class RefactoringGuru\Command\RealWorld\IMDBGenrePageScrapingCommand:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  __construct
number of ops:  8
compiled vars:  !0 = $url, !1 = $page
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  117     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      1
  119     2        INIT_STATIC_METHOD_CALL                                  
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
  120     5        ASSIGN_OBJ                                               'page'
          6        OP_DATA                                                  !1
  121     7      > RETURN                                                   null

End of function __construct

Function geturl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  getURL
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  125     0  E >   FETCH_OBJ_R                                      ~0      'url'
          1        CONCAT                                           ~1      ~0, '%3Fpage%3D'
          2        FETCH_OBJ_R                                      ~2      'page'
          3        CONCAT                                           ~3      ~1, ~2
          4        VERIFY_RETURN_TYPE                                       ~3
          5      > RETURN                                                   ~3
  126     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function geturl

Function parse:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 28
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 28
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 47
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
Branch analysis from position: 28
filename:       /in/336C9
function name:  parse
number of ops:  48
compiled vars:  !0 = $html, !1 = $matches, !2 = $moviePath, !3 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  132     0  E >   RECV                                             !0      
  134     1        INIT_NS_FCALL_BY_NAME                                    'RefactoringGuru%5CCommand%5CRealWorld%5Cpreg_match_all'
          2        SEND_VAL_EX                                              '%7Chref%3D%22%28%2Ftitle%2F.%2A%3F%2F%29%5C%3Fref_%3Dadv_li_tt%22%7C'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0          
  135     6        INIT_NS_FCALL_BY_NAME                                    'RefactoringGuru%5CCommand%5CRealWorld%5Ccount'
          7        CHECK_FUNC_ARG                                           
          8        FETCH_DIM_FUNC_ARG                               $5      !1, 1
          9        SEND_FUNC_ARG                                            $5
         10        DO_FCALL                                      0  $6      
         11        CONCAT                                           ~7      'IMDBGenrePageScrapingCommand%3A+Discovered+', $6
         12        CONCAT                                           ~8      ~7, '+movies.%0A'
         13        ECHO                                                     ~8
  137    14        FETCH_DIM_R                                      ~9      !1, 1
         15      > FE_RESET_R                                       $10     ~9, ->28
         16    > > FE_FETCH_R                                               $10, !2, ->28
  138    17    >   CONCAT                                           ~11     'https%3A%2F%2Fwww.imdb.com', !2
         18        ASSIGN                                                   !3, ~11
  139    19        INIT_STATIC_METHOD_CALL                                  'RefactoringGuru%5CCommand%5CRealWorld%5CQueue', 'get'
         20        DO_FCALL                                      0  $13     
         21        INIT_METHOD_CALL                                         $13, 'add'
         22        NEW                                              $14     'RefactoringGuru%5CCommand%5CRealWorld%5CIMDBMovieScrapingCommand'
         23        SEND_VAR_EX                                              !3
         24        DO_FCALL                                      0          
         25        SEND_VAR_NO_REF_EX                                       $14
         26        DO_FCALL                                      0          
  137    27      > JMP                                                      ->16
         28    >   FE_FREE                                                  $10
  143    29        INIT_NS_FCALL_BY_NAME                                    'RefactoringGuru%5CCommand%5CRealWorld%5Cpreg_match'
         30        SEND_VAL_EX                                              '%7CNext+%26%23187%3B%3C%2Fa%3E%7C'
         31        SEND_VAR_EX                                              !0
         32        DO_FCALL                                      0  $17     
         33      > JMPZ                                                     $17, ->47
  144    34    >   INIT_STATIC_METHOD_CALL                                  'RefactoringGuru%5CCommand%5CRealWorld%5CQueue', 'get'
         35        DO_FCALL                                      0  $18     
         36        INIT_METHOD_CALL                                         $18, 'add'
         37        NEW                                              $19     'RefactoringGuru%5CCommand%5CRealWorld%5CIMDBGenrePageScrapingCommand'
         38        CHECK_FUNC_ARG                                           
         39        FETCH_OBJ_FUNC_ARG                               $20     'url'
         40        SEND_FUNC_ARG                                            $20
         41        FETCH_OBJ_R                                      ~21     'page'
         42        ADD                                              ~22     ~21, 1
         43        SEND_VAL_EX                                              ~22
         44        DO_FCALL                                      0          
         45        SEND_VAR_NO_REF_EX                                       $19
         46        DO_FCALL                                      0          
  146    47    > > RETURN                                                   null

End of function parse

End of class RefactoringGuru\Command\RealWorld\IMDBGenrePageScrapingCommand.

Class RefactoringGuru\Command\RealWorld\IMDBMovieScrapingCommand:
Function parse:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/336C9
function name:  parse
number of ops:  14
compiled vars:  !0 = $html, !1 = $matches, !2 = $title
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  158     0  E >   RECV                                             !0      
  160     1        INIT_NS_FCALL_BY_NAME                                    'RefactoringGuru%5CCommand%5CRealWorld%5Cpreg_match'
          2        SEND_VAL_EX                                              '%7C%3Ch1+itemprop%3D%22name%22+class%3D%22%22%3E%28.%2A%3F%29%3C%2Fh1%3E%7C'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $3      
          6      > JMPZ                                                     $3, ->9
  161     7    >   FETCH_DIM_R                                      ~4      !1, 1
          8        ASSIGN                                                   !2, ~4
  163     9    >   ROPE_INIT                                     3  ~7      'IMDBMovieScrapingCommand%3A+Parsed+movie+'
         10        ROPE_ADD                                      1  ~7      ~7, !2
         11        ROPE_END                                      2  ~6      ~7, '.%0A'
         12        ECHO                                                     ~6
  164    13      > RETURN                                                   null

End of function parse

End of class RefactoringGuru\Command\RealWorld\IMDBMovieScrapingCommand.

Class RefactoringGuru\Command\RealWorld\Queue:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  __construct
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  184     0  E >   NEW                                              $1      'SQLite3'
          1        SEND_VAL_EX                                              '%2Fin%2Fcommands.sqlite'
  185     2        FETCH_CONSTANT                                   ~2      'RefactoringGuru%5CCommand%5CRealWorld%5CSQLITE3_OPEN_CREATE'
          3        FETCH_CONSTANT                                   ~3      'RefactoringGuru%5CCommand%5CRealWorld%5CSQLITE3_OPEN_READWRITE'
          4        BW_OR                                            ~4      ~2, ~3
          5        SEND_VAL_EX                                              ~4
          6        DO_FCALL                                      0          
  184     7        ASSIGN_OBJ                                               'db'
  185     8        OP_DATA                                                  $1
  187     9        FETCH_OBJ_R                                      ~6      'db'
         10        INIT_METHOD_CALL                                         ~6, 'query'
         11        SEND_VAL_EX                                              'CREATE+TABLE+IF+NOT+EXISTS+%22commands%22+%28%0A++++++++++++%22id%22+INTEGER+PRIMARY+KEY+AUTO_INCREMENT+NOT+NULL%2C%0A++++++++++++%22command%22+TEXT%2C%0A++++++++++++%22status%22+INTEGER%0A++++++++%29'
         12        DO_FCALL                                      0          
  192    13      > RETURN                                                   null

End of function __construct

Function isempty:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  isEmpty
number of ops:  10
compiled vars:  !0 = $query
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  196     0  E >   ASSIGN                                                   !0, 'SELECT+COUNT%28%22id%22%29+FROM+%22commands%22+WHERE+status+%3D+0'
  198     1        FETCH_OBJ_R                                      ~2      'db'
          2        INIT_METHOD_CALL                                         ~2, 'querySingle'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $3      
          5        IS_IDENTICAL                                     ~4      $3, 0
          6        VERIFY_RETURN_TYPE                                       ~4
          7      > RETURN                                                   ~4
  199     8*       VERIFY_RETURN_TYPE                                       
          9*     > RETURN                                                   null

End of function isempty

Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  add
number of ops:  26
compiled vars:  !0 = $command, !1 = $query, !2 = $statement
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  201     0  E >   RECV                                             !0      
  203     1        ASSIGN                                                   !1, 'INSERT+INTO+commands+%28command%2C+status%29+VALUES+%28%3Acommand%2C+%3Astatus%29'
  204     2        FETCH_OBJ_R                                      ~4      'db'
          3        INIT_METHOD_CALL                                         ~4, 'prepare'
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !2, $5
  205     7        INIT_METHOD_CALL                                         !2, 'bindValue'
          8        SEND_VAL_EX                                              '%3Acommand'
          9        INIT_NS_FCALL_BY_NAME                                    'RefactoringGuru%5CCommand%5CRealWorld%5Cbase64_encode'
         10        INIT_NS_FCALL_BY_NAME                                    'RefactoringGuru%5CCommand%5CRealWorld%5Cserialize'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0  $7      
         13        SEND_VAR_NO_REF_EX                                       $7
         14        DO_FCALL                                      0  $8      
         15        SEND_VAR_NO_REF_EX                                       $8
         16        DO_FCALL                                      0          
  206    17        INIT_METHOD_CALL                                         !2, 'bindValue'
         18        SEND_VAL_EX                                              '%3Astatus'
         19        INIT_METHOD_CALL                                         !0, 'getStatus'
         20        DO_FCALL                                      0  $10     
         21        SEND_VAR_NO_REF_EX                                       $10
         22        DO_FCALL                                      0          
  207    23        INIT_METHOD_CALL                                         !2, 'execute'
         24        DO_FCALL                                      0          
  208    25      > RETURN                                                   null

End of function add

Function getcommand:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/336C9
function name:  getCommand
number of ops:  23
compiled vars:  !0 = $query, !1 = $record, !2 = $command
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  212     0  E >   ASSIGN                                                   !0, 'SELECT+%2A+FROM+%22commands%22+WHERE+%22status%22+%3D+0+LIMIT+1'
  213     1        FETCH_OBJ_R                                      ~4      'db'
          2        INIT_METHOD_CALL                                         ~4, 'querySingle'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAL_EX                                              <true>
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.83 ms | 1428 KiB | 25 Q