3v4l.org

run code in 300+ PHP versions simultaneously
<?php $schema = <<<SCHEMA <xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="item"> <xs:complexType> <xs:sequence> <xs:element ref="item" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> <xs:attribute name="is-foo" type="xs:boolean" default="true" use="optional" /> <xs:attribute name="is-bar" type="xs:boolean" default="false" use="optional" /> </xs:complexType> </xs:element> </xs:schema> SCHEMA; $xml = <<<XML <item is-foo="false" is-bar="false"> <item is-bar="true"> <item> <item is-foo="true"> <item /> <item is-foo="true" /> </item> </item> <item is-foo="true" is-bar="true" /> </item> </item> XML; $document = new DOMDocument(); $document->loadXML($xml); $document->schemaValidateSource($schema, LIBXML_SCHEMA_CREATE); $document->resolveExternals = true; $document->substituteEntities = true; $xpath = new DOMXPath($document); foreach ($xpath->query('//item') as $item) { echo $item->getNodePath() . PHP_EOL . ' is-foo : ' . ($item->getAttribute('is-foo') === 'true' ? 'true' : 'false') . PHP_EOL . ' is-bar : ' . ($item->getAttribute('is-bar') === 'true' ? 'true' : 'false') . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 52
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 52
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 36
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 47
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 47
Branch analysis from position: 45
Branch analysis from position: 47
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
filename:       /in/qCdY3
function name:  (null)
number of ops:  54
compiled vars:  !0 = $schema, !1 = $xml, !2 = $document, !3 = $xpath, !4 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cxs%3Aschema+elementFormDefault%3D%22qualified%22+xmlns%3Axs%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%22%3E%0A++++%3Cxs%3Aelement+name%3D%22item%22%3E%0A++++++++%3Cxs%3AcomplexType%3E%0A++++++++++++%3Cxs%3Asequence%3E%0A++++++++++++++++%3Cxs%3Aelement+ref%3D%22item%22+minOccurs%3D%220%22+maxOccurs%3D%22unbounded%22+%2F%3E%0A++++++++++++%3C%2Fxs%3Asequence%3E%0A++++++++++++%3Cxs%3Aattribute+name%3D%22is-foo%22+type%3D%22xs%3Aboolean%22+default%3D%22true%22+use%3D%22optional%22+%2F%3E%0A++++++++++++%3Cxs%3Aattribute+name%3D%22is-bar%22+type%3D%22xs%3Aboolean%22+default%3D%22false%22+use%3D%22optional%22+%2F%3E%0A++++++++%3C%2Fxs%3AcomplexType%3E%0A++++%3C%2Fxs%3Aelement%3E%0A%3C%2Fxs%3Aschema%3E'
   17     1        ASSIGN                                                   !1, '%3Citem+is-foo%3D%22false%22+is-bar%3D%22false%22%3E%0A++++%3Citem+is-bar%3D%22true%22%3E%0A++++++++%3Citem%3E%0A++++++++++++%3Citem+is-foo%3D%22true%22%3E%0A++++++++++++++++%3Citem+%2F%3E%0A++++++++++++++++%3Citem+is-foo%3D%22true%22+%2F%3E%0A++++++++++++%3C%2Fitem%3E%0A++++++++%3C%2Fitem%3E%0A++++++++%3Citem+is-foo%3D%22true%22+is-bar%3D%22true%22+%2F%3E%0A++++%3C%2Fitem%3E%0A%3C%2Fitem%3E'
   31     2        NEW                                              $7      'DOMDocument'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !2, $7
   32     5        INIT_METHOD_CALL                                         !2, 'loadXML'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
   33     8        INIT_METHOD_CALL                                         !2, 'schemaValidateSource'
          9        SEND_VAR_EX                                              !0
         10        SEND_VAL_EX                                              1
         11        DO_FCALL                                      0          
   34    12        ASSIGN_OBJ                                               !2, 'resolveExternals'
         13        OP_DATA                                                  <true>
   35    14        ASSIGN_OBJ                                               !2, 'substituteEntities'
         15        OP_DATA                                                  <true>
   37    16        NEW                                              $14     'DOMXPath'
         17        SEND_VAR_EX                                              !2
         18        DO_FCALL                                      0          
         19        ASSIGN                                                   !3, $14
   38    20        INIT_METHOD_CALL                                         !3, 'query'
         21        SEND_VAL_EX                                              '%2F%2Fitem'
         22        DO_FCALL                                      0  $17     
         23      > FE_RESET_R                                       $18     $17, ->52
         24    > > FE_FETCH_R                                               $18, !4, ->52
   39    25    >   INIT_METHOD_CALL                                         !4, 'getNodePath'
         26        DO_FCALL                                      0  $19     
         27        CONCAT                                           ~20     $19, '%0A'
   40    28        CONCAT                                           ~21     ~20, '++is-foo+%3A+'
         29        INIT_METHOD_CALL                                         !4, 'getAttribute'
         30        SEND_VAL_EX                                              'is-foo'
         31        DO_FCALL                                      0  $22     
         32        IS_IDENTICAL                                             $22, 'true'
         33      > JMPZ                                                     ~23, ->36
         34    >   QM_ASSIGN                                        ~24     'true'
         35      > JMP                                                      ->37
         36    >   QM_ASSIGN                                        ~24     'false'
         37    >   CONCAT                                           ~25     ~21, ~24
         38        CONCAT                                           ~26     ~25, '%0A'
   41    39        CONCAT                                           ~27     ~26, '++is-bar+%3A+'
         40        INIT_METHOD_CALL                                         !4, 'getAttribute'
         41        SEND_VAL_EX                                              'is-bar'
         42        DO_FCALL                                      0  $28     
         43        IS_IDENTICAL                                             $28, 'true'
         44      > JMPZ                                                     ~29, ->47
         45    >   QM_ASSIGN                                        ~30     'true'
         46      > JMP                                                      ->48
         47    >   QM_ASSIGN                                        ~30     'false'
         48    >   CONCAT                                           ~31     ~27, ~30
         49        CONCAT                                           ~32     ~31, '%0A'
         50        ECHO                                                     ~32
   38    51      > JMP                                                      ->24
         52    >   FE_FREE                                                  $18
   42    53      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.14 ms | 1399 KiB | 13 Q