3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Thing { public function __call($name, $params) { return 'foo'; } } function can_be_string($var) { return $var === null || is_scalar($var) || is_callable([$var, '__toString']); } $a = new Thing; var_dump(can_be_string($a)); (string) $a;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4ttLv
function name:  (null)
number of ops:  12
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $1      'Thing'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   17     3        INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'can_be_string'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   19     9        CAST                                          6  ~6      !0
         10        FREE                                                     ~6
         11      > RETURN                                                   1

Function can_be_string:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 47) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
Branch analysis from position: 5
filename:       /in/4ttLv
function name:  can_be_string
number of ops:  14
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        TYPE_CHECK                                    2  ~1      !0
          2      > JMPNZ_EX                                         ~1      ~1, ->5
          3    >   TYPE_CHECK                                  124  ~2      !0
          4        BOOL                                             ~1      ~2
          5    > > JMPNZ_EX                                         ~1      ~1, ->12
          6    >   INIT_FCALL                                               'is_callable'
          7        INIT_ARRAY                                       ~3      !0
          8        ADD_ARRAY_ELEMENT                                ~3      '__toString'
          9        SEND_VAL                                                 ~3
         10        DO_ICALL                                         $4      
         11        BOOL                                             ~1      $4
         12    > > RETURN                                                   ~1
   13    13*     > RETURN                                                   null

End of function can_be_string

Class Thing:
Function __call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4ttLv
function name:  __call
number of ops:  4
compiled vars:  !0 = $name, !1 = $params
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2      > RETURN                                                   'foo'
    8     3*     > RETURN                                                   null

End of function __call

End of class Thing.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
128.15 ms | 1403 KiB | 18 Q