Thanks to visit codestin.com
Credit goes to github.com

Skip to content

final ProgressBar #24098

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

Closed
dominikzogg opened this issue Sep 5, 2017 · 10 comments
Closed

final ProgressBar #24098

dominikzogg opened this issue Sep 5, 2017 · 10 comments

Comments

@dominikzogg
Copy link

Q A
Bug report? yes
Feature request? no
BC Break report? yes
RFC? no
Symfony version 3.3.x

Within 3.3 the Keyword final gets added to ProgressBar which is a BC, there is no "internal" PHP Doc given in 3.2

https://github.com/symfony/symfony/blob/3.3/src/Symfony/Component/Console/Helper/ProgressBar.php#L25

@linaori
Copy link
Contributor

linaori commented Sep 5, 2017

See #20487 for the reasoning. Is there anything that broke for you?

@dominikzogg
Copy link
Author

@iltar mocking within a test. A BC is an objective thing and not a perspective of a single person or a group. Does it break existing code event tests => BC, the only exception is if some plays with reflection.

@linaori
Copy link
Contributor

linaori commented Sep 5, 2017

It was considered a BC break, but it was already not working for inheritance, so they've decided to make it impossible to extend. It will save developers a lot of headache and time just to find out it doesn't work.

For your tests, see: https://github.com/symfony/symfony/pull/20487/files#diff-e8a7dfc3f0826c43961bd686470a714bR356

@dominikzogg
Copy link
Author

@iltar thanks for help

I have no reason to change my opinion about BC, cause its a boolean decision, not something that is to be discussed, as for example things like code quality.

Its painful to see, that i was right about my guess about the reaction on this issue. Made the same experience in most of issues i opened.

@linaori
Copy link
Contributor

linaori commented Sep 5, 2017

While BC breaks are either yes or no, that doesn't mean that the developer experience has to suffer on it.

Yes - Symfony has a policy about BC breaks.
Yes - This is a BC break.

However, this issue caused some hard to find and debug errors, which really gave developers problems. In this case I personally agree with the fact that it was made final as no production code would've worked. This is also preventing developers from wasting time and is worth more than preventing a BC break.

Yes - your test broke, but luckily it's only a test and it takes a few minutes to fix it at most. Honestly, I don't see the problem, life nor software development are black and white.

@chalasr
Copy link
Member

chalasr commented Sep 5, 2017

You are right, it's a BC break. Even if inheritance was broken in some cases, it could have been working enough for your use case.
We could have marked it @final for deprecating extending it at first. But then, we would have let other users use the buggy part.
Please do not believe that we are not open to discuss any of the changes we make. If you (or others) have suggestions for reducing the impact of the breaking change which is worth the hassle, we can always reconsider. That's always a case by case decision.
Thanks.

@funivan
Copy link

funivan commented Jul 29, 2019

@linaori If it was a BC Break why symfony haven't release a new version?
In symfony docs: Also note that backward compatibility breaks are tolerated if they are required to fix a *security* issue.
This class has @internal tag - no!
Was it a security Issue - no!
Can I extend it and use without bugs - yes.

p.s. Symfony can bump up PATCH version instead of MINOR, there is no difference. New version Break current working code adding final modifier.

@linaori
Copy link
Contributor

linaori commented Jul 29, 2019

As this issue is close to 2 years old, I don't think it's worth discussing anything here. If there's still an issue related to this, you can create a new issue.

@maartenderie
Copy link

BC or not; would it be possible to make a ProgressBar-interface that can be mocked? Please?

@NickSun
Copy link

NickSun commented Jan 6, 2023

@maartenderie as a workaround you can use an anonymous class:

        $progressBarMock = new class {
            public function start(): void
            {}
            public function advance(): void
            {}
            public function finish(): void
            {}
        };

        $outputStyleMock = $this->createMock(OutputStyle::class);
        $outputStyleMock
            ->expects($this->once())
            ->method('createProgressBar')
            ->willReturn($progressBarMock);

        $command->setOutput($outputStyleMock);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants