3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User implements \JsonSerializable { private $username; private $password; private $name; private static function findByUsername($username) { $res = new self(); $res->username = $username; $res->name = 'Some User'; $res->password = password_hash("aXSA9_5uZp0QLhGY", PASSWORD_DEFAULT); return $res; } public function login($username, $password) { $user = self::findByUsername($username); if (password_verify($password, $user->password)) { $fields = get_class_vars(static::class); foreach ($fields as $field => $_) { $this->$field = $user->$field; } } } public function jsonSerialize() { return [ 'username' => $this->username, 'name' => $this->name ]; } } $user = new User(); $user->login('admin', 'aXSA9_5uZp0QLhGY'); echo json_encode($user); // {"username":"admin","name":"Some User"}
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbJde
function name:  (null)
number of ops:  13
compiled vars:  !0 = $user
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'user'
   34     1        NEW                                              $1      'User'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   35     4        INIT_METHOD_CALL                                         !0, 'login'
          5        SEND_VAL_EX                                              'admin'
          6        SEND_VAL_EX                                              'aXSA9_5uZp0QLhGY'
          7        DO_FCALL                                      0          
   36     8        INIT_FCALL                                               'json_encode'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $5      
         11        ECHO                                                     $5
         12      > RETURN                                                   1

Class User:
Function findbyusername:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbJde
function name:  findByUsername
number of ops:  16
compiled vars:  !0 = $username, !1 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        NEW                          self                $2      
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $2
   10     4        ASSIGN_OBJ                                               !1, 'username'
          5        OP_DATA                                                  !0
   11     6        ASSIGN_OBJ                                               !1, 'name'
          7        OP_DATA                                                  'Some+User'
   12     8        INIT_FCALL                                               'password_hash'
          9        SEND_VAL                                                 'aXSA9_5uZp0QLhGY'
         10        SEND_VAL                                                 '2y'
         11        DO_ICALL                                         $8      
         12        ASSIGN_OBJ                                               !1, 'password'
         13        OP_DATA                                                  $8
   13    14      > RETURN                                                   !1
   14    15*     > RETURN                                                   null

End of function findbyusername

Function login:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 25
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 24
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 24
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 25
filename:       /in/VbJde
function name:  login
number of ops:  26
compiled vars:  !0 = $username, !1 = $password, !2 = $user, !3 = $fields, !4 = $_, !5 = $field
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        INIT_STATIC_METHOD_CALL                                  'findByUsername'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !2, $6
   18     6        INIT_FCALL                                               'password_verify'
          7        SEND_VAR                                                 !1
          8        FETCH_OBJ_R                                      ~8      !2, 'password'
          9        SEND_VAL                                                 ~8
         10        DO_ICALL                                         $9      
         11      > JMPZ                                                     $9, ->25
   19    12    >   INIT_FCALL                                               'get_class_vars'
         13        FETCH_CLASS_NAME                                 ~10     
         14        SEND_VAL                                                 ~10
         15        DO_ICALL                                         $11     
         16        ASSIGN                                                   !3, $11
   20    17      > FE_RESET_R                                       $13     !3, ->24
         18    > > FE_FETCH_R                                       ~14     $13, !4, ->24
         19    >   ASSIGN                                                   !5, ~14
   21    20        FETCH_OBJ_R                                      ~17     !2, !5
         21        ASSIGN_OBJ                                               !5
         22        OP_DATA                                                  ~17
   20    23      > JMP                                                      ->18
         24    >   FE_FREE                                                  $13
   24    25    > > RETURN                                                   null

End of function login

Function jsonserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbJde
function name:  jsonSerialize
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   FETCH_OBJ_R                                      ~0      'username'
          1        INIT_ARRAY                                       ~1      ~0, 'username'
   29     2        FETCH_OBJ_R                                      ~2      'name'
          3        ADD_ARRAY_ELEMENT                                ~1      ~2, 'name'
          4      > RETURN                                                   ~1
   31     5*     > RETURN                                                   null

End of function jsonserialize

End of class User.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.19 ms | 1400 KiB | 21 Q