hi,
Did we not discuss this problem recently? If I'm not mistaken the
decision was to do not change the way constructors work in 5.x.
Cheers,
2010/6/28 Johannes Schlüter johannes@schlueters.de:
Hi,
felipe Sat, 26 Jun 2010 22:05:13 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=300770
Log:
- Fixed bug #51421 (Abstract __construct constructor argument list not enforced)
Bug: http://bugs.php.net/51421 (Closed) Abstract __construct constructor argument list not enforced
Won't this break compatibility?
I'd say the change is logically correct but not sure we should break BC
there during RC.johannes
Changed paths:
A php/php-src/branches/PHP_5_2/Zend/tests/bug51421.phpt
U php/php-src/branches/PHP_5_2/Zend/zend_compile.c
A php/php-src/branches/PHP_5_3/Zend/tests/bug51421.phpt
U php/php-src/branches/PHP_5_3/Zend/zend_compile.c
A php/php-src/trunk/Zend/tests/bug51421.phpt
U php/php-src/trunk/Zend/zend_compile.cAdded: php/php-src/branches/PHP_5_2/Zend/tests/bug51421.phpt
--- php/php-src/branches/PHP_5_2/Zend/tests/bug51421.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/Zend/tests/bug51421.phpt 2010-06-26 22:05:13 UTC (rev 300770)
@@ -0,0 +1,18 @@
+--TEST--
+Bug #51421 (Abstract __construct constructor argument list not enforced)
+--FILE--
+<?php
+class ExampleClass {}
+abstract class TestInterface {
- abstract public function __construct(ExampleClass $var);
+}+class Test extends TestInterface {
- public function __construct() {}
+}+?>
+--EXPECTF--
+Fatal error: Declaration of Test::__construct() must be compatible with that of TestInterface::__construct() in %s on line %dProperty changes on: php/php-src/branches/PHP_5_2/Zend/tests/bug51421.phpt
Added: svn:keywords
+ Id Rev Revision
Added: svn:eol-style
+ nativeModified: php/php-src/branches/PHP_5_2/Zend/zend_compile.c
--- php/php-src/branches/PHP_5_2/Zend/zend_compile.c 2010-06-26 21:29:56 UTC (rev 300769)
+++ php/php-src/branches/PHP_5_2/Zend/zend_compile.c 2010-06-26 22:05:13 UTC (rev 300770)
@@ -2009,13 +2009,20 @@
{
zend_uint i;
- /* If it's a user function then arg_info ==
NULL
means we don't have any parameters but we still need to do the arg number checks. We are only willing to ignore this for internal functions because extensions don't always define arg_info. */
- /* If it's a user function then arg_info ==
NULL
means we don't have any parameters but- * we still need to do the arg number checks. We are only willing to ignore this for internal
- * functions because extensions don't always define arg_info.
- */
if (!proto || (!proto->common.arg_info && proto->common.type != ZEND_USER_FUNCTION)) {
return 1;
}
- /* Checks for constructors only if they are declared in an interface */
- if ((fe->common.fn_flags & ZEND_ACC_CTOR) && !(proto->common.scope->ce_flags & ZEND_ACC_INTERFACE)) {
- /* Checks for constructors only if they are declared in an interface,
- * or explicitly marked as abstract
- */
- if ((fe->common.fn_flags & ZEND_ACC_CTOR)
- && ((proto->common.scope->ce_flags & ZEND_ACC_INTERFACE) == 0
- && (proto->common.fn_flags & ZEND_ACC_ABSTRACT) == 0)) {
return 1;
}Added: php/php-src/branches/PHP_5_3/Zend/tests/bug51421.phpt
--- php/php-src/branches/PHP_5_3/Zend/tests/bug51421.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/Zend/tests/bug51421.phpt 2010-06-26 22:05:13 UTC (rev 300770)
@@ -0,0 +1,18 @@
+--TEST--
+Bug #51421 (Abstract __construct constructor argument list not enforced)
+--FILE--
+<?php
+class ExampleClass {}
+abstract class TestInterface {
- abstract public function __construct(ExampleClass $var);
+}+class Test extends TestInterface {
- public function __construct() {}
+}+?>
+--EXPECTF--
+Fatal error: Declaration of Test::__construct() must be compatible with that of TestInterface::__construct() in %s on line %dProperty changes on: php/php-src/branches/PHP_5_3/Zend/tests/bug51421.phpt
Added: svn:keywords
+ Id Rev Revision
Added: svn:eol-style
+ nativeModified: php/php-src/branches/PHP_5_3/Zend/zend_compile.c
--- php/php-src/branches/PHP_5_3/Zend/zend_compile.c 2010-06-26 21:29:56 UTC (rev 300769)
+++ php/php-src/branches/PHP_5_3/Zend/zend_compile.c 2010-06-26 22:05:13 UTC (rev 300770)
@@ -2532,13 +2532,20 @@
{
zend_uint i;
- /* If it's a user function then arg_info ==
NULL
means we don't have any parameters but we still need to do the arg number checks. We are only willing to ignore this for internal functions because extensions don't always define arg_info. */
- /* If it's a user function then arg_info ==
NULL
means we don't have any parameters but- * we still need to do the arg number checks. We are only willing to ignore this for internal
- * functions because extensions don't always define arg_info.
- */
if (!proto || (!proto->common.arg_info && proto->common.type != ZEND_USER_FUNCTION)) {
return 1;
}
- /* Checks for constructors only if they are declared in an interface */
- if ((fe->common.fn_flags & ZEND_ACC_CTOR) && !(proto->common.scope->ce_flags & ZEND_ACC_INTERFACE)) {
- /* Checks for constructors only if they are declared in an interface,
- * or explicitly marked as abstract
- */
- if ((fe->common.fn_flags & ZEND_ACC_CTOR)
- && ((proto->common.scope->ce_flags & ZEND_ACC_INTERFACE) == 0
- && (proto->common.fn_flags & ZEND_ACC_ABSTRACT) == 0)) {
return 1;
}Added: php/php-src/trunk/Zend/tests/bug51421.phpt
--- php/php-src/trunk/Zend/tests/bug51421.phpt (rev 0)
+++ php/php-src/trunk/Zend/tests/bug51421.phpt 2010-06-26 22:05:13 UTC (rev 300770)
@@ -0,0 +1,18 @@
+--TEST--
+Bug #51421 (Abstract __construct constructor argument list not enforced)
+--FILE--
+<?php
+class ExampleClass {}
+abstract class TestInterface {
- abstract public function __construct(ExampleClass $var);
+}+class Test extends TestInterface {
- public function __construct() {}
+}+?>
+--EXPECTF--
+Fatal error: Declaration of Test::__construct() must be compatible with that of TestInterface::__construct() in %s on line %dProperty changes on: php/php-src/trunk/Zend/tests/bug51421.phpt
Added: svn:keywords
+ Id Rev Revision
Added: svn:eol-style
+ nativeModified: php/php-src/trunk/Zend/zend_compile.c
--- php/php-src/trunk/Zend/zend_compile.c 2010-06-26 21:29:56 UTC (rev 300769)
+++ php/php-src/trunk/Zend/zend_compile.c 2010-06-26 22:05:13 UTC (rev 300770)
@@ -2909,13 +2909,20 @@
{
zend_uint i;
- /* If it's a user function then arg_info ==
NULL
means we don't have any parameters but we still need to do the arg number checks. We are only willing to ignore this for internal functions because extensions don't always define arg_info. */
- /* If it's a user function then arg_info ==
NULL
means we don't have any parameters but- * we still need to do the arg number checks. We are only willing to ignore this for internal
- * functions because extensions don't always define arg_info.
- */
if (!proto || (!proto->common.arg_info && proto->common.type != ZEND_USER_FUNCTION)) {
return 1;
}
- /* Checks for constructors only if they are declared in an interface */
- if ((fe->common.fn_flags & ZEND_ACC_CTOR) && !(proto->common.scope->ce_flags & ZEND_ACC_INTERFACE)) {
- /* Checks for constructors only if they are declared in an interface,
- * or explicitly marked as abstract
- */
- if ((fe->common.fn_flags & ZEND_ACC_CTOR)
- && ((proto->common.scope->ce_flags & ZEND_ACC_INTERFACE) == 0
- && (proto->common.fn_flags & ZEND_ACC_ABSTRACT) == 0)) {
return 1;
}--
PHP CVS Mailing List (http://www.php.net/)--
--
Pierre
@pierrejoye | http://blog.thepimp.net | http://www.libgd.org
2010/6/28 Johannes Schlüter johannes@schlueters.de:
Log:
- Fixed bug #51421 (Abstract __construct constructor argument
list not enforced)Bug: http://bugs.php.net/51421 (Closed) Abstract __construct
constructor argument list not enforcedWon't this break compatibility?
I'd say the change is logically correct but not sure we should break BC
there during RC.Did we not discuss this problem recently? If I'm not mistaken the
decision was to do not change the way constructors work in 5.x.
That's what I seem to remember as well.
Derick
--
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug