3v4l.org

run code in 300+ PHP versions simultaneously
<?php class StringSupported { protected $value; public function __construct(string $string) { $this->value = $string; } public function __toString() { return $this->value; } } class Token { public function replace($text) { if (is_object($text)) { throw new \TypeError("Argument $text expected type string, Object passed"); } echo sprintf('you passed %s', $text); } } $token = new Token(); $token->replace('bob'); $token->replace(new StringSupported('bess'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qCJsV
function name:  (null)
number of ops:  14
compiled vars:  !0 = $token
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'stringsupported'
   22     1        NEW                                              $1      'Token'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   23     4        INIT_METHOD_CALL                                         !0, 'replace'
          5        SEND_VAL_EX                                              'bob'
          6        DO_FCALL                                      0          
   24     7        INIT_METHOD_CALL                                         !0, 'replace'
          8        NEW                                              $5      'StringSupported'
          9        SEND_VAL_EX                                              'bess'
         10        DO_FCALL                                      0          
         11        SEND_VAR_NO_REF_EX                                       $5
         12        DO_FCALL                                      0          
         13      > RETURN                                                   1

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

End of function __construct

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

End of function __tostring

End of class StringSupported.

Class Token:
Function replace:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qCJsV
function name:  replace
number of ops:  16
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        TYPE_CHECK                                  256          !0
          2      > JMPZ                                                     ~1, ->10
   16     3    >   NEW                                              $2      'TypeError'
          4        ROPE_INIT                                     3  ~4      'Argument+'
          5        ROPE_ADD                                      1  ~4      ~4, !0
          6        ROPE_END                                      2  ~3      ~4, '+expected+type+string%2C+Object+passed'
          7        SEND_VAL_EX                                              ~3
          8        DO_FCALL                                      0          
          9      > THROW                                         0          $2
   18    10    >   INIT_FCALL                                               'sprintf'
         11        SEND_VAL                                                 'you+passed+%25s'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $7      
         14        ECHO                                                     $7
   19    15      > RETURN                                                   null

End of function replace

End of class Token.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
127.59 ms | 948 KiB | 16 Q