diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index cca69985a0dfe..0fc76e2fe9518 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -724,6 +724,8 @@ static HashTable *zend_closure_get_gc(zend_object *obj, zval **table, int *n) /* /* {{{ Private constructor preventing instantiation */ ZEND_COLD ZEND_METHOD(Closure, __construct) { + ZEND_PARSE_PARAMETERS_NONE(); + zend_throw_error(NULL, "Instantiation of class Closure is not allowed"); } /* }}} */ diff --git a/Zend/zend_fibers.c b/Zend/zend_fibers.c index d571a622e476b..56ea5060acf5a 100644 --- a/Zend/zend_fibers.c +++ b/Zend/zend_fibers.c @@ -1099,6 +1099,8 @@ ZEND_METHOD(Fiber, getCurrent) ZEND_METHOD(FiberError, __construct) { + ZEND_PARSE_PARAMETERS_NONE(); + zend_throw_error( NULL, "The \"%s\" class is reserved for internal use and cannot be manually instantiated", diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index 404dd9db893ea..1f7728a43eacf 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -550,6 +550,8 @@ static zend_result zend_internal_iterator_ensure_rewound(zend_internal_iterator ZEND_METHOD(InternalIterator, __construct) { + ZEND_PARSE_PARAMETERS_NONE(); + zend_throw_error(NULL, "Cannot manually construct InternalIterator"); } diff --git a/Zend/zend_weakrefs.c b/Zend/zend_weakrefs.c index 8c1263885bf6c..8bd9e8355b4d2 100644 --- a/Zend/zend_weakrefs.c +++ b/Zend/zend_weakrefs.c @@ -312,6 +312,8 @@ static HashTable *zend_weakref_get_debug_info(zend_object *object, int *is_temp) ZEND_COLD ZEND_METHOD(WeakReference, __construct) { + ZEND_PARSE_PARAMETERS_NONE(); + zend_throw_error(NULL, "Direct instantiation of WeakReference is not allowed, use WeakReference::create instead"); } diff --git a/ext/dom/node.c b/ext/dom/node.c index 19b6c2eeae3b9..9b590085ce5df 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -2741,6 +2741,8 @@ PHP_METHOD(Dom_Node, compareDocumentPosition) PHP_METHOD(Dom_Node, __construct) { + ZEND_PARSE_PARAMETERS_NONE(); + zend_throw_error(NULL, "Cannot directly construct %s, use document methods instead", ZSTR_VAL(Z_OBJCE_P(ZEND_THIS)->name)); } diff --git a/ext/hash/hash.c b/ext/hash/hash.c index 8a9494fb62d01..58e9e97be2095 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -1132,6 +1132,8 @@ PHP_FUNCTION(hash_equals) /* {{{ */ PHP_METHOD(HashContext, __construct) { + ZEND_PARSE_PARAMETERS_NONE(); + /* Normally unreachable as private/final */ zend_throw_exception(zend_ce_error, "Illegal call to private/final constructor", 0); } diff --git a/ext/intl/breakiterator/breakiterator_methods.cpp b/ext/intl/breakiterator/breakiterator_methods.cpp index c9791d4b23ae6..740a9b2ceb60f 100644 --- a/ext/intl/breakiterator/breakiterator_methods.cpp +++ b/ext/intl/breakiterator/breakiterator_methods.cpp @@ -36,6 +36,8 @@ using icu::Locale; U_CFUNC PHP_METHOD(IntlBreakIterator, __construct) { + ZEND_PARSE_PARAMETERS_NONE(); + zend_throw_exception( NULL, "An object of this type cannot be created with the new operator", 0 ); diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp index c404286fe0944..43c24f3fd1ffc 100644 --- a/ext/intl/calendar/calendar_methods.cpp +++ b/ext/intl/calendar/calendar_methods.cpp @@ -65,6 +65,8 @@ using icu::Locale; U_CFUNC PHP_METHOD(IntlCalendar, __construct) { + ZEND_PARSE_PARAMETERS_NONE(); + zend_throw_exception( NULL, "An object of this type cannot be created with the new operator", 0 ); diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp index 3de186a9ca031..6a2a1c918c9c1 100644 --- a/ext/intl/timezone/timezone_methods.cpp +++ b/ext/intl/timezone/timezone_methods.cpp @@ -41,6 +41,8 @@ using icu::Calendar; U_CFUNC PHP_METHOD(IntlTimeZone, __construct) { + ZEND_PARSE_PARAMETERS_NONE(); + zend_throw_exception( NULL, "An object of this type cannot be created with the new operator", 0 ); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 587bca11522b2..4f7e6549fd912 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -7274,6 +7274,8 @@ ZEND_METHOD(ReflectionZendExtension, getCopyright) /* {{{ Dummy constructor -- always throws ReflectionExceptions. */ ZEND_METHOD(ReflectionReference, __construct) { + ZEND_PARSE_PARAMETERS_NONE(); + _DO_THROW( "Cannot directly instantiate ReflectionReference. " "Use ReflectionReference::fromArrayElement() instead" @@ -7363,12 +7365,16 @@ ZEND_METHOD(ReflectionReference, getId) ZEND_METHOD(ReflectionAttribute, __construct) { + ZEND_PARSE_PARAMETERS_NONE(); + _DO_THROW("Cannot directly instantiate ReflectionAttribute"); } ZEND_METHOD(ReflectionAttribute, __clone) { /* __clone() is private but this is reachable with reflection */ + ZEND_PARSE_PARAMETERS_NONE(); + _DO_THROW("Cannot clone object using __clone()"); } diff --git a/ext/reflection/tests/ReflectionAttribute_constructor_001.phpt b/ext/reflection/tests/ReflectionAttribute_constructor_001.phpt index ad895dc424377..31b52f7152960 100644 --- a/ext/reflection/tests/ReflectionAttribute_constructor_001.phpt +++ b/ext/reflection/tests/ReflectionAttribute_constructor_001.phpt @@ -16,7 +16,7 @@ $attribute = $rm->getAttributes()[0]; $rm = new ReflectionMethod($attribute, "__construct"); try { - var_dump($rm->invoke($attribute, 0, 1, 2)); + var_dump($rm->invoke($attribute)); } catch (ReflectionException $exception) { echo $exception->getMessage(); } diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 659de2291d86d..53592f225a737 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -2134,6 +2134,8 @@ PHP_METHOD(SQLite3Result, finalize) /* {{{ __constructor for SQLite3Result. */ PHP_METHOD(SQLite3Result, __construct) { + ZEND_PARSE_PARAMETERS_NONE(); + zend_throw_exception(zend_ce_exception, "SQLite3Result cannot be directly instantiated", 0); } /* }}} */ diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 9dcfb733a591f..6fc345978671a 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -1588,6 +1588,8 @@ PHP_METHOD(tidyNode, getNextSibling) /* {{{ __constructor for tidyNode. */ PHP_METHOD(tidyNode, __construct) { + ZEND_PARSE_PARAMETERS_NONE(); + zend_throw_error(NULL, "You should not create a tidyNode manually"); } /* }}} */