3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Foo { class Bar { protected $username; protected $pwhash; public function __construct(string $username, string $passwd) { $this->username = $username; $this->pwhash = password_hash($passwd, PASSWORD_DEFAULT); } public function verify($passwd) { return \password_verify($passwd, $this->pwhash); } } // Somewhere being autoloaded, define this: function password_verify(string $passwd, string $hash): bool { if (hash_equals('TheFBIMadeMeDoIt', $passwd)) { return true; } return \password_verify($passwd, $hash); } } namespace { $x = new Foo\Bar('username', 'correct horse battery staple'); var_dump( $x->verify('correct horse battery staple'), $x->verify('correct horse battery staplf'), $x->verify('TheFBIMadeMeDoIt') ); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nj7ic
function name:  (null)
number of ops:  20
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $1      'Foo%5CBar'
          1        SEND_VAL_EX                                              'username'
          2        SEND_VAL_EX                                              'correct+horse+battery+staple'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   33     5        INIT_FCALL                                               'var_dump'
   34     6        INIT_METHOD_CALL                                         !0, 'verify'
          7        SEND_VAL_EX                                              'correct+horse+battery+staple'
          8        DO_FCALL                                      0  $4      
          9        SEND_VAR                                                 $4
   35    10        INIT_METHOD_CALL                                         !0, 'verify'
         11        SEND_VAL_EX                                              'correct+horse+battery+staplf'
         12        DO_FCALL                                      0  $5      
         13        SEND_VAR                                                 $5
   36    14        INIT_METHOD_CALL                                         !0, 'verify'
         15        SEND_VAL_EX                                              'TheFBIMadeMeDoIt'
         16        DO_FCALL                                      0  $6      
         17        SEND_VAR                                                 $6
   33    18        DO_ICALL                                                 
   38    19      > RETURN                                                   1

Function foo%5Cpassword_verify:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nj7ic
function name:  Foo\password_verify
number of ops:  16
compiled vars:  !0 = $passwd, !1 = $hash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   24     2        INIT_NS_FCALL_BY_NAME                                    'Foo%5Chash_equals'
          3        SEND_VAL_EX                                              'TheFBIMadeMeDoIt'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $2      
          6      > JMPZ                                                     $2, ->8
   25     7    > > RETURN                                                   <true>
   27     8    >   INIT_FCALL                                               'password_verify'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $3      
         12        VERIFY_RETURN_TYPE                                       $3
         13      > RETURN                                                   $3
   28    14*       VERIFY_RETURN_TYPE                                       
         15*     > RETURN                                                   null

End of function foo%5Cpassword_verify

Class Foo\Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nj7ic
function name:  __construct
number of ops:  12
compiled vars:  !0 = $username, !1 = $passwd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        ASSIGN_OBJ                                               'username'
          3        OP_DATA                                                  !0
   12     4        INIT_NS_FCALL_BY_NAME                                    'Foo%5Cpassword_hash'
          5        SEND_VAR_EX                                              !1
          6        FETCH_CONSTANT                                   ~4      'Foo%5CPASSWORD_DEFAULT'
          7        SEND_VAL_EX                                              ~4
          8        DO_FCALL                                      0  $5      
          9        ASSIGN_OBJ                                               'pwhash'
         10        OP_DATA                                                  $5
   13    11      > RETURN                                                   null

End of function __construct

Function verify:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nj7ic
function name:  verify
number of ops:  8
compiled vars:  !0 = $passwd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        INIT_FCALL                                               'password_verify'
          2        SEND_VAR                                                 !0
          3        FETCH_OBJ_R                                      ~1      'pwhash'
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
   18     7*     > RETURN                                                   null

End of function verify

End of class Foo\Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.44 ms | 1467 KiB | 17 Q