Skip to content

Correct / improve SymfonyProfilerController #370

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

Merged
merged 1 commit into from
Dec 29, 2019

Conversation

odolbeau
Copy link
Member

No description provided.

@@ -149,3 +149,8 @@ parameters:
message: "#^Call to an undefined method Symfony\\\\Component\\\\Translation\\\\TranslatorBagInterface\\|Symfony\\\\Contracts\\\\Translation\\\\TranslatorInterface\\:\\:transChoice\\(\\)\\.$#"
count: 2
path: Twig/TranslationExtension.php

-
message: "#^Call to method getValue\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\DataCollector\\\\Data\\.$#"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will become useless once missing use will be added in symfony
See: symfony/symfony#35122

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHPStan will also give an error when a message is not used anymore 👍 Great way of gradually improving code quality

compliments to @ondrejmirtes 👏

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 😊

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

/** @var \Symfony\Component\HttpKernel\DataCollector\RequestDataCollector */
$requestCollector = $this->profiler->loadProfile($token)->getCollector('request');

$message
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about reducing fluent usage? That way you don't need to rely on the message returning itself.

$message->setLocale()
$message->setTranslation()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the original syntax.

@@ -6,6 +6,7 @@ services:
- { name: 'data_collector', template: "@Translation/SymfonyProfiler/translation.html.twig", id: "translation", priority: 200 }

Translation\Bundle\Controller\SymfonyProfilerController:
autowire: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about moving this to a _defaults section?

_defaults:
    autowire: true
    autoconfigure: true

@odolbeau odolbeau merged commit 31c526c into php-translation:master Dec 29, 2019
@odolbeau odolbeau deleted the correct-controller branch December 29, 2019 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants