-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Upgrading to Symfony 7 #14887
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
Upgrading to Symfony 7 #14887
Conversation
I'm trying to resolve the migrations issue in #14954 to get the PHPSTAN checks green |
I have resolved 72 PHPStan errors, and there is 1 remaining (or 2, including the migration DI issue, which will be fixed in a separate PR). I'm unsure how to resolve this one. Should PHPStan ignore it? https://github.com/mautic/mautic/blob/7.x/app/bundles/CoreBundle/Translation/TranslatorLoader.php The Translator class has been marked as final since Symfony 7.1, as indicated in the docblock. https://github.com/symfony/framework-bundle/blob/7.2/Translation/Translator.php
|
@matbcvo I think we should refactor to decorator pattern. It would fail with a PHP error if we wouldn't right? This is what AI dumped: <?php
declare(strict_types=1);
namespace Mautic\CoreBundle\Translation;
use Symfony\Bundle\FrameworkBundle\Translation\Translator as FrameworkTranslator;
use Symfony\Component\Translation\MessageCatalogueInterface;
class TranslatorLoader implements TranslatorInterface, LocaleAwareInterface
{
private FrameworkTranslator $translator;
public function __construct(FrameworkTranslator $translator)
{
$this->translator = $translator;
}
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string
{
return $this->translator->trans($id, $parameters, $domain, $locale);
}
public function getCatalogue($locale = null): MessageCatalogueInterface
{
// Custom logic before calling parent
if ('en_US' !== $locale && !$this->translator->getCatalogue('en_US')->has('loaded')) {
$this->translator->addResource('mautic', null, 'en_US', 'messages');
}
$this->translator->addResource('mautic', null, $locale, 'messages');
return $this->translator->getCatalogue($locale);
}
// Delegate other required interface methods...
} <?php
namespace Mautic\CoreBundle\DependencyInjection\Compiler;
use Mautic\CoreBundle\Translation\TranslatorDecorator;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
class TranslationLoaderPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
if (!$container->has('translator.default')) {
return;
}
// Create decorator service
$decoratorDefinition = new Definition(TranslatorDecorator::class);
$decoratorDefinition->setDecoratedService('translator.default');
$decoratorDefinition->setArgument(0, new Reference('translator.default.inner'));
$decoratorDefinition->setPublic(true);
$container->setDefinition('mautic.translator.decorator', $decoratorDefinition);
}
} |
…tead of deprecated string argument
…, per Symfony 7.2 docs
…constant due to AsCommand implementation
…er exists in klapaudius/FOSOAuthServerBundle
Subtle fixes
Subtle fixes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @escopecz!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
The composer changes were generated with command
composer update symfony/* klapaudius/oauth-server-bundle
It generated this output:
📋 Steps to test this PR: