diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 1d909d60654a7..399b7a516576b 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -170,6 +170,11 @@ static zend_object* imap_object_create(zend_class_entry* ce) { return zobj; } +static zend_function *imap_object_get_constructor(zend_object *zobj) { + zend_throw_error(NULL, "Cannot directly construct IMAPConnection, use imap_open() instead"); + return NULL; +} + static void imap_object_destroy(zend_object *zobj) { php_imap_object *obj = imap_object_from_zend_object(zobj); @@ -483,6 +488,7 @@ PHP_MINIT_FUNCTION(imap) memcpy(&imap_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); imap_object_handlers.offset = XtOffsetOf(php_imap_object, std); + imap_object_handlers.get_constructor = imap_object_get_constructor; imap_object_handlers.dtor_obj = imap_object_destroy; imap_object_handlers.clone_obj = NULL; diff --git a/ext/imap/php_imap.stub.php b/ext/imap/php_imap.stub.php index 0c597badecf98..580c79cc9bc1e 100644 --- a/ext/imap/php_imap.stub.php +++ b/ext/imap/php_imap.stub.php @@ -1,7 +1,7 @@ getMessage(), "\n"; +} +--EXPECT-- +Exception: Cannot directly construct IMAPConnection, use imap_open() instead diff --git a/ext/imap/tests/imap_final.phpt b/ext/imap/tests/imap_final.phpt new file mode 100644 index 0000000000000..a896b4e6c4e8f --- /dev/null +++ b/ext/imap/tests/imap_final.phpt @@ -0,0 +1,11 @@ +--TEST-- +Check that IMAPConnection is declared final +--SKIPIF-- +