3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Verifies that a password matches a hash. This validator requires that * function password_verify() is available (it is implemented natively * since PHP 5.5.0). */ class Zefram_Validate_PasswordVerify extends Zend_Validate_Abstract { const EMPTY_HASH = 'passwordVerifyEmptyHash'; const INVALID = 'passwordVerifyInvalid'; /** * @var string */ protected $_hash; protected $_messageTemplates = array( self::EMPTY_HASH => 'No hash was provided to match against', self::INVALID => 'The password provided is invalid', ); /** * Constructor. * * @param string|array $options * @throws Zend_Validate_Exception */ public function __construct($options = null) { if (!function_exists('password_verify')) { throw new Zend_Validate_Exception('Function password_verify() is not callable. Please upgrade to PHP 5.5 or install userland implementation. Read more at http://php.net/manual/en/function.password-verify.php'); } if (is_string($options)) { $options = array('hash' => $options); } if (is_object($options) && method_exists($options, 'toArray')) { $options = $options->toArray(); } if ($options) { $this->setOptions((array) $options); } } /** * @param array $options * @return Zefram_Validate_PasswordVerify */ public function setOptions(array $options) { foreach ($options as $key => $value) { $method = 'set' . $key; if (method_exists($this, $method)) { $this->{$method}($value); } } return $this; } /** * @param string $hash * @return Zefram_Validate_PasswordVerify */ public function setHash($hash) { $this->_hash = (string) $hash; return $this; } /** * @return string */ public function getHash() { return $this->_hash; } /** * @param string $value * @return bool */ public function isValid($value) { $value = (string) $value; $this->_setValue($value); $hash = $this->getHash(); if (empty($hash)) { $this->_error(self::EMPTY_HASH); return false; } if (!password_verify($value, $hash)) { $this->_error(self::INVALID); return false; } return true; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jffqZ
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_CLASS                                            'zefram_validate_passwordverify', 'zend_validate_abstract'
  101     1      > RETURN                                                   1

Class Zefram_Validate_PasswordVerify:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 25
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 30
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
Branch analysis from position: 25
Branch analysis from position: 21
Branch analysis from position: 14
filename:       /in/jffqZ
function name:  __construct
number of ops:  31
compiled vars:  !0 = $options
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV_INIT                                        !0      null
   31     1        INIT_FCALL                                               'function_exists'
          2        SEND_VAL                                                 'password_verify'
          3        DO_ICALL                                         $1      
          4        BOOL_NOT                                         ~2      $1
          5      > JMPZ                                                     ~2, ->10
   32     6    >   NEW                                              $3      'Zend_Validate_Exception'
          7        SEND_VAL_EX                                              'Function+password_verify%28%29+is+not+callable.+Please+upgrade+to+PHP+5.5+or+install+userland+implementation.+Read+more+at+http%3A%2F%2Fphp.net%2Fmanual%2Fen%2Ffunction.password-verify.php'
          8        DO_FCALL                                      0          
          9      > THROW                                         0          $3
   34    10    >   TYPE_CHECK                                   64          !0
         11      > JMPZ                                                     ~5, ->14
   35    12    >   INIT_ARRAY                                       ~6      !0, 'hash'
         13        ASSIGN                                                   !0, ~6
   37    14    >   TYPE_CHECK                                  256  ~8      !0
         15      > JMPZ_EX                                          ~8      ~8, ->21
         16    >   INIT_FCALL                                               'method_exists'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 'toArray'
         19        DO_ICALL                                         $9      
         20        BOOL                                             ~8      $9
         21    > > JMPZ                                                     ~8, ->25
   38    22    >   INIT_METHOD_CALL                                         !0, 'toArray'
         23        DO_FCALL                                      0  $10     
         24        ASSIGN                                                   !0, $10
   40    25    > > JMPZ                                                     !0, ->30
   41    26    >   INIT_METHOD_CALL                                         'setOptions'
         27        CAST                                          7  ~12     !0
         28        SEND_VAL_EX                                              ~12
         29        DO_FCALL                                      0          
   43    30    > > RETURN                                                   null

End of function __construct

Function setoptions:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 16
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 15
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/jffqZ
function name:  setOptions
number of ops:  20
compiled vars:  !0 = $options, !1 = $value, !2 = $key, !3 = $method
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   RECV                                             !0      
   51     1      > FE_RESET_R                                       $4      !0, ->16
          2    > > FE_FETCH_R                                       ~5      $4, !1, ->16
          3    >   ASSIGN                                                   !2, ~5
   52     4        CONCAT                                           ~7      'set', !2
          5        ASSIGN                                                   !3, ~7
   53     6        INIT_FCALL                                               'method_exists'
          7        FETCH_THIS                                       ~9      
          8        SEND_VAL                                                 ~9
          9        SEND_VAR                                                 !3
         10        DO_ICALL                                         $10     
         11      > JMPZ                                                     $10, ->15
   54    12    >   INIT_METHOD_CALL                                         !3
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0          
   51    15    > > JMP                                                      ->2
         16    >   FE_FREE                                                  $4
   57    17        FETCH_THIS                                       ~12     
         18      > RETURN                                                   ~12
   58    19*     > RETURN                                                   null

End of function setoptions

Function sethash:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jffqZ
function name:  setHash
number of ops:  7
compiled vars:  !0 = $hash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   RECV                                             !0      
   66     1        CAST                                          6  ~2      !0
          2        ASSIGN_OBJ                                               '_hash'
          3        OP_DATA                                                  ~2
   67     4        FETCH_THIS                                       ~3      
          5      > RETURN                                                   ~3
   68     6*     > RETURN                                                   null

End of function sethash

Function gethash:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jffqZ
function name:  getHash
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   75     0  E >   FETCH_OBJ_R                                      ~0      '_hash'
          1      > RETURN                                                   ~0
   76     2*     > RETURN                                                   null

End of function gethash

Function isvalid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jffqZ
function name:  isValid
number of ops:  27
compiled vars:  !0 = $value, !1 = $hash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   82     0  E >   RECV                                             !0      
   84     1        CAST                                          6  ~2      !0
          2        ASSIGN                                                   !0, ~2
   85     3        INIT_METHOD_CALL                                         '_setValue'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
   87     6        INIT_METHOD_CALL                                         'getHash'
          7        DO_FCALL                                      0  $5      
          8        ASSIGN                                                   !1, $5
   89     9        ISSET_ISEMPTY_CV                                         !1
         10      > JMPZ                                                     ~7, ->15
   90    11    >   INIT_METHOD_CALL                                         '_error'
         12        SEND_VAL_EX                                              'passwordVerifyEmptyHash'
         13        DO_FCALL                                      0          
   91    14      > RETURN                                                   <false>
   94    15    >   INIT_FCALL                                               'password_verify'
         16        SEND_VAR                                                 !0
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $9      
         19        BOOL_NOT                                         ~10     $9
         20      > JMPZ                                                     ~10, ->25
   95    21    >   INIT_METHOD_CALL                                         '_error'
         22        SEND_VAL_EX                                              'passwordVerifyInvalid'
         23        DO_FCALL                                      0          
   96    24      > RETURN                                                   <false>
   99    25    > > RETURN                                                   <true>
  100    26*     > RETURN                                                   null

End of function isvalid

End of class Zefram_Validate_PasswordVerify.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.38 ms | 1396 KiB | 19 Q