#50870 [NEW]: Constructor parameters do not have to match those of superclass constructor
| From: | sjoerd-php at linuxonly dot nl | Date: | Thu, 28 Jan 2010 07:59:57 +0000 |
| Subject: | #50870 [NEW]: Constructor parameters do not have to match those of superclass constructor | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-3792@lists.php.net to get a copy of this message | ||
From: sjoerd-php at linuxonly dot nl
Operating system:
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: Constructor parameters do not have to match those of superclass constructor
Description:
------------
It is unclear when a overloading method should have the same parameters as
its superclass, this could use some documentation.
If you override a method in a subclass, the method needs to have the same
parameters as the superclass. The following will trigger an E_STRICT:
class A {
public function foo(stdClass $a) { }
}
class B extends A {
public function foo($a) { }
}
Strict standards: Declaration of B::foo() should be compatible with that
of A::foo()
This does not apply to the constructor. The __construct special method may
have different parameters. The following will not give a notice:
class A {
public function A(stdClass $a) { }
}
class B extends A {
public function B($a) { }
}
--
Edit bug report at http://bugs.php.net/?id=50870&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50870&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50870&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50870&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=50870&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50870&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=50870&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=50870&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=50870&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=50870&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=50870&r=support
Expected behavior: http://bugs.php.net/fix.php?id=50870&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=50870&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=50870&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=50870&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50870&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50870&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=50870&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=50870&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=50870&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=50870&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=50870&r=mysqlcfg