Bug #66648 [NEW]: problem with the definition of a method
| From: | Viktorlubchuk at gmail dot com | Date: | Wed, 05 Feb 2014 17:22:08 +0000 |
| Subject: | Bug #66648 [NEW]: problem with the definition of a method | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-184168@lists.php.net to get a copy of this message | ||
From: Viktorlubchuk at gmail dot com
Operating system: linux mint 16
PHP version: 5.5.8
Package: Compile Failure
Bug Type: Bug
Bug description:problem with the definition of a method
Description:
------------
the is bug is that I appeal to the public methods as static and it
works
i try it on php versions 5.4 , 5.3 and its outputting error as it should
be
<?php
namespace PHP_SINGLETONE;
abstract class Example
{
public static $counter = null;
protected $num;
public function __construct()
{
}
public function in()
{
$class = get_called_class();
if ($class::$counter === null) {
$class::$counter = new $class();
}
return $class::$counter;
}
public function doSome($string)
{
echo get_called_class(). " ".$string."<br>";
}
public function showNum($number)
{
$this->num = $number;
return $this->num;
}
}
class Example1 extends Example
{
public static $counter = null;
}
class Example2 extends Example
{
public static $counter = null;
}
$var = Example1::in();
$var::doSome('var1');
$var1 = Example2::in();
$var1::doSome('var2');
var_dump($a = $var1->showNum("6"));
echo $a;
Expected result:
----------------
i`m expecting to error that say - I can not appeal to the public methods
as static
--
Edit bug report at https://bugs.php.net/bug.php?id=66648&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66648&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66648&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66648&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66648&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66648&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66648&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66648&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66648&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66648&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66648&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66648&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66648&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66648&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66648&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66648&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66648&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66648&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66648&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66648&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66648&r=mysqlcfg