mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Deprecate PHP 4 constructors
This commit is contained in:
parent
d252c9f832
commit
db76b708cf
110 changed files with 219 additions and 191 deletions
|
@ -23,6 +23,7 @@
|
|||
#include "zend_execute.h"
|
||||
#include "zend_inheritance.h"
|
||||
#include "zend_smart_str.h"
|
||||
#include "zend_inheritance.h"
|
||||
|
||||
static void ptr_dtor(zval *zv) /* {{{ */
|
||||
{
|
||||
|
@ -1596,6 +1597,9 @@ ZEND_API void zend_do_bind_traits(zend_class_entry *ce) /* {{{ */
|
|||
/* verify that all abstract methods from traits have been implemented */
|
||||
zend_verify_abstract_class(ce);
|
||||
|
||||
/* Emit E_DEPRECATED for PHP 4 constructors */
|
||||
zend_check_deprecated_constructor(ce);
|
||||
|
||||
/* now everything should be fine and an added ZEND_ACC_IMPLICIT_ABSTRACT_CLASS should be removed */
|
||||
if (ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) {
|
||||
ce->ce_flags -= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS;
|
||||
|
@ -1603,6 +1607,29 @@ ZEND_API void zend_do_bind_traits(zend_class_entry *ce) /* {{{ */
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
static zend_bool zend_has_deprecated_constructor(const zend_class_entry *ce) /* {{{ */
|
||||
{
|
||||
const zend_string *constructor_name;
|
||||
if (!ce->constructor) {
|
||||
return 0;
|
||||
}
|
||||
constructor_name = ce->constructor->common.function_name;
|
||||
return !zend_binary_strcasecmp(
|
||||
ce->name->val, ce->name->len,
|
||||
constructor_name->val, constructor_name->len
|
||||
);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void zend_check_deprecated_constructor(const zend_class_entry *ce) /* {{{ */
|
||||
{
|
||||
if (zend_has_deprecated_constructor(ce)) {
|
||||
zend_error(E_DEPRECATED, "Methods with the same name as their class will not be constructors in a future version of PHP; %s has a deprecated constructor", ce->name->val);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue