Fix all phpstan and php-cs-fixer errors

This commit is contained in:
osaajani 2019-10-30 00:17:10 +01:00
parent 117c18ddca
commit 485a0cb6fd
39 changed files with 994 additions and 1142 deletions

View file

@ -7,10 +7,10 @@
public function __construct()
{
$bdd = Model::connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
$bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
$this->internal_user = new \controllers\internals\User($bdd);
\controllers\internals\Tool::verify_connect();
\controllers\internals\Tool::verifyconnect();
}
/**
@ -31,25 +31,25 @@
{
$password = $_POST['password'] ?? false;
if (!$this->verifyCSRF($csrf)) {
\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
if (!$this->verify_csrf($csrf)) {
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Account', 'show'));
}
if (!$password) {
\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous devez renseigner un mot de passe.');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous devez renseigner un mot de passe.');
return $this->redirect(\descartes\Router::url('Account', 'show'));
}
$update_password_result = $this->internal_user->update_password($_SESSION['user']['id'], $password);
if (!$update_password_result) {
\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Impossible de mettre à jour le mot de passe.');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Impossible de mettre à jour le mot de passe.');
return $this->redirect(\descartes\Router::url('Account', 'show'));
}
\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'Le mot de passe a bien été mis à jour.');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'Le mot de passe a bien été mis à jour.');
return $this->redirect(\descartes\Router::url('Account', 'show'));
}
/**
@ -61,26 +61,26 @@
{
$transfer = $_POST['transfer'] ?? false;
if (!$this->verifyCSRF($csrf)) {
\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
if (!$this->verify_csrf($csrf)) {
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Account', 'show'));
}
if ($transfer === false) {
\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous devez choisir une option parmis celles de la liste déroulante.');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous devez choisir une option parmis celles de la liste déroulante.');
return $this->redirect(\descartes\Router::url('Account', 'show'));
}
$transfer_update_result = $this->internal_user->update_transfer($_SESSION['user']['id'], $transfer);
if (!$transfer_update_result) {
\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Impossible de mettre à jour.');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Impossible de mettre à jour.');
return $this->redirect(\descartes\Router::url('Account', 'show'));
}
$_SESSION['user']['transfer'] = $transfer;
\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'Le transfert a bien été ' . ($transfer ? 'activé' : 'désactivé') . '.');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'Le transfert a bien été ' . ($transfer ? 'activé' : 'désactivé') . '.');
return $this->redirect(\descartes\Router::url('Account', 'show'));
}
/**
@ -91,33 +91,34 @@
*/
public function update_email($csrf)
{
if (!$this->verifyCSRF($csrf)) {
\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
if (!$this->verify_csrf($csrf)) {
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Account', 'show'));
}
$email = $_POST['email'] ?? false;
if (!$email) {
\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous devez fournir une adresse e-mail !');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous devez fournir une adresse e-mail !');
return $this->redirect(\descartes\Router::url('Account', 'show'));
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'L\'adresse e-mail n\'est pas une adresse valide.');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'L\'adresse e-mail n\'est pas une adresse valide.');
return $this->redirect(\descartes\Router::url('Account', 'show'));
}
$update_email_result = $this->internal_user->update_email($_SESSION['user']['id'], $email);
if (!$update_email_result) {
\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Impossible de mettre à jour.');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Impossible de mettre à jour.');
return $this->redirect(\descartes\Router::url('Account', 'show'));
;
}
$_SESSION['user']['email'] = $email;
\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'L\'email a bien été mis à jour.');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'L\'email a bien été mis à jour.');
return $this->redirect(\descartes\Router::url('Account', 'show'));
}
/**
@ -127,22 +128,22 @@
*/
public function delete($csrf)
{
if (!$this->verifyCSRF($csrf)) {
\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
if (!$this->verify_csrf($csrf)) {
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Account', 'show'));
}
$delete_account = $_POST['delete_account'] ?? false;
if (!$delete_account) {
\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Pour supprimer le compte, vous devez cocher la case correspondante.');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Pour supprimer le compte, vous devez cocher la case correspondante.');
return $this->redirect(\descartes\Router::url('Account', 'show'));
}
$delete_account_result = $this->internal_user->delete($_SESSION['user']['id']);
if (!$delete_account_result) {
\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Impossible de supprimer le compte.');
return header('Location: ' . \descartes\Router::url('Account', 'show'));
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Impossible de supprimer le compte.');
return $this->redirect(\descartes\Router::url('Account', 'show'));
}
return $this->logout();
@ -150,12 +151,12 @@
/**
* Logout a user and redirect to login page
* @return void
* @return null
*/
public function logout()
{
session_unset();
session_destroy();
return header('Location: ' . \descartes\Router::url('Connect', 'login'));
return $this->redirect(\descartes\Router::url('Connect', 'login'));
}
}