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 = []) { $document = $parent instanceof \DOMDocument ? $parent : $parent->ownerDocument; $newNode = $document->createElementNS($this->nsUrl, $tagName); foreach ($attributes as $name => $value) { $newNode->setAttribute($name, $value); } return $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/Z3uNp
function name:  (null)
number of ops:  12
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   59     0  E >   NEW                                              $1      'ChromeUpdateManifestGenerator'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   60     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 = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 25
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 25
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 25
Branch analysis from position: 18
Branch analysis from position: 25
filename:       /in/Z3uNp
function name:  appendNode
number of ops:  31
compiled vars:  !0 = $parent, !1 = $tagName, !2 = $attributes, !3 = $document, !4 = $newNode, !5 = $value, !6 = $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        INSTANCEOF                                               !0, 'DOMDocument'
          4      > JMPZ                                                     ~7, ->7
          5    >   QM_ASSIGN                                        ~8      !0
          6      > JMP                                                      ->9
          7    >   FETCH_OBJ_R                                      ~9      !0, 'ownerDocument'
          8        QM_ASSIGN                                        ~8      ~9
          9    >   ASSIGN                                                   !3, ~8
   28    10        INIT_METHOD_CALL                                         !3, 'createElementNS'
         11        CHECK_FUNC_ARG                                           
         12        FETCH_OBJ_FUNC_ARG                               $11     'nsUrl'
         13        SEND_FUNC_ARG                                            $11
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0  $12     
         16        ASSIGN                                                   !4, $12
   30    17      > FE_RESET_R                                       $14     !2, ->25
         18    > > FE_FETCH_R                                       ~15     $14, !5, ->25
         19    >   ASSIGN                                                   !6, ~15
   31    20        INIT_METHOD_CALL                                         !4, 'setAttribute'
         21        SEND_VAR_EX                                              !6
         22        SEND_VAR_EX                                              !5
         23        DO_FCALL                                      0          
   30    24      > JMP                                                      ->18
         25    >   FE_FREE                                                  $14
   34    26        INIT_METHOD_CALL                                         !0, 'appendChild'
         27        SEND_VAR_EX                                              !4
         28        DO_FCALL                                      0  $18     
         29      > RETURN                                                   $18
   35    30*     > 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/Z3uNp
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
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   47     3        NEW                                              $6      'DOMDocument'
          4        SEND_VAL_EX                                              '1.0'
          5        SEND_VAL_EX                                              'utf-8'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !3, $6
   48     8        ASSIGN_OBJ                                               !3, 'formatOutput'
          9        OP_DATA                                                  <true>
   50    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
   51    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
   52    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          
   54    30      > RETURN                                                   !3
   55    31*     > RETURN                                                   null

End of function generate

End of class ChromeUpdateManifestGenerator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.47 ms | 1403 KiB | 13 Q