@@ -13,44 +13,52 @@ class HashFunctionTests
1313
1414 public function hash_hmac (): void
1515 {
16- assertType ('non-empty-string ' , hash_hmac ('md5 ' , 'data ' , 'key ' ));
17- assertType ('non-empty-string ' , hash_hmac ('sha256 ' , 'data ' , 'key ' ));
16+ assertType ('lowercase-string&non-falsy-string ' , hash_hmac ('md5 ' , 'data ' , 'key ' ));
17+ assertType ('non-falsy-string ' , hash_hmac ('md5 ' , 'data ' , 'key ' , true ));
18+ assertType ('lowercase-string&non-falsy-string ' , hash_hmac ('sha256 ' , 'data ' , 'key ' ));
19+ assertType ('non-falsy-string ' , hash_hmac ('sha256 ' , 'data ' , 'key ' , true ));
1820 }
1921
2022 public function hash_hmac_file (string $ string ): void
2123 {
22- assertType ('non-empty-string|false ' , hash_hmac_file ('md5 ' , 'filename ' , 'key ' ));
23- assertType ('non-empty-string|false ' , hash_hmac_file ('sha256 ' , 'filename ' , 'key ' ));
24- assertType ('(non-empty-string|false) ' , hash_hmac_file ($ string , 'filename ' , 'key ' ));
24+ assertType ('(lowercase-string&non-falsy-string)|false ' , hash_hmac_file ('md5 ' , 'filename ' , 'key ' ));
25+ assertType ('non-falsy-string|false ' , hash_hmac_file ('md5 ' , 'filename ' , 'key ' , true ));
26+ assertType ('(lowercase-string&non-falsy-string)|false ' , hash_hmac_file ('sha256 ' , 'filename ' , 'key ' ));
27+ assertType ('non-falsy-string|false ' , hash_hmac_file ('sha256 ' , 'filename ' , 'key ' , true ));
28+ assertType ('((lowercase-string&non-falsy-string)|false) ' , hash_hmac_file ($ string , 'filename ' , 'key ' ));
29+ assertType ('(non-falsy-string|false) ' , hash_hmac_file ($ string , 'filename ' , 'key ' , true ));
2530 }
2631
2732 public function hash ($ mixed ): void
2833 {
29- assertType ('non-empty -string ' , hash ('sha256 ' , 'data ' , false ));
30- assertType ('non-empty -string ' , hash ('sha256 ' , 'data ' , true ));
31- assertType ('non-empty -string ' , hash ('md5 ' , $ mixed , false ));
34+ assertType ('lowercase-string& non-falsy -string ' , hash ('sha256 ' , 'data ' , false ));
35+ assertType ('non-falsy -string ' , hash ('sha256 ' , 'data ' , true ));
36+ assertType ('lowercase-string& non-falsy -string ' , hash ('md5 ' , $ mixed , false ));
3237 }
3338
3439 public function hash_file (): void
3540 {
36- assertType ('non-empty-string|false ' , hash_file ('sha256 ' , 'filename ' , false ));
37- assertType ('non-empty-string|false ' , hash_file ('sha256 ' , 'filename ' , true ));
38- assertType ('non-empty-string|false ' , hash_file ('crc32 ' , 'filename ' ));
41+ assertType ('(lowercase-string&non-falsy-string)|false ' , hash_file ('sha256 ' , 'filename ' , false ));
42+ assertType ('non-falsy-string|false ' , hash_file ('sha256 ' , 'filename ' , true ));
43+ assertType ('(lowercase-string&non-falsy-string)|false ' , hash_file ('crc32 ' , 'filename ' ));
44+ assertType ('non-falsy-string|false ' , hash_file ('crc32 ' , 'filename ' , true ));
3945 }
4046
4147 public function hash_hkdf (): void
4248 {
43- assertType ('non-empty -string ' , hash_hkdf ('sha256 ' , 'key ' ));
49+ assertType ('non-falsy -string ' , hash_hkdf ('sha256 ' , 'key ' ));
4450 }
4551
4652 public function hash_pbkdf2 (): void
4753 {
48- assertType ('non-empty-string ' , hash_pbkdf2 ('sha256 ' , 'password ' , 'salt ' , 1000 ));
54+ assertType ('lowercase-string&non-falsy-string ' , hash_pbkdf2 ('sha256 ' , 'password ' , 'salt ' , 1000 ));
55+ assertType ('non-falsy-string ' , hash_pbkdf2 ('sha256 ' , 'password ' , 'salt ' , 1000 , 0 , true ));
4956 }
5057
5158 public function caseSensitive ()
5259 {
53- assertType ('non-empty-string ' , hash ('SHA256 ' , 'data ' ));
60+ assertType ('lowercase-string&non-falsy-string ' , hash ('SHA256 ' , 'data ' ));
61+ assertType ('non-falsy-string ' , hash ('SHA256 ' , 'data ' , true ));
5462 }
5563
5664 public function constantStrings (int $ type )
@@ -69,7 +77,8 @@ public function constantStrings(int $type)
6977 return ;
7078 }
7179
72- assertType ('non-empty-string ' , hash_pbkdf2 ($ algorithm , 'password ' , 'salt ' , 1000 ));
80+ assertType ('lowercase-string&non-falsy-string ' , hash_pbkdf2 ($ algorithm , 'password ' , 'salt ' , 1000 ));
81+ assertType ('non-falsy-string ' , hash_pbkdf2 ($ algorithm , 'password ' , 'salt ' , 1000 , 0 , true ));
7382 }
7483
7584}
0 commit comments