#27304 [NEW]: ZE2 Static functions don't function properly

From: Date: Wed, 18 Feb 2004 07:44:44 +0000
Subject: #27304 [NEW]: ZE2 Static functions don't function properly
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-55128@lists.php.net to get a copy of this message
From:             john@php.net
Operating system: RH8
PHP version:      5CVS-2004-02-18 (dev)
PHP Bug Type:     Zend Engine 2 problem
Bug description:  ZE2 Static functions don't function properly

Description:
------------
Static functions don't behave properly at all. They can be called from an
object-context and provide no means to even confirm from within the
function if it has been called from a static context or not.

I understand that static methods should never have access to $this
regardless of context, but unless the engine enforces a restriction on
calling static functions from an object context this behavior is
completely counter-intuitive and inconsistent. Not only does the engine
not catch this, but the developer cannot either.



Reproduce code:
---------------
<?php
        error_reporting(E_ALL);
        class Staticexample {
                const a = 10;

                static function test() {
                        
                        var_dump(isset($this));

                }

                
        }
       
        $b = new Staticexample();
        Staticexample::test();
        $b->test();
        
?>

Expected result:
----------------
bool(false)
bool(true)


Actual result:
--------------
bool(false)
bool(false)

-- 
Edit bug report at http://bugs.php.net/?id=27304&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27304&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27304&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27304&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27304&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27304&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27304&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27304&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27304&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27304&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27304&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27304&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27304&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27304&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27304&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27304&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27304&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27304&r=float


Thread (2 messages)

« previous php.bugs (#55128) next »