Fix phpstan issues

This commit is contained in:
2023-12-12 22:34:26 +01:00
parent af663cf27c
commit da997badd9
26 changed files with 275 additions and 261 deletions

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\ReportBundle\Form;
use Chill\CustomFieldsBundle\Form\Type\CustomFieldType;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Form\Type\AppendScopeChoiceTypeTrait;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
@@ -22,41 +23,16 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
class ReportType extends AbstractType
final class ReportType extends AbstractType
{
use AppendScopeChoiceTypeTrait;
/**
* @var AuthorizationHelper
*/
protected $authorizationHelper;
/**
* @var \Doctrine\Persistence\ObjectManager
*/
protected $om;
/**
* @var TranslatableStringHelper
*/
protected $translatableStringHelper;
/**
* @var \Chill\MainBundle\Entity\User
*/
protected $user;
public function __construct(
AuthorizationHelper $helper,
TokenStorageInterface $tokenStorage,
TranslatableStringHelper $translatableStringHelper,
ObjectManager $om
) {
$this->authorizationHelper = $helper;
$this->user = $tokenStorage->getToken()->getUser();
$this->translatableStringHelper = $translatableStringHelper;
$this->om = $om;
}
private readonly AuthorizationHelper $authorizationHelper,
private readonly TokenStorageInterface $tokenStorage,
private readonly TranslatableStringHelper $translatableStringHelper,
private readonly ObjectManager $om
) {}
public function buildForm(FormBuilderInterface $builder, array $options)
{
@@ -74,11 +50,17 @@ class ReportType extends AbstractType
'group' => $options['cFGroup'], ]
);
$user = $this->tokenStorage->getToken()->getUser();
if (!$user instanceof User) {
throw new \RuntimeException('user must be a regular user');
}
$this->appendScopeChoices(
$builder,
$options['role'],
$options['center'],
$this->user,
$user,
$this->authorizationHelper,
$this->translatableStringHelper,
$this->om