3v4l.org

run code in 500+ PHP versions simultaneously
<?php $xml = ' <content> <hello attribute="123"></hello> </content> '; class Parser { private $xml; public function __construct(SimpleXMLElement $xml) { $this->xml = $xml; } public function asString(): string { return $this->getValue(); } public function asInt(): int { return $this->getValue(); } public function asCastedInt(): int { return $this->asString(); } public function directConversion() { return (int)$this->getValue(); } private function getValue() { return $this->xml->hello['attribute']; } } $object = new Parser(new SimpleXMLElement($xml)); var_dump($object->asString()); var_dump($object->asCastedInt()); var_dump($object->directConversion()); var_dump($object->asInt());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JnFCh
function name:  (null)
number of ops:  29
compiled vars:  !0 = $xml, !1 = $object
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%0A++++%3Ccontent%3E%0A++++++++%3Chello+attribute%3D%22123%22%3E%3C%2Fhello%3E%0A++++%3C%2Fcontent%3E%0A'
   39     1        NEW                                                  $3      'Parser'
          2        NEW                                                  $4      'SimpleXMLElement'
          3        SEND_VAR_EX                                                  !0
          4        DO_FCALL                                          0          
          5        SEND_VAR_NO_REF_EX                                           $4
          6        DO_FCALL                                          0          
          7        ASSIGN                                                       !1, $3
   41     8        INIT_FCALL                                                   'var_dump'
          9        INIT_METHOD_CALL                                             !1, 'asString'
         10        DO_FCALL                                          0  $8      
         11        SEND_VAR                                                     $8
         12        DO_ICALL                                                     
   42    13        INIT_FCALL                                                   'var_dump'
         14        INIT_METHOD_CALL                                             !1, 'asCastedInt'
         15        DO_FCALL                                          0  $10     
         16        SEND_VAR                                                     $10
         17        DO_ICALL                                                     
   43    18        INIT_FCALL                                                   'var_dump'
         19        INIT_METHOD_CALL                                             !1, 'directConversion'
         20        DO_FCALL                                          0  $12     
         21        SEND_VAR                                                     $12
         22        DO_ICALL                                                     
   44    23        INIT_FCALL                                                   'var_dump'
         24        INIT_METHOD_CALL                                             !1, 'asInt'
         25        DO_FCALL                                          0  $14     
         26        SEND_VAR                                                     $14
         27        DO_ICALL                                                     
         28      > RETURN                                                       1

Class Parser:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JnFCh
function name:  __construct
number of ops:  4
compiled vars:  !0 = $xml
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
   14     1        ASSIGN_OBJ                                                   'xml'
          2        OP_DATA                                                      !0
   15     3      > RETURN                                                       null

End of function __construct

Function asstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JnFCh
function name:  asString
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   INIT_METHOD_CALL                                             'getValue'
          1        DO_FCALL                                          0  $0      
          2        VERIFY_RETURN_TYPE                                           $0
          3      > RETURN                                                       $0
   19     4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function asstring

Function asint:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JnFCh
function name:  asInt
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   INIT_METHOD_CALL                                             'getValue'
          1        DO_FCALL                                          0  $0      
          2        VERIFY_RETURN_TYPE                                           $0
          3      > RETURN                                                       $0
   23     4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function asint

Function ascastedint:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JnFCh
function name:  asCastedInt
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   26     0  E >   INIT_METHOD_CALL                                             'asString'
          1        DO_FCALL                                          0  $0      
          2        VERIFY_RETURN_TYPE                                           $0
          3      > RETURN                                                       $0
   27     4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function ascastedint

Function directconversion:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JnFCh
function name:  directConversion
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   30     0  E >   INIT_METHOD_CALL                                             'getValue'
          1        DO_FCALL                                          0  $0      
          2        CAST                                              4  ~1      $0
          3      > RETURN                                                       ~1
   31     4*     > RETURN                                                       null

End of function directconversion

Function getvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JnFCh
function name:  getValue
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   34     0  E >   FETCH_OBJ_R                                          ~0      'xml'
          1        FETCH_OBJ_R                                          ~1      ~0, 'hello'
          2        FETCH_DIM_R                                          ~2      ~1, 'attribute'
          3      > RETURN                                                       ~2
   35     4*     > RETURN                                                       null

End of function getvalue

End of class Parser.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
172.68 ms | 2333 KiB | 14 Q