mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 18:58:46 +02:00
Improved typing and phpdoc type annotations
This commit is contained in:
parent
3817ba774d
commit
b7c8ca2a48
39 changed files with 189 additions and 129 deletions
|
@ -244,7 +244,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
return true;
|
||||
}
|
||||
|
||||
protected function _new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?AbstractNamedDBElement $entity = null)
|
||||
protected function _new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?AbstractNamedDBElement $entity = null): Response
|
||||
{
|
||||
$new_entity = $entity instanceof AbstractNamedDBElement ? clone $entity : new $this->entity_class();
|
||||
|
||||
|
|
|
@ -44,11 +44,18 @@ class HomepageController extends AbstractController
|
|||
public function getBanner(): string
|
||||
{
|
||||
$banner = $this->getParameter('partdb.banner');
|
||||
if (!is_string($banner)) {
|
||||
throw new \RuntimeException('The parameter "partdb.banner" must be a string.');
|
||||
}
|
||||
if (empty($banner)) {
|
||||
$banner_path = $this->kernel->getProjectDir()
|
||||
.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'banner.md';
|
||||
|
||||
return file_get_contents($banner_path);
|
||||
$tmp = file_get_contents($banner_path);
|
||||
if (false === $tmp) {
|
||||
throw new \RuntimeException('The banner file could not be read.');
|
||||
}
|
||||
$banner = $tmp;
|
||||
}
|
||||
|
||||
return $banner;
|
||||
|
|
|
@ -66,7 +66,7 @@ class UserSettingsController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route(path: '/2fa_backup_codes', name: 'show_backup_codes')]
|
||||
public function showBackupCodes()
|
||||
public function showBackupCodes(): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
|
||||
|
@ -74,7 +74,7 @@ class UserSettingsController extends AbstractController
|
|||
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
||||
|
||||
if (!$user instanceof User) {
|
||||
return new RuntimeException('This controller only works only for Part-DB User objects!');
|
||||
throw new RuntimeException('This controller only works only for Part-DB User objects!');
|
||||
}
|
||||
|
||||
if ($user->isSamlUser()) {
|
||||
|
|
|
@ -29,6 +29,7 @@ use Jbtronics\TFAWebauthn\Services\TFAWebauthnRegistrationHelper;
|
|||
use RuntimeException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
use function Symfony\Component\Translation\t;
|
||||
|
@ -40,7 +41,7 @@ class WebauthnKeyRegistrationController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route(path: '/webauthn/register', name: 'webauthn_register')]
|
||||
public function register(Request $request, TFAWebauthnRegistrationHelper $registrationHelper, EntityManagerInterface $em)
|
||||
public function register(Request $request, TFAWebauthnRegistrationHelper $registrationHelper, EntityManagerInterface $em): Response
|
||||
{
|
||||
//When user change its settings, he should be logged in fully.
|
||||
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue