-
Notifications
You must be signed in to change notification settings - Fork 7.9k
IMAP: Resource object constructor and stub #6534
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
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.
Thank you for this :D
Could you add a separate test checking that one cannot extend the class?
ext/imap/tests/imap_constructor.phpt
Outdated
<?php | ||
require_once __DIR__ . '/setup/skipif.inc'; |
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.
Just a nitpick but this test doesn't need to check for the presence of a mailbox, so could you change this to
<?php | |
require_once __DIR__ . '/setup/skipif.inc'; | |
<?php | |
extension_loaded('imap') or die('skip imap extension not available in this build'); |
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.
Thank you, I just force-pushed an updated commit with this test simplified like you suggested.
Disallows constructing an `IMAPConnection` class directly with `new IMAPConnection` construct, by throwing an `Error` exception if attempted. `imap_open` is still the only way to create `IMAPConnection` objects.
Updates the `IMAPConnection` class stub to make sure it has the `final` flag, and adds a test to verify it.
3889cf8
to
adb338e
Compare
Thanks a lot for the review @Girgias. I update both commits and force-pushed with updated test for constructor check, and a new test for a Thank you. |
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.
LGTM, will wait for CI to clear before merging. :)
Thanks a lot @Girgias 🙏🏼 |
This is similar to #6533 (
FTPConnection
), but forIMAPConnection
resource class.As of now, direct construction of
IMAPConnection
class is allowed, and I think it was meant to be disallowed just like other new resource objects. In this PR:new IMAPConnection
constructor with\Error
exceptionCannot directly construct IMAPConnection, use imap_open() instead
.IMAPConnection
withfinal
flag.Thank you.