-
Notifications
You must be signed in to change notification settings - Fork 8k
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
Girgias
left a comment
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. |
Girgias
left a comment
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 forIMAPConnectionresource class.As of now, direct construction of
IMAPConnectionclass is allowed, and I think it was meant to be disallowed just like other new resource objects. In this PR:new IMAPConnectionconstructor with\ErrorexceptionCannot directly construct IMAPConnection, use imap_open() instead.IMAPConnectionwithfinalflag.Thank you.