Skip to content

Commit

Permalink
Fix some misleading comments about __clone() never being executed (#…
Browse files Browse the repository at this point in the history
…15926)

For the `Exception`, `ReflectionClass`, and `ReflectionAttribute` classes, the
`__clone()` method is declared to be private, and the implementation has a
comment that it should never be executed. However, the implementation can be
executed by using a `ReflectionMethod`. Fix the comments to instead explain why
the implementation is needed.

[skip ci]
  • Loading branch information
DanielEScherzer authored Sep 16, 2024
1 parent 2fce0bb commit 65b4f22
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ static zend_object *zend_default_exception_new(zend_class_entry *class_type) /*
/* {{{ Clone the exception object */
ZEND_COLD ZEND_METHOD(Exception, __clone)
{
/* Should never be executable */
/* __clone() is private but this is reachable with reflection */
zend_throw_exception(NULL, "Cannot clone object using __clone()", 0);
}
/* }}} */
Expand Down
4 changes: 2 additions & 2 deletions ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ static int get_parameter_default(zval *result, parameter_reference *param) {
/* {{{ Preventing __clone from being called */
ZEND_METHOD(ReflectionClass, __clone)
{
/* Should never be executable */
/* __clone() is private but this is reachable with reflection */
_DO_THROW("Cannot clone object using __clone()");
}
/* }}} */
Expand Down Expand Up @@ -7183,7 +7183,7 @@ ZEND_METHOD(ReflectionAttribute, __construct)

ZEND_METHOD(ReflectionAttribute, __clone)
{
/* Should never be executable */
/* __clone() is private but this is reachable with reflection */
_DO_THROW("Cannot clone object using __clone()");
}

Expand Down

0 comments on commit 65b4f22

Please sign in to comment.