Skip to content

Commit

Permalink
Fix static analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioribeiro committed Oct 21, 2019
1 parent ffdcb82 commit 511944a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
44 changes: 23 additions & 21 deletions src/Google2FA.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ class Google2FA
/**
* Find a valid One Time Password.
*
* @param string $secret
* @param string $key
* @param int $window
* @param int $startingTimestamp
* @param int $timestamp
* @param int|null $oldTimestamp
* @param string $secret
* @param string $key
* @param int|null $window
* @param int $startingTimestamp
* @param int $timestamp
* @param int|null $oldTimestamp
*
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
* @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException
*
* @return bool
* @return bool|int
*/
public function findValidOTP(
$secret,
Expand Down Expand Up @@ -219,7 +219,7 @@ public function getWindow($window = null)
/**
* Make a window based starting timestamp.
*
* @param int $window
* @param int|null $window
* @param int $timestamp
* @param int|null $oldTimestamp
*
Expand Down Expand Up @@ -290,8 +290,10 @@ public function oathTruncate($hash)

$temp = unpack('N', substr($hash, $offset, 4));

$temp = $temp[1] & 0x7fffffff;

return substr(
$temp[1] & 0x7fffffff,
(string) $temp,
-$this->getOneTimePasswordLength()
);
}
Expand All @@ -301,7 +303,7 @@ public function oathTruncate($hash)
*
* @param string $string
*
* @return string
* @return string|null
*/
public function removeInvalidChars($string)
{
Expand Down Expand Up @@ -389,11 +391,11 @@ public function setWindow($window)
* Verifies a user inputted key against the current timestamp. Checks $window
* keys either side of the timestamp.
*
* @param string $key - User specified key
* @param null|string $secret
* @param null|int $window
* @param null|int $timestamp
* @param null|string|int $oldTimestamp
* @param string $key - User specified key
* @param string $secret
* @param null|int $window
* @param null|int $timestamp
* @param null|int $oldTimestamp
*
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
Expand All @@ -403,7 +405,7 @@ public function setWindow($window)
*/
public function verify(
$key,
$secret = null,
$secret,
$window = null,
$timestamp = null,
$oldTimestamp = null
Expand All @@ -421,11 +423,11 @@ public function verify(
* Verifies a user inputted key against the current timestamp. Checks $window
* keys either side of the timestamp.
*
* @param string $secret
* @param string $key - User specified key
* @param null|int $window
* @param null|int $timestamp
* @param null|string|int $oldTimestamp
* @param string $secret
* @param string $key - User specified key
* @param int|null $window
* @param null|int $timestamp
* @param null|int $oldTimestamp
*
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Base32.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function isCharCountNotAPowerOfTwo($b32)
* Pad string with random base 32 chars.
*
* @param string $string
* @param string $length
* @param int $length
*
* @throws \Exception
*
Expand Down
4 changes: 2 additions & 2 deletions src/Support/QRCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public function getQRCodeUrl($company, $holder, $secret)
'&algorithm=' .
rawurlencode(strtoupper($this->getAlgorithm())) .
'&digits=' .
rawurlencode(strtoupper($this->getOneTimePasswordLength())) .
rawurlencode(strtoupper((string) $this->getOneTimePasswordLength())) .
'&period=' .
rawurlencode(strtoupper($this->getKeyRegeneration())) .
rawurlencode(strtoupper((string) $this->getKeyRegeneration())) .
'';
}
}
2 changes: 1 addition & 1 deletion tests/tools/analyse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function main

banner

$PHPSTAN analyse --level 4 src
$PHPSTAN analyse --level max src
}

function get_phpstan_path()
Expand Down

0 comments on commit 511944a

Please sign in to comment.