#40837 [NEW]: static and non-static functions can't have the same name
From: nick dot telford at gmail dot com
Operating system: Irrelevant
PHP version: 5.2.1
PHP Bug Type: Class/Object related
Bug description: static and non-static functions can't have the same name
Description:
------------
When declaring two functions in a class (methods) non-static and static
functions may not use the same names.
While I understand this, this is essentially wrong since static methods
and non-static methods are entirely different.
This also leads me on to another bug/feature suggestion I'm about to file
about not being able to overload static attributes with __set/__get.
Reproduce code:
---------------
class Example {
public static function test() {}
public function test() {}
}
$example = new Example();
$example->test();
Example::test();
Expected result:
----------------
No errors, all methods called correctly.
Actual result:
--------------
PHP errors with: Fatal error: Cannot redeclare Example::test()
--
Edit bug report at http://bugs.php.net/?id=40837&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40837&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40837&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40837&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40837&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=40837&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40837&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40837&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40837&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40837&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40837&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=40837&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=40837&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40837&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40837&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40837&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40837&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40837&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40837&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40837&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40837&r=mysqlcfg
Thread (20 messages)
- nick dot telford at gmail dot com
- helly@php.net#40837 [Opn->Bgs]: static and non-static functions can't have the same name
- martijntje at martijnotto dot nlBug #40837 [Com]: static and non-static functions can't have the same name
- mac at macnewbold dot comBug #40837 [Com]: static and non-static functions can't have the same name
- info at renemaas dot deBug #40837 [Com]: static and non-static functions can't have the same name
- billco at fnarg dot comBug #40837 [Com]: static and non-static functions can't have the same name
- accounts dot php at nickawilliams dot comBug #40837 [Com]: static and non-static functions can't have the same name
- aharvey@php.netBug #40837 [Nab]: static and non-static functions can't have the same name
- mac at macnewbold dot comBug #40837 [Com]: static and non-static functions can't have the same name
- aharvey@php.netBug #40837 [Nab]: static and non-static functions can't have the same name
- jpmarois at hotmail dot comBug #40837 [Com]: static and non-static functions can't have the same name
- aharvey@php.netBug #40837 [Nab]: static and non-static functions can't have the same name
- capitaine dot gloumi at gmail dot comBug #40837 [Com]: static and non-static functions can't have the same name
- dmittner at llnw dot comBug #40837 [Com]: static and non-static functions can't have the same name
- nikic@php.netBug #40837 [Com]: static and non-static functions can't have the same name
- dmittner at llnw dot comBug #40837 [Com]: static and non-static functions can't have the same name
- billco at fnarg dot comBug #40837 [Com]: static and non-static functions can't have the same name
- nikic@php.netBug #40837 [Com]: static and non-static functions can't have the same name
- dmittner at llnw dot comBug #40837 [Com]: static and non-static functions can't have the same name
- ed at over-yonder dot comBug #40837 [Com]: static and non-static functions can't have the same name