3v4l.org

run code in 500+ PHP versions simultaneously
<?php // i wish the php builtin HashContext class had this stuff: class OOHashContext{ private $hc; public const HASH_HMAC=1; public function __construct(string $algo, int $options = 0, string $key = NULL){ if(!($this->hc = hash_init($algo, $options, $key))){ throw new \RuntimeException(); } } public function update(string $data):self{ if(!hash_update($this->hc, $data)){ throw new \RuntimeException(); } return $this; } public function update_file(string $file, $scontext = null):self{ if(!hash_update_file($this->hc, $file, $scontext)){ throw new \RuntimeException(); } return $this; } public function update_stream($handle, int $length = -1):self{ if(!hash_update_stream($this->hc, $handle, $length)){ throw new \RuntimeException(); } return $this; } public function final(bool $raw_output = false):string{ $ret = hash_final($this->hc, $raw_output); if(!is_string($ret)){ throw new \RuntimeException(); } return $ret; } } $o=new OOHashContext("SHA1"); $str1="foo"; $str2="bar"; $result = (new OOHashContext("SHA1"))->update($str1)->update($str2)->final(); echo $result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lXd3u
function name:  (null)
number of ops:  20
compiled vars:  !0 = $o, !1 = $str1, !2 = $str2, !3 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   37     0  E >   NEW                                                  $4      'OOHashContext'
          1        SEND_VAL_EX                                                  'SHA1'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $4
   38     4        ASSIGN                                                       !1, 'foo'
   39     5        ASSIGN                                                       !2, 'bar'
   40     6        NEW                                                  $9      'OOHashContext'
          7        SEND_VAL_EX                                                  'SHA1'
          8        DO_FCALL                                          0          
          9        INIT_METHOD_CALL                                             $9, 'update'
         10        SEND_VAR_EX                                                  !1
         11        DO_FCALL                                          0  $11     
         12        INIT_METHOD_CALL                                             $11, 'update'
         13        SEND_VAR_EX                                                  !2
         14        DO_FCALL                                          0  $12     
         15        INIT_METHOD_CALL                                             $12, 'final'
         16        DO_FCALL                                          0  $13     
         17        ASSIGN                                                       !3, $13
   41    18        ECHO                                                         !3
   42    19      > RETURN                                                       1

Class OOHashContext:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lXd3u
function name:  __construct
number of ops:  16
compiled vars:  !0 = $algo, !1 = $options, !2 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      0
          2        RECV_INIT                                            !2      null
    7     3        INIT_FCALL                                                   'hash_init'
          4        SEND_VAR                                                     !0
          5        SEND_VAR                                                     !1
          6        SEND_VAR                                                     !2
          7        DO_ICALL                                             $4      
          8        ASSIGN_OBJ                                           ~3      'hc'
          9        OP_DATA                                                      $4
         10        BOOL_NOT                                             ~5      ~3
         11      > JMPZ                                                         ~5, ->15
    8    12    >   NEW                                                  $6      'RuntimeException'
         13        DO_FCALL                                          0          
         14      > THROW                                             0          $6
   10    15    > > RETURN                                                       null

End of function __construct

Function update:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lXd3u
function name:  update
number of ops:  16
compiled vars:  !0 = $data
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
   12     1        INIT_FCALL                                                   'hash_update'
          2        FETCH_OBJ_R                                          ~1      'hc'
          3        SEND_VAL                                                     ~1
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $2      
          6        BOOL_NOT                                             ~3      $2
          7      > JMPZ                                                         ~3, ->11
   13     8    >   NEW                                                  $4      'RuntimeException'
          9        DO_FCALL                                          0          
         10      > THROW                                             0          $4
   15    11    >   FETCH_THIS                                           ~6      
         12        VERIFY_RETURN_TYPE                                           ~6
         13      > RETURN                                                       ~6
   16    14*       VERIFY_RETURN_TYPE                                           
         15*     > RETURN                                                       null

End of function update

Function update_file:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lXd3u
function name:  update_file
number of ops:  18
compiled vars:  !0 = $file, !1 = $scontext
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      null
   18     2        INIT_FCALL                                                   'hash_update_file'
          3        FETCH_OBJ_R                                          ~2      'hc'
          4        SEND_VAL                                                     ~2
          5        SEND_VAR                                                     !0
          6        SEND_VAR                                                     !1
          7        DO_ICALL                                             $3      
          8        BOOL_NOT                                             ~4      $3
          9      > JMPZ                                                         ~4, ->13
   19    10    >   NEW                                                  $5      'RuntimeException'
         11        DO_FCALL                                          0          
         12      > THROW                                             0          $5
   21    13    >   FETCH_THIS                                           ~7      
         14        VERIFY_RETURN_TYPE                                           ~7
         15      > RETURN                                                       ~7
   22    16*       VERIFY_RETURN_TYPE                                           
         17*     > RETURN                                                       null

End of function update_file

Function update_stream:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lXd3u
function name:  update_stream
number of ops:  18
compiled vars:  !0 = $handle, !1 = $length
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      -1
   24     2        INIT_FCALL                                                   'hash_update_stream'
          3        FETCH_OBJ_R                                          ~2      'hc'
          4        SEND_VAL                                                     ~2
          5        SEND_VAR                                                     !0
          6        SEND_VAR                                                     !1
          7        DO_ICALL                                             $3      
          8        BOOL_NOT                                             ~4      $3
          9      > JMPZ                                                         ~4, ->13
   25    10    >   NEW                                                  $5      'RuntimeException'
         11        DO_FCALL                                          0          
         12      > THROW                                             0          $5
   27    13    >   FETCH_THIS                                           ~7      
         14        VERIFY_RETURN_TYPE                                           ~7
         15      > RETURN                                                       ~7
   28    16*       VERIFY_RETURN_TYPE                                           
         17*     > RETURN                                                       null

End of function update_stream

Function final:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lXd3u
function name:  final
number of ops:  17
compiled vars:  !0 = $raw_output, !1 = $ret
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   29     0  E >   RECV_INIT                                            !0      <false>
   30     1        INIT_FCALL                                                   'hash_final'
          2        FETCH_OBJ_R                                          ~2      'hc'
          3        SEND_VAL                                                     ~2
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $3      
          6        ASSIGN                                                       !1, $3
   31     7        TYPE_CHECK                                       64  ~5      !1
          8        BOOL_NOT                                             ~6      ~5
          9      > JMPZ                                                         ~6, ->13
   32    10    >   NEW                                                  $7      'RuntimeException'
         11        DO_FCALL                                          0          
         12      > THROW                                             0          $7
   34    13    >   VERIFY_RETURN_TYPE                                           !1
         14      > RETURN                                                       !1
   35    15*       VERIFY_RETURN_TYPE                                           
         16*     > RETURN                                                       null

End of function final

End of class OOHashContext.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
177.12 ms | 3359 KiB | 18 Q