Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update for symfony 7 compatibility #292

Merged
merged 19 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 7 additions & 29 deletions Command/AutoClosingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,40 +29,18 @@ final class AutoClosingCommand extends Command
{
protected static $defaultName = 'ticket:autoclosing';

/**
* @var TicketManagerInterface
*/
private $ticketManager;
private bool|string|int|float|\UnitEnum|array|null $locale = 'en';

/**
* @var UserManagerInterface
*/
private $userManager;
private string $translationDomain = 'HackzillaTicketBundle';

/**
* @var string
*/
private $locale = 'en';
private readonly TranslatorInterface $translator;

/**
* @var string
*/
private $translationDomain = 'HackzillaTicketBundle';

/**
* @var TranslatorInterface
*/
private $translator;

public function __construct(TicketManagerInterface $ticketManager, UserManagerInterface $userManager, LocaleAwareInterface $translator, ParameterBagInterface $parameterBag)
public function __construct(private readonly TicketManagerInterface $ticketManager, private readonly UserManagerInterface $userManager, LocaleAwareInterface $translator, ParameterBagInterface $parameterBag)
{
parent::__construct();

$this->ticketManager = $ticketManager;
$this->userManager = $userManager;

if (!is_a($translator, TranslatorInterface::class)) {
throw new \InvalidArgumentException(\get_class($translator).' Must implement TranslatorInterface and LocaleAwareInterface');
if (!$translator instanceof TranslatorInterface) {
throw new \InvalidArgumentException($translator::class.' Must implement TranslatorInterface and LocaleAwareInterface');
}

$this->translator = $translator;
Expand All @@ -76,7 +54,7 @@ public function __construct(TicketManagerInterface $ticketManager, UserManagerIn
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this
->setDescription('Automatically close resolved tickets still opened')
Expand Down
19 changes: 3 additions & 16 deletions Command/TicketManagerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,15 @@ final class TicketManagerCommand extends Command
{
protected static $defaultName = 'ticket:create';

/**
* @var TicketManagerInterface
*/
private $ticketManager;

/**
* @var UserManagerInterface
*/
private $userManager;

public function __construct(TicketManagerInterface $ticketManager, UserManagerInterface $userManager)
public function __construct(private readonly TicketManagerInterface $ticketManager, private readonly UserManagerInterface $userManager)
{
parent::__construct();

$this->ticketManager = $ticketManager;
$this->userManager = $userManager;
}

/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this
->setDescription('Create a new Ticket')
Expand Down Expand Up @@ -90,7 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->ticketManager->updateTicket($ticket, $message);

$output->writeln(
"Ticket with subject '".$ticket->getSubject()."' has been created with ticketnumber #".$ticket->getId().''
"Ticket with subject '".$ticket->getSubject()."' has been created with ticketnumber #".$ticket->getId()
);

return Command::SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion Component/TicketFeatures.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class TicketFeatures
* @param array<string, bool> $features
* @param string $messageClass TicketMessage class
*/
private $features = [];
private array $features;

/**
* @param string $messageClass TicketMessage class
Expand Down
22 changes: 3 additions & 19 deletions Controller/TicketAttachmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,14 @@
*/
final class TicketAttachmentController extends AbstractController
{
private DownloadHandler $downloadHandler;

private TicketManager $ticketManager;

private TranslatorInterface $translator;

private UserManagerInterface $userManager;

public function __construct(
DownloadHandler $downloadHandler,
TicketManager $ticketManager,
TranslatorInterface $translator,
UserManagerInterface $userManager
) {
$this->downloadHandler = $downloadHandler;
$this->ticketManager = $ticketManager;
$this->translator = $translator;
$this->userManager = $userManager;
public function __construct(private readonly DownloadHandler $downloadHandler, private readonly TicketManager $ticketManager, private readonly TranslatorInterface $translator, private readonly UserManagerInterface $userManager)
{
}

/**
* Download attachment on message.
*/
public function downloadAction(int $ticketMessageId): Response
public function download(int $ticketMessageId): Response
{
$ticketMessage = $this->ticketManager->getMessageById($ticketMessageId);

Expand Down
Loading
Loading