Skip to content

[FrameworkBundle] Trigger deprecations on stderr instead of using trigger_deprecation call #43765

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
Oct 30, 2021

Conversation

welcoMattic
Copy link
Member

@welcoMattic welcoMattic commented Oct 26, 2021

Q A
Branch? 5.3
Bug fix? no
New feature? no
Deprecations? no
Tickets
License MIT
Doc PR

As discussed in #43758 (comment), I change the way to deprecate options by using warning on stderr instead of trigger_deprecation call.

@chalasr
Copy link
Member

chalasr commented Oct 26, 2021

👍 Thanks. Can you check if other commands have the same problem btw?

@welcoMattic
Copy link
Member Author

@chalasr I've found 4 trigger_deprecation calls in Symfony\Component\Messenger\Command\AbstractFailedMessagesCommand, but as it's in Abstract, I don't have access to $output to trigger a warning. Should I leave it as it is?

@chalasr
Copy link
Member

chalasr commented Oct 27, 2021

Maybe we can add an abstract getOutput(): OutputInterface method to that abstract class, implement it from concrete commands and call it where needed? The abstract command is internal so no BC to worry about

@welcoMattic
Copy link
Member Author

welcoMattic commented Oct 27, 2021

It works, expect for the trigger_deprecation located in the constructor of the abstract

@stof
Copy link
Member

stof commented Oct 27, 2021

if it is in the constructor, it means that it is a deprecation targetting the code running the constructor (i.e. the code registering the command).

Deprecation messages needing to use stderr are only deprecation messages where fixing them involves changing the CLI command you run

@welcoMattic welcoMattic requested a review from sroze as a code owner October 27, 2021 12:22
@welcoMattic welcoMattic changed the title [FrameworkBundle] Trigger deprecations on stderr instead of using trigger_deprecation call [FrameworkBundle][Messenger] Trigger deprecations on stderr instead of using trigger_deprecation call Oct 27, 2021
@welcoMattic welcoMattic force-pushed the fix/trans-update-deprecations branch 2 times, most recently from 55880fa to 11e1c06 Compare October 27, 2021 12:24
@welcoMattic
Copy link
Member Author

Ok, so as discussed in #43765 (comment), we don't need to change the way to deprecated methods here. Let's close this, ok for you @chalasr ?

@@ -183,7 +185,7 @@ protected function printPendingMessagesMessage(ReceiverInterface $receiver, Symf
protected function getReceiver(/* string $name = null */): ReceiverInterface
{
if (1 > \func_num_args() && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface && !$this instanceof \Mockery\MockInterface) {
trigger_error_deprecation('symfony/messenger', '5.3', 'The "%s()" method will have a new "string $name" argument in version 6.0, not defining it is deprecated.', __METHOD__);
$this->getOutput()->warning(sprintf('The "%s()" method will have a new "string $name" argument in version 6.0, not defining it is deprecated since version 5.3.', __METHOD__));
Copy link
Member Author

Choose a reason for hiding this comment

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

trigger_error_deprecation must be trigger_deprecation right?

@welcoMattic welcoMattic force-pushed the fix/trans-update-deprecations branch from 11e1c06 to 8b534e8 Compare October 28, 2021 14:46
@welcoMattic welcoMattic changed the title [FrameworkBundle][Messenger] Trigger deprecations on stderr instead of using trigger_deprecation call [FrameworkBundle] Trigger deprecations on stderr instead of using trigger_deprecation call Oct 28, 2021
@fabpot fabpot force-pushed the fix/trans-update-deprecations branch from 8b534e8 to 663eb29 Compare October 30, 2021 10:18
@fabpot
Copy link
Member

fabpot commented Oct 30, 2021

Thank you @welcoMattic.

@fabpot fabpot merged commit f7319e6 into symfony:5.3 Oct 30, 2021
@welcoMattic welcoMattic deleted the fix/trans-update-deprecations branch November 10, 2021 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants