3v4l.org

run code in 300+ PHP versions simultaneously
<?php class StringCastable { private $data; public function __constructor(string $data) { $this->data = $data; } public function __toString(): string { return $this->toString(); } public function toString(): string { return $this->data; } } function testStringCast(string $data) { var_dump($data, get_class($data)); } $speculoos = new StringCastable("speculoos"); var_dump($speculoos, $speculoos->__toString()); testStringCast($speculoos);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZRbRd
function name:  (null)
number of ops:  15
compiled vars:  !0 = $speculoos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'stringcastable'
   28     1        NEW                                              $1      'StringCastable'
          2        SEND_VAL_EX                                              'speculoos'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   30     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        INIT_METHOD_CALL                                         !0, '__toString'
          8        DO_FCALL                                      0  $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                                 
   32    11        INIT_FCALL                                               'teststringcast'
         12        SEND_VAR                                                 !0
         13        DO_FCALL                                      0          
         14      > RETURN                                                   1

Function teststringcast:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZRbRd
function name:  testStringCast
number of ops:  7
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   25     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        GET_CLASS                                        ~1      !0
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                                 
   26     6      > RETURN                                                   null

End of function teststringcast

Class StringCastable:
Function __constructor:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZRbRd
function name:  __constructor
number of ops:  4
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN_OBJ                                               'data'
          2        OP_DATA                                                  !0
   10     3      > RETURN                                                   null

End of function __constructor

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

End of function __tostring

Function tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZRbRd
function name:  toString
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~0      'data'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   20     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function tostring

End of class StringCastable.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.86 ms | 1403 KiB | 16 Q