| Total Complexity | 5 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 7 | final class Utils |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Securely erases a memory block |
||
| 11 | * |
||
| 12 | * @param string $data |
||
| 13 | * @return void |
||
| 14 | */ |
||
| 15 | public static function zero(string $data) |
||
| 16 | { |
||
| 17 | return \sodium_memzero($data); |
||
|
|
|||
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Generates a crypto keypair |
||
| 22 | * |
||
| 23 | * @return array |
||
| 24 | */ |
||
| 25 | public static function generateKeypair() |
||
| 26 | { |
||
| 27 | try { |
||
| 28 | $keypair = \sodium_crypto_box_keypair(); |
||
| 29 | return [ |
||
| 30 | 'public' => \sodium_crypto_box_secretkey($keypair), |
||
| 31 | 'secret' => \sodium_crypto_box_publickey($keypair) |
||
| 32 | ]; |
||
| 33 | } catch (SodiumException $e) { |
||
| 34 | throw new Exception($e->getMessage()); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Generates a signing keypair |
||
| 40 | * |
||
| 41 | * @return array |
||
| 42 | */ |
||
| 43 | public static function generateSigningKeypair() |
||
| 53 | } |
||
| 54 | } |
||
| 55 | } |
||
| 56 |
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.