3v4l.org

run code in 300+ PHP versions simultaneously
<?php $user = new \stdClass; $user->attributes = [ 'id' => 1, 'role' => 'admin', ]; $user->is = function($role) { if (in_array($role, ['amdin', 'user', 'guest'])) return $this->attributes['role'] === $role; else return false; }; var_dump($user->is('user')); var_dump($user->is('admin'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vnEgE
function name:  (null)
number of ops:  21
compiled vars:  !0 = $user
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   NEW                                              $1      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
    3     3        ASSIGN_OBJ                                               !0, 'attributes'
    4     4        OP_DATA                                                  <array>
    7     5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvnEgE%3A7%240'
          6        ASSIGN_OBJ                                               !0, 'is'
   12     7        OP_DATA                                                  ~6
   14     8        INIT_FCALL                                               'var_dump'
          9        INIT_METHOD_CALL                                         !0, 'is'
         10        SEND_VAL_EX                                              'user'
         11        DO_FCALL                                      0  $7      
         12        SEND_VAR                                                 $7
         13        DO_ICALL                                                 
   15    14        INIT_FCALL                                               'var_dump'
         15        INIT_METHOD_CALL                                         !0, 'is'
         16        SEND_VAL_EX                                              'admin'
         17        DO_FCALL                                      0  $9      
         18        SEND_VAR                                                 $9
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FvnEgE%3A7%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vnEgE
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $role
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        IN_ARRAY                                                 !0, <array>
          2      > JMPZ                                                     ~1, ->9
    9     3    >   FETCH_THIS                                       $2      
          4        FETCH_OBJ_R                                      ~3      $2, 'attributes'
          5        FETCH_DIM_R                                      ~4      ~3, 'role'
          6        IS_IDENTICAL                                     ~5      !0, ~4
          7      > RETURN                                                   ~5
          8*       JMP                                                      ->10
   11     9    > > RETURN                                                   <false>
   12    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvnEgE%3A7%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.17 ms | 1396 KiB | 15 Q