-
Notifications
You must be signed in to change notification settings - Fork 53
CacheException / Throwable #13
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
Conversation
…terface for PHP 7
Can you merge the pull request? |
|
Its works, your example is wrong https://3v4l.org/7NPYS A class cant extend a Throwable interface you always need a Exception class |
Any news ? |
@michaelcullum @dragoonis Is this PR mergeable ? Thx |
@Seldaek @michaelcullum any chance this could be looked at? PHPStan gives type errors, this change would fix it.
|
/ping @weaverryan |
The problem here is that so if you intend to throw, you need to declare your exception class: namespace MyCache;
class InvalidArgumentException extends \RuntimeException implements \Psr\SimpleCache\InvalidArgumentException {} Don't know why it is so, probably to allow use any but it allows actual exception to extend any of the namespace MyCache;
class InvalidArgumentException extends \Exception implements \Psr\SimpleCache\InvalidArgumentException {}
class InvalidArgumentException extends \RuntimeException implements \Psr\SimpleCache\InvalidArgumentException {}
class InvalidArgumentException extends \Throwable implements \Psr\SimpleCache\InvalidArgumentException {} I think it would still make sense to make the class in this project extend |
src/ThrowablePhp5.php
Outdated
/** | ||
* Interface for PHP 5 backward compatibility. | ||
*/ | ||
interface ThrowablePhp5 |
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.
you are not solving the problem here, ThrowablePhp5
is still just an interface, not \Exception
subclass.
this should probably be class ThrowablePhp5 extends \Exception
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.
CacheException
is an interface, so can't extends a class.
That's solve the problem for PHP 7.
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.
@glensc For PHP 5 there is no way to solve the problem as there is no interface for Exception
s. There shouldn't be any implementations as the repository only contains interfaces. The ThrowablePhp5
is there only for BC.
As the |
…n and check existence of class
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/ |
Is there anything preventing this PR to be merged? It is backward-compatible as any class that can be thrown has to be @Jean85 I've read the chapter about the problem and it doesn't apply here. There are no types added. Ping @Seldaek |
Now we have a proper bylaw and procedure to handle this kind of cases: https://www.php-fig.org/bylaws/psr-evolution/ We could handle this with a bump to the PHP requirement to (at least) |
@Jean85 Thanks, that makes sense 👍 |
So i removed PHP5 compatibility 😄 |
@Jean85 as far as i read the change in this pull request is BC compatible with php5. why not keep it compatible with php5 and have the fixed behavior for php7? |
This change would be released as a new minor version, so whoever uses it on PHP 5 would still rely on the 1.0 release of this package. That would leave PHP 7 users with the fix, which would impact mainly static analysis and correct implementation of the spec, not runtime. |
Hey everyone! Thanks for commenting here. FYI: The authors of this standard are me, and @Seldaek, so there's no use in pinging other people. Please continue to ping @Jean85 as it's his responsibility to review community stuff. I'm sorry that you're seeing issues with Stan. I think it's a legitimate time to review this implementation. When I created this standard, PHPStan wasn't a mature library in PHP ecosystem and I didn't run it against it. Back in 2019 when people were looking into changes, the FIG's upgrade policy wasn't matured or trialed out either, so this is why I didn't consider making any changes to this at that time. |
Technical Review: I can see that PHP7 has added What the community is asking for, is a dual-compatible implementation between PHP5 and PHP7, and using composer to handle the "figuring out" of which version of the library to use. This means the FIG will need to consider maintaining 2 versions of this, and if you don't configure composer correctly, then you'll get the wrong version. I'd like to hear from @Jean85 on what certainties he can provide me with, that the decided approach going forward, is safe, for people who don't specify the PHP version in their composer, and for developers who aren't running composer update/install on the production target environment, but instead their local machine (i.e: --ignore-platform-reqs). I hope this made sense, and I'm looking forward to hearing what ideas and safety measures can be put in place, to make sure PHP5 consumers already using this library are not going to get the wrong version, but people long PHP7 can "explicitly" say they want the new version. Sorry if it's taken a long time for me to see this thread, you're all welcome to ping me on twitter to get my attention: https://twitter.com/dr4goonis Cheers, viva la PHP. |
In my opinion, whoever is doing So yes, that's the only pitfall in declaring the new version as 1.1 with PHP ^7.0; but doing otherwise (like releasing as 2.0) would create a huge rift in the community, requiring a lot of distributed effort in implementing libraries to make all cross compatible again, which would put us back to breaking projects again when you do |
👍 from me on this and other 7/7.1 changes to bring the PSR forward. But I won't have time to do any merging or further work here, if someone else does please do. |
@Seldaek I'll hold the fort :) |
@Jean85 I'm happy with this approach as long as it's a safe upgrade, and users don't need special flags in their composer.json files or on the composer CLI.
|
It's not the specified project that will lock onto the right version, but the version of PHP in use during So, if you have PHP 7+, you'll get the new version. If you do not, you'll get the old one. As I said in a previous comment (#13 (comment)), if something breaks, at that point it's the user's fault. PS: just a small reminder, we need to pass this through the bylaw procedure (#13 (comment)), so it would make sense to group all the meaningful PRs here and do a single vote and release. |
@Jean85 reach out to me on the PHPFIG slack for a conversation on the approach forward? Thanks |
so... its 2021. Can this be merged yet? |
PSR-6 received a similar upgrade just last month, see:
@dragoonis you can look at how that was done (and how we're doing it for PSR-11) as an example; we should talk about this on the new PHP-FIG Discord: https://discord.gg/php-fig |
Extends CacheException with \Throwable interface.
With PHP 5 backward compatibility.
A do an error on pull request : #12 ; sorry ;)