From:             j dot boggiano at seld dot be
Operating system: Windows/Linux
PHP version:      6CVS-2008-02-04 (snap)
PHP Bug Type:     Class/Object related
Bug description:  Enforcing a method without specifying the arguments

Description:
------------
The purpose of this is to allow an abstract class or an interface to
enforce the implementation of a method, without however enforcing the
arguments signature.

This is -as I understand it- not a bug, but a feature request.

Reproduce code:
---------------
/***
 * This works in PHP5 but does not anymore in PHP6
 */
class Parnt {
        public function foo() {}
}
class Child extends Parnt {
        public function foo($arg){}
}

/***
 * Those don't work in either 5 or 6
 */
abstract class Abst {
        abstract public function foo();
}
class Child2 extends Abst {
        public function foo($arg){}
}

interface Int {
        public function foo();
}
class Child3 implements Int {
        public function foo($arg){}
}

Expected result:
----------------
/***
 * Proposal for a solution
 */
abstract class AbstFixed {
        abstract public function foo;
}
class Child4 extends AbstFixed {
        public function foo($arg){}
}

// => Declaring the method without parenthesis (which currently throws a
parse error) would allow the implementations of this method to use any
argument signature they please.

Actual result:
--------------
At the moment those three examples throw a fatal error in PHP6 with :
Declaration of Child::foo() must be compatible with that of Parnt::foo()

I don't think it is a bug, but I think having the capability to allow
variable function signatures would definitely be a plus, especially with
PHP6 coming that prevents the first example to work.

-- 
Edit bug report at http://bugs.php.net/?id=44043&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=44043&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44043&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44043&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44043&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44043&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44043&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44043&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44043&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44043&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44043&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44043&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44043&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44043&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44043&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=44043&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=44043&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44043&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44043&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44043&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44043&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44043&r=mysqlcfg

Reply via email to