#40837 [NEW]: static and non-static functions can't have the same name

From: Date: Fri, 16 Mar 2007 16:44:17 +0000
Subject: #40837 [NEW]: static and non-static functions can't have the same name
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-110440@lists.php.net to get a copy of this message
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)

« previous php.bugs (#110440) next »