1
0
geforkt von D3Public/oxtotp

fix small code issues

Dieser Commit ist enthalten in:
Daniel Seifert 2022-10-01 14:44:36 +02:00
Ursprung ecb8b61923
Commit 4e8bae08e7
Signiert von: DanielS
GPG-Schlüssel-ID: 6A513E13AEE66170
9 geänderte Dateien mit 33 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -46,7 +46,8 @@
"laminas/laminas-math": "^3.2"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.19"
"friendsofphp/php-cs-fixer": "^2.19",
"phpstan/phpstan": "^1.8"
},
"suggest": {
"d3/modcfg": "Provides automatic installation routines"

8
phpstan.neon Normale Datei
Datei anzeigen

@ -0,0 +1,8 @@
parameters:
scanFiles:
- src/IntelliSenseHelper.php
- ../../oxid-esales/oxideshop-ce/source/oxfunctions.php
paths:
- src
level: 5
phpVersion: 70300

Datei anzeigen

@ -43,7 +43,7 @@ class d3user_totp extends AdminDetailsController
$soxId = $this->getEditObjectId();
if (isset($soxId) && $soxId != "-1") {
if ($soxId && $soxId != "-1") {
/** @var d3_totp_user $oUser */
$oUser = $this->getUserObject();
if ($oUser->load($soxId)) {

Datei anzeigen

@ -20,6 +20,7 @@ use D3\Totp\Application\Model\d3totp;
use D3\Totp\Modules\Application\Model\d3_totp_user;
use Exception;
use OxidEsales\Eshop\Application\Controller\AccountController;
use OxidEsales\Eshop\Application\Model\User;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\UtilsView;
@ -34,9 +35,9 @@ class d3_account_totp extends AccountController
{
$sRet = parent::render();
// is logged in ?
/** @var User|null $oUser */
$oUser = $this->getUser();
if (!$oUser) {
if (false === $oUser instanceof User) {
return $this->_sThisTemplate = $this->_sThisLoginTemplate;
}
@ -127,7 +128,7 @@ class d3_account_totp extends AccountController
$oUser = $this->getUser();
/** @var d3totp $oTotp */
$oTotp = $this->getTotpObject();
if ($oUser && $oUser->getId()) {
if ($oUser instanceof User && $oUser->getId()) {
$oTotp->loadByUserId($oUser->getId());
$oTotp->delete();
}

Datei anzeigen

@ -47,7 +47,7 @@ class d3totplogin extends FrontendController
/**
* @return Utils
*/
public function getUtils()
public function getUtils(): Utils
{
return Registry::getUtils();
}
@ -72,7 +72,7 @@ class d3totplogin extends FrontendController
/**
* @return d3backupcodelist
*/
public function getBackupCodeListObject()
public function getBackupCodeListObject(): d3backupcodelist
{
return oxNew(d3backupcodelist::class);
}
@ -82,7 +82,7 @@ class d3totplogin extends FrontendController
return Registry::getSession()->getVariable(d3totp::TOTP_SESSION_CURRENTCLASS);
}
public function previousClassIsOrderStep()
public function previousClassIsOrderStep(): bool
{
$sClassKey = Registry::getSession()->getVariable(d3totp::TOTP_SESSION_CURRENTCLASS);
$resolvedClass = Registry::getControllerClassNameResolver()->getClassNameById($sClassKey);
@ -96,7 +96,7 @@ class d3totplogin extends FrontendController
/**
* @return bool
*/
public function getIsOrderStep()
public function getIsOrderStep(): bool
{
return $this->previousClassIsOrderStep();
}
@ -106,11 +106,11 @@ class d3totplogin extends FrontendController
*
* @return array
*/
public function getBreadCrumb()
public function getBreadCrumb(): array
{
$aPaths = [];
$aPath = [];
$iBaseLanguage = Registry::getLang()->getBaseLanguage();
$iBaseLanguage = (int) Registry::getLang()->getBaseLanguage();
$aPath['title'] = Registry::getLang()->translateString('D3_TOTP_BREADCRUMB', $iBaseLanguage, false);
$aPath['link'] = $this->getLink();

Datei anzeigen

@ -67,7 +67,10 @@ class d3backupcode extends BaseModel
public function d3GetUser()
{
if ($this->getUser()) {
/** @var User|null $user */
$user = $this->getUser();
if ($user instanceof User) {
return $this->getUser();
}

Datei anzeigen

@ -46,7 +46,7 @@ class d3totp extends BaseModel
{
$this->init($this->tableName);
return parent::__construct();
parent::__construct();
}
/**
@ -124,9 +124,9 @@ class d3totp extends BaseModel
}
/**
* @return string
* @return string|null
*/
public function getSavedSecret()
public function getSavedSecret(): ?string
{
$seed_enc = $this->getFieldData('seed');
@ -197,7 +197,7 @@ class d3totp extends BaseModel
/**
* @param $totp
* @param $seed
* @return string
* @return bool
* @throws DatabaseConnectionException
* @throws d3totp_wrongOtpException
*/
@ -212,7 +212,7 @@ class d3totp extends BaseModel
if ($blNotVerified) {
throw oxNew(d3totp_wrongOtpException::class);
}
} elseif ($blNotVerified && $seed) {
} elseif ($blNotVerified && $seed !== null) {
throw oxNew(d3totp_wrongOtpException::class);
}
@ -282,6 +282,6 @@ class d3totp extends BaseModel
$oBackupCodeList = $this->d3GetBackupCodeListObject();
$oBackupCodeList->deleteAllFromUser($this->getFieldData('oxuserid'));
return parent::delete();
return parent::delete($oxid);
}
}

Datei anzeigen

@ -37,7 +37,7 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
$oUser = $this->getUser();
if ($oUser && $oUser->getId()) {
if ($oUser instanceof User && $oUser->getId()) {
$totp = $this->d3GetTotpObject();
$totp->loadByUserId($oUser->getId());

Datei anzeigen

@ -31,7 +31,7 @@ trait d3_totp_getUserTrait
{
$oUser = parent::getUser();
if ($oUser && $oUser->getId()) {
if ($oUser instanceof User && $oUser->getId()) {
$totp = $this->d3GetTotpObject();
$totp->loadByUserId($oUser->getId());