3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @author: hakre <http://hakre.wordpress.com> * @link http://stackoverflow.com/a/17628617/367456 */ /** * dereference a value and optionally setting its type * * @param mixed $mixed * @param null $type (optional) * * @return mixed $mixed set as $type */ function rettype($mixed, $type = NULL) { $type === NULL || settype($mixed, $type); return $mixed; } $array = Array('status' => 'Figure A. ...'); echo rettype($array, 'object')->status; // prints "Figure A. ..."
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JNAlp
function name:  (null)
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ASSIGN                                                   !0, <array>
   22     1        INIT_FCALL                                               'rettype'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'object'
          4        DO_FCALL                                      0  $2      
          5        FETCH_OBJ_R                                      ~3      $2, 'status'
          6        ECHO                                                     ~3
          7      > RETURN                                                   1

Function rettype:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/JNAlp
function name:  rettype
number of ops:  11
compiled vars:  !0 = $mixed, !1 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   16     2        TYPE_CHECK                                    2  ~2      !1
          3      > JMPNZ_EX                                         ~2      ~2, ->9
          4    >   INIT_FCALL                                               'settype'
          5        SEND_REF                                                 !0
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $3      
          8        BOOL                                             ~2      $3
   17     9    > > RETURN                                                   !0
   18    10*     > RETURN                                                   null

End of function rettype

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.99 ms | 1447 KiB | 15 Q