Skip to content

Make ContainerExceptionInterface extend Throwable where it is available#23

Closed
ErikBooij wants to merge 1 commit intophp-fig:masterfrom
ErikBooij:master
Closed

Make ContainerExceptionInterface extend Throwable where it is available#23
ErikBooij wants to merge 1 commit intophp-fig:masterfrom
ErikBooij:master

Conversation

@ErikBooij
Copy link
Copy Markdown

I've run into some static analysis issues because the ContainerExceptionInterface provides no guarantee that it's actually throwable (or catchable more specifically).

I understand making it extend Throwable would break BC, so I think this would be the ideal middle ground, providing the benefit of stricter typing only where it's available.

@mnapoli
Copy link
Copy Markdown
Member

mnapoli commented May 4, 2019

👍 I've faced the same problem.

Is it a BC break to extend Throwable?

@ErikBooij
Copy link
Copy Markdown
Author

Current minimum compatibility constraint is

"require": {
    "php": ">=5.3.0"
}

Throwable is only available from 7.0 upwards.

@mnapoli
Copy link
Copy Markdown
Member

mnapoli commented May 4, 2019

OK I see, tagging a release that targets 7.0 wouldn't really be a BC break though since Composer will not install the new release unless you run PHP 7.

@ErikBooij
Copy link
Copy Markdown
Author

ErikBooij commented May 4, 2019

Agreed, and I'm not aware of the FIG's BC policy, but to me it seems unnecessary to limit BC to PHP 7+ going forward, while with this solution, we can still maintain compatibility with 5.3+.

Although I also don't see many changes/upgrades coming to this package in the future, since I guess it does what it's supposed to ;-)

If it's preferred to just extend Throwable without the existence check for the interface, I'm happy to change it.

@mnapoli
Copy link
Copy Markdown
Member

mnapoli commented May 4, 2019

You're right, this solution works fine!

I'm 👍 with both solution. Does anyone know what is needed to merge this?

@Jean85
Copy link
Copy Markdown
Member

Jean85 commented May 6, 2019

Unfortunately we do not have any kind of process defined for this kind of stuff. In any case, the editor(s) of this PSR (which are you @mnapoli along with @moufmouf) have the final say on this.

@ErikBooij
Copy link
Copy Markdown
Author

@mnapoli @moufmouf Could you please take another look at this and if it's acceptable, get it merged and released? Would be much appreciated.

@ErikBooij
Copy link
Copy Markdown
Author

@mnapoli @moufmouf @Jean85 Gentle reminder that this PR is still here and open 😉 Any chance we can get this merged and released?

@Jean85
Copy link
Copy Markdown
Member

Jean85 commented Oct 4, 2019

We've been discussing this kind of issues a lot lately, and we've condensed our proposed solution to updating PSR interfaces in a blog post. Please read it and provide your feedback!

https://www.php-fig.org/blog/2019/10/upgrading-psr-interfaces/

@ErikBooij
Copy link
Copy Markdown
Author

@Jean85 I've read the post and it makes total sense, I've filled in the feedback form.

At the same time, to be honest, I don't think it really applies to this PR, as this has specifically been created to not be a BC break, therefore I'd still love to just get this merged and released as 1.0.1

@ChristophWurst
Copy link
Copy Markdown

Hey, I'm in the process of adapting more PSR interfaces in Nextcloud and I came across this missing base class as I added the psr/conatiner package. Would it be possible to include this change with the v2.0 release together with #28?

@Jean85
Copy link
Copy Markdown
Member

Jean85 commented Jul 13, 2020

This could made even 1.1, and with no if shenanigans too!

ping @weierophinney

@weierophinney
Copy link
Copy Markdown
Contributor

@Jean85 Would this require an errata vote?

@mnapoli
Copy link
Copy Markdown
Member

mnapoli commented Jul 13, 2020

I hope not ^^

@Jean85
Copy link
Copy Markdown
Member

Jean85 commented Jul 13, 2020

@weierophinney IMHO it could be bundled up with everything else in the 1.1-2.0 evolution vote. As far as I'm concerned, this interface only enforces at the code level what the spec requires.

@weierophinney
Copy link
Copy Markdown
Contributor

@Jean85 This patch actually duplicates work already in #20, which does target 1.1, and doesn't require a conditional as it requires PHP 7.2. As such, I'm closing it.

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.

5 participants