3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyNode extends DOMNode { public function describe() { echo "I am a " . $this->tagName . " node!"; } } class MyElement extends DOMElement {} class MyDocument extends DOMDocument {} class MyNodeList extends DOMNodeList {} // this class is unused. $dom = new MyDocument(); $dom->registerNodeClass("DOMNode", "MyNode"); $dom->registerNodeClass("DOMElement", "MyElement"); // Can't do this, because DOMNodeList doesn't inherit from DOMNode. // $dom->registerNodeClass("DOMNodeList", "MyNodeList"); $dom->loadHTML("<!doctype html><h1>Hello, World!</h1>"); // The items within the DOMNodeList are MyElement objects... var_dump($dom->documentElement->childNodes->item(0)); // ...but why can't I use a MyNodeList here? var_dump($dom->documentElement->childNodes);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gm41f
function name:  (null)
number of ops:  28
compiled vars:  !0 = $dom
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $1      'MyDocument'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   16     3        INIT_METHOD_CALL                                         !0, 'registerNodeClass'
          4        SEND_VAL_EX                                              'DOMNode'
          5        SEND_VAL_EX                                              'MyNode'
          6        DO_FCALL                                      0          
   17     7        INIT_METHOD_CALL                                         !0, 'registerNodeClass'
          8        SEND_VAL_EX                                              'DOMElement'
          9        SEND_VAL_EX                                              'MyElement'
         10        DO_FCALL                                      0          
   22    11        INIT_METHOD_CALL                                         !0, 'loadHTML'
         12        SEND_VAL_EX                                              '%3C%21doctype+html%3E%3Ch1%3EHello%2C+World%21%3C%2Fh1%3E'
         13        DO_FCALL                                      0          
   25    14        INIT_FCALL                                               'var_dump'
         15        FETCH_OBJ_R                                      ~7      !0, 'documentElement'
         16        FETCH_OBJ_R                                      ~8      ~7, 'childNodes'
         17        INIT_METHOD_CALL                                         ~8, 'item'
         18        SEND_VAL_EX                                              0
         19        DO_FCALL                                      0  $9      
         20        SEND_VAR                                                 $9
         21        DO_ICALL                                                 
   27    22        INIT_FCALL                                               'var_dump'
         23        FETCH_OBJ_R                                      ~11     !0, 'documentElement'
         24        FETCH_OBJ_R                                      ~12     ~11, 'childNodes'
         25        SEND_VAL                                                 ~12
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Class MyNode:
Function describe:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gm41f
function name:  describe
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   FETCH_OBJ_R                                      ~0      'tagName'
          1        CONCAT                                           ~1      'I+am+a+', ~0
          2        CONCAT                                           ~2      ~1, '+node%21'
          3        ECHO                                                     ~2
    6     4      > RETURN                                                   null

End of function describe

End of class MyNode.

Class MyElement: [no user functions]
Class MyDocument: [no user functions]
Class MyNodeList: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.34 ms | 1396 KiB | 15 Q