3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { /** @var array<string, string> */ private array $stuff = ["foo" => "foo"]; /** * @param non-empty-list<string> $param * @return string */ public function foo(array $param) { $arr = &$this->stuff[$param[0]]; // This seems to cause Psalm to blackout. var_dump($this->stuff); /** @var string */ $x = $arr; /** @psalm-trace $x, $arr */; // This trace doesn't work, and $x's type appears to be mixed at this point. /** @psalm-trace $x */ return $x; } } $foo = new Foo(); $foo->foo(["foo"]); $foo->foo(["bar"]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f63nj
function name:  (null)
number of ops:  10
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   27     3        INIT_METHOD_CALL                                         !0, 'foo'
          4        SEND_VAL_EX                                              <array>
          5        DO_FCALL                                      0          
   28     6        INIT_METHOD_CALL                                         !0, 'foo'
          7        SEND_VAL_EX                                              <array>
          8        DO_FCALL                                      0          
          9      > RETURN                                                   1

Class Foo:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f63nj
function name:  foo
number of ops:  12
compiled vars:  !0 = $param, !1 = $arr, !2 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        FETCH_DIM_R                                      ~4      !0, 0
          2        FETCH_OBJ_W                                      $3      'stuff'
          3        FETCH_DIM_W                                      $5      $3, ~4
          4        ASSIGN_REF                                               !1, $5
   15     5        INIT_FCALL                                               'var_dump'
          6        FETCH_OBJ_R                                      ~7      'stuff'
          7        SEND_VAL                                                 ~7
          8        DO_ICALL                                                 
   17     9        ASSIGN                                                   !2, !1
   22    10      > RETURN                                                   !2
   23    11*     > RETURN                                                   null

End of function foo

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.7 ms | 1010 KiB | 14 Q