cvs: ZendEngine2 / zend_API.c zend_compile.c zend_compile.h zend_execute.c zend_execute_API.c php-src/tests/lang bug23384.phpt
| From: | Marcus Boerger | Date: | Sat, 24 Jan 2004 16:59:24 +0000 |
| Subject: | cvs: ZendEngine2 / zend_API.c zend_compile.c zend_compile.h zend_execute.c zend_execute_API.c php-src/tests/lang bug23384.phpt | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-2252@lists.php.net to get a copy of this message | ||
helly Sat Jan 24 11:59:24 2004 EDT
Modified files:
/php-src/tests/lang bug23384.phpt
/ZendEngine2 zend_API.c zend_compile.c zend_compile.h
zend_execute.c zend_execute_API.c
Log:
Switch from ZEND_ACC_DYNAMIC to ZEND_ACC_ALLOW_STATIC and disallow calling
internal non-static methods statically.
# As discussed with Zeev:
# - For BC standard userspace methods allow this with an E_STRICT message.
# - If you want to implement an internal method taht can be called both
# statically and non-statically then use flag ZEND_ACC_ALLOW_STATIC.
# - Magic user space methods __*() cannot and __construct, __destruct,
# __clone can never be called statically.
http://cvs.php.net/diff.php/php-src/tests/lang/bug23384.phpt?r1=1.1&r2=1.2&ty=u
Index: php-src/tests/lang/bug23384.phpt
diff -u php-src/tests/lang/bug23384.phpt:1.1 php-src/tests/lang/bug23384.phpt:1.2
--- php-src/tests/lang/bug23384.phpt:1.1 Mon Jun 16 05:20:42 2003
+++ php-src/tests/lang/bug23384.phpt Sat Jan 24 11:59:23 2004
@@ -1,5 +1,7 @@
--TEST--
Bug #23384 (use of class constants in statics)
+--INI--
+error_reporting=4095
--FILE--
<?php
define('TEN', 10);
@@ -18,7 +20,8 @@
Foo::test();
echo Foo::HUN."\n";
?>
---EXPECT--
+--EXPECTF--
+Strict Standards: Non-static method Foo::test() cannot be called statically in %sbug23384.php on
line %d
Array
(
[100] => ten
http://cvs.php.net/diff.php/ZendEngine2/zend_API.c?r1=1.237&r2=1.238&ty=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.237 ZendEngine2/zend_API.c:1.238
--- ZendEngine2/zend_API.c:1.237 Fri Jan 23 17:04:42 2004
+++ ZendEngine2/zend_API.c Sat Jan 24 11:59:23 2004
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.237 2004/01/23 22:04:42 helly Exp $ */
+/* $Id: zend_API.c,v 1.238 2004/01/24 16:59:23 helly Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -1293,22 +1293,25 @@
scope->destructor = dtor;
scope->clone = clone;
if (ctor) {
- ctor->common.fn_flags |= ZEND_ACC_CTOR|ZEND_ACC_DYNAMIC;
+ ctor->common.fn_flags |= ZEND_ACC_CTOR;
if (ctor->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Constructor %s::%s cannot be static",
ctor->common.scope->name, ctor->common.function_name);
}
+ ctor->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (dtor) {
- dtor->common.fn_flags |= ZEND_ACC_DTOR|ZEND_ACC_DYNAMIC;
+ dtor->common.fn_flags |= ZEND_ACC_DTOR;
if (dtor->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Destructor %s::%s cannot be static",
dtor->common.scope->name, dtor->common.function_name);
}
+ dtor->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (clone) {
- clone->common.fn_flags |= ZEND_ACC_CLONE|ZEND_ACC_DYNAMIC;
+ clone->common.fn_flags |= ZEND_ACC_CLONE;
if (clone->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Constructor %s::%s cannot be static",
clone->common.scope->name, clone->common.function_name);
}
+ clone->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
}
return SUCCESS;
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.517&r2=1.518&ty=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.517 ZendEngine2/zend_compile.c:1.518
--- ZendEngine2/zend_compile.c:1.517 Fri Jan 23 17:04:42 2004
+++ ZendEngine2/zend_compile.c Sat Jan 24 11:59:24 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.517 2004/01/23 22:04:42 helly Exp $ */
+/* $Id: zend_compile.c,v 1.518 2004/01/24 16:59:24 helly Exp $ */
#include "zend_language_parser.h"
#include "zend.h"
@@ -1043,6 +1043,8 @@
CG(active_class_entry)->__get = (zend_function *) CG(active_op_array);
} else if ((name_len == sizeof(ZEND_SET_FUNC_NAME)-1) && (!memcmp(lcname,
ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME)))) {
CG(active_class_entry)->__set = (zend_function *) CG(active_op_array);
+ } else if (!(fn_flags & ZEND_ACC_STATIC)) {
+ CG(active_op_array)->fn_flags |= ZEND_ACC_ALLOW_STATIC;
}
free_alloca(short_class_name);
@@ -2389,19 +2391,19 @@
do_inherit_parent_constructor(ce);
if (ce->constructor) {
- ce->constructor->common.fn_flags |= ZEND_ACC_CTOR|ZEND_ACC_DYNAMIC;
+ ce->constructor->common.fn_flags |= ZEND_ACC_CTOR;
if (ce->constructor->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(E_COMPILE_ERROR, "Constructor %s::%s() cannot be static", ce->name,
ce->constructor->common.function_name);
}
}
if (ce->destructor) {
- ce->destructor->common.fn_flags |= ZEND_ACC_DTOR|ZEND_ACC_DYNAMIC;
+ ce->destructor->common.fn_flags |= ZEND_ACC_DTOR;
if (ce->destructor->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(E_COMPILE_ERROR, "Destructor %s::%s() cannot be static", ce->name,
ce->destructor->common.function_name);
}
}
if (ce->clone) {
- ce->clone->common.fn_flags |= ZEND_ACC_CLONE|ZEND_ACC_DYNAMIC;
+ ce->clone->common.fn_flags |= ZEND_ACC_CLONE;
if (ce->clone->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(E_COMPILE_ERROR, "Clone method %s::%s() cannot be static", ce->name,
ce->clone->common.function_name);
}
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.269&r2=1.270&ty=u
Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.269 ZendEngine2/zend_compile.h:1.270
--- ZendEngine2/zend_compile.h:1.269 Fri Jan 23 17:04:42 2004
+++ ZendEngine2/zend_compile.h Sat Jan 24 11:59:24 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.h,v 1.269 2004/01/23 22:04:42 helly Exp $ */
+/* $Id: zend_compile.h,v 1.270 2004/01/24 16:59:24 helly Exp $ */
#ifndef ZEND_COMPILE_H
#define ZEND_COMPILE_H
@@ -101,7 +101,7 @@
#define ZEND_ACC_ABSTRACT_CLASS 0x10
#define ZEND_ACC_FINAL_CLASS 0x20
-#define ZEND_ACC_DYNAMIC 0x80
+#define ZEND_ACC_ALLOW_STATIC 0x80
/* The order of those must be kept - public < protected < private */
#define ZEND_ACC_PUBLIC 0x100
http://cvs.php.net/diff.php/ZendEngine2/zend_execute.c?r1=1.587&r2=1.588&ty=u
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.587 ZendEngine2/zend_execute.c:1.588
--- ZendEngine2/zend_execute.c:1.587 Fri Jan 23 23:59:47 2004
+++ ZendEngine2/zend_execute.c Sat Jan 24 11:59:24 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.587 2004/01/24 04:59:47 sebastian Exp $ */
+/* $Id: zend_execute.c,v 1.588 2004/01/24 16:59:24 helly Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -2520,10 +2520,10 @@
if (EX(function_state).function->common.scope) {
if (!EG(This) && !(EX(function_state).function->common.fn_flags &
ZEND_ACC_STATIC)) {
int severity;
- if (EX(function_state).function->common.fn_flags & ZEND_ACC_DYNAMIC) {
- severity = E_ERROR;
- } else {
+ if (EX(function_state).function->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
severity = E_STRICT;
+ } else {
+ severity = E_ERROR;
}
zend_error(severity, "Non-static method %s::%s() cannot be called statically",
EX(function_state).function->common.scope->name,
EX(function_state).function->common.function_name);
}
http://cvs.php.net/diff.php/ZendEngine2/zend_execute_API.c?r1=1.254&r2=1.255&ty=u
Index: ZendEngine2/zend_execute_API.c
diff -u ZendEngine2/zend_execute_API.c:1.254 ZendEngine2/zend_execute_API.c:1.255
--- ZendEngine2/zend_execute_API.c:1.254 Fri Jan 23 23:59:47 2004
+++ ZendEngine2/zend_execute_API.c Sat Jan 24 11:59:24 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute_API.c,v 1.254 2004/01/24 04:59:47 sebastian Exp $ */
+/* $Id: zend_execute_API.c,v 1.255 2004/01/24 16:59:24 helly Exp $ */
#include <stdio.h>
#include <signal.h>
@@ -718,10 +718,10 @@
EG(This) = NULL;
if (calling_scope && !(EX(function_state).function->common.fn_flags &
ZEND_ACC_STATIC)) {
int severity;
- if (EX(function_state).function->common.fn_flags & ZEND_ACC_DYNAMIC) {
- severity = E_ERROR;
- } else {
+ if (EX(function_state).function->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
severity = E_STRICT;
+ } else {
+ severity = E_ERROR;
}
zend_error(E_STRICT, "Non-static method %s::%s() cannot be called statically",
calling_scope->name, EX(function_state).function->common.function_name);
}