From: som dot guha at yahoo dot com Operating system: linux PHP version: 5.2.6 PHP Bug Type: Class/Object related Bug description: PHP Scope resolution operator
Description: ------------ I am using php 5.2.5 version. I was testing the functionality of the scope resolution operator. In php.net site it stated that "The Scope Resolution Operator (also called Paamayim Nekudotayim) or in simpler terms, the double colon, is a token that allows access to static, constant, and overridden members or methods of a class.". Now if you check my following code: class MyClass{ public function showMyName(){ echo "My Name"; } } >From the above code, I am able to access the showMyName() method without creating any object, with the help of scope resolution operator, like: MyClass::showMyName(); If you check my code you can see that I have never declared the method as a static method. Show how I am able to access that method with the scope resolution operator. I think this is violating the OOPs rule. Reproduce code: --------------- class MyClass{ public function showMyName(){ echo "My Name"; } } MyClass::showMyName(); Expected result: ---------------- Should generate an error. Actual result: -------------- My Name -- Edit bug report at http://bugs.php.net/?id=44944&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44944&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44944&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44944&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44944&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44944&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44944&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44944&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44944&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44944&r=support Expected behavior: http://bugs.php.net/fix.php?id=44944&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44944&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44944&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44944&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44944&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44944&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44944&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44944&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44944&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44944&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44944&r=mysqlcfg