3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Update manifest generator for Chrome * * @category [cv-pls] * @package Chrome * @author Chris Wright <info@daverandom.com> */ class ChromeUpdateManifestGenerator { /** * @var string Namespace URL for manifest XML */ private $nsUrl = 'http://www.google.com/update2/response'; /** * Create a new node, append it to the specified parent and add attributes * * @param \DOMNode $parent * @param string $tagName * @param array $attributes * @return \DOMElement */ private function appendNode(\DOMNode $parent, $tagName, array $attributes = []) { $newNode = ($parent->ownerDocument ?: $parent)->createElementNS($this->nsUrl, $tagName); foreach ($attributes as $name => $value) { $newNode->setAttribute($name, $value); } $parent->appendChild($newNode); } /** * Generate the update manifest document * * @param string $appId * @param string $version * @param string $packageUrl * @return \DOMDocument */ public function generate($appId, $version, $packageUrl) { $document = new \DOMDocument('1.0', 'utf-8'); $document->formatOutput = true; $rootEl = $this->appendNode($document, 'gupdate', ['protocol' => '2.0']); $appEl = $this->appendNode($rootEl, 'app', ['appid' => $appId]); $this->appendNode($appEl, 'updatecheck', ['codebase' => $packageUrl, 'version' => $version]); return $document; } } $obj = new ChromeUpdateManifestGenerator; echo $obj->generate('abcdef', '1.2.3.4', 'http://foo.com/')->saveXML();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bCOfZ
function name:  (null)
number of ops:  12
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   58     0  E >   NEW                                              $1      'ChromeUpdateManifestGenerator'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   59     3        INIT_METHOD_CALL                                         !0, 'generate'
          4        SEND_VAL_EX                                              'abcdef'
          5        SEND_VAL_EX                                              '1.2.3.4'
          6        SEND_VAL_EX                                              'http%3A%2F%2Ffoo.com%2F'
          7        DO_FCALL                                      0  $4      
          8        INIT_METHOD_CALL                                         $4, 'saveXML'
          9        DO_FCALL                                      0  $5      
         10        ECHO                                                     $5
         11      > RETURN                                                   1

Class ChromeUpdateManifestGenerator:
Function appendnode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/bCOfZ
function name:  appendNode
number of ops:  26
compiled vars:  !0 = $parent, !1 = $tagName, !2 = $attributes, !3 = $newNode, !4 = $value, !5 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <array>
   27     3        FETCH_OBJ_R                                      ~6      !0, 'ownerDocument'
          4        JMP_SET                                          ~7      ~6, ->6
          5        QM_ASSIGN                                        ~7      !0
          6        INIT_METHOD_CALL                                         ~7, 'createElementNS'
          7        CHECK_FUNC_ARG                                           
          8        FETCH_OBJ_FUNC_ARG                               $8      'nsUrl'
          9        SEND_FUNC_ARG                                            $8
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0  $9      
         12        ASSIGN                                                   !3, $9
   29    13      > FE_RESET_R                                       $11     !2, ->21
         14    > > FE_FETCH_R                                       ~12     $11, !4, ->21
         15    >   ASSIGN                                                   !5, ~12
   30    16        INIT_METHOD_CALL                                         !3, 'setAttribute'
         17        SEND_VAR_EX                                              !5
         18        SEND_VAR_EX                                              !4
         19        DO_FCALL                                      0          
   29    20      > JMP                                                      ->14
         21    >   FE_FREE                                                  $11
   33    22        INIT_METHOD_CALL                                         !0, 'appendChild'
         23        SEND_VAR_EX                                              !3
         24        DO_FCALL                                      0          
   34    25      > RETURN                                                   null

End of function appendnode

Function generate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bCOfZ
function name:  generate
number of ops:  32
compiled vars:  !0 = $appId, !1 = $version, !2 = $packageUrl, !3 = $document, !4 = $rootEl, !5 = $appEl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   46     3        NEW                                              $6      'DOMDocument'
          4        SEND_VAL_EX                                              '1.0'
          5        SEND_VAL_EX                                              'utf-8'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !3, $6
   47     8        ASSIGN_OBJ                                               !3, 'formatOutput'
          9        OP_DATA                                                  <true>
   49    10        INIT_METHOD_CALL                                         'appendNode'
         11        SEND_VAR                                                 !3
         12        SEND_VAL                                                 'gupdate'
         13        SEND_VAL                                                 <array>
         14        DO_FCALL                                      0  $10     
         15        ASSIGN                                                   !4, $10
   50    16        INIT_METHOD_CALL                                         'appendNode'
         17        SEND_VAR                                                 !4
         18        SEND_VAL                                                 'app'
         19        INIT_ARRAY                                       ~12     !0, 'appid'
         20        SEND_VAL                                                 ~12
         21        DO_FCALL                                      0  $13     
         22        ASSIGN                                                   !5, $13
   51    23        INIT_METHOD_CALL                                         'appendNode'
         24        SEND_VAR                                                 !5
         25        SEND_VAL                                                 'updatecheck'
         26        INIT_ARRAY                                       ~15     !2, 'codebase'
         27        ADD_ARRAY_ELEMENT                                ~15     !1, 'version'
         28        SEND_VAL                                                 ~15
         29        DO_FCALL                                      0          
   53    30      > RETURN                                                   !3
   54    31*     > RETURN                                                   null

End of function generate

End of class ChromeUpdateManifestGenerator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.64 ms | 1399 KiB | 13 Q