Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Zend/zend_closures.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
/* }}} */
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_fibers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_interfaces.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_weakrefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
2 changes: 2 additions & 0 deletions ext/dom/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
2 changes: 2 additions & 0 deletions ext/hash/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions ext/intl/breakiterator/breakiterator_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 2 additions & 0 deletions ext/intl/calendar/calendar_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 2 additions & 0 deletions ext/intl/timezone/timezone_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
6 changes: 6 additions & 0 deletions ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions ext/sqlite3/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
/* }}} */
Expand Down
2 changes: 2 additions & 0 deletions ext/tidy/tidy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
/* }}} */
Expand Down
Loading