Bug #66648 [Opn->Nab]: problem with the definition of a method
| From: | requinix@php.net | Date: | Wed, 05 Feb 2014 19:47:33 +0000 |
| Subject: | Bug #66648 [Opn->Nab]: problem with the definition of a method | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-184170@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66648&edit=1
ID: 66648
Updated by: requinix@php.net
Reported by: Viktorlubchuk at gmail dot com
Summary: problem with the definition of a method
-Status: Open
+Status: Not a bug
Type: Bug
-Package: Compile Failure
+Package: Scripting Engine problem
Operating System: linux mint 16
PHP Version: 5.5.8
Block user comment: N
Private report: N
New Comment:
You can call a non-static method statically - PHP allows that (for the time being) - but it will
issue an E_STRICT. If you don't see the message then you don't have your error_reporting
and/or display_errors settings set to show it.
Strict Standards: Non-static method PHP_SINGLETONE\Example::in() should not be called statically in
... on line 58
Strict Standards: Non-static method PHP_SINGLETONE\Example::doSome() should not be called statically
in ... on line 60
PHP_SINGLETONE\Example1 var1<br>
Strict Standards: Non-static method PHP_SINGLETONE\Example::in() should not be called statically in
... on line 62
Strict Standards: Non-static method PHP_SINGLETONE\Example::doSome() should not be called statically
in ... on line 64
PHP_SINGLETONE\Example2 var2<br>string(1) "6"
6
Previous Comments:
------------------------------------------------------------------------
[2014-02-05 17:22:07] Viktorlubchuk at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=66648&edit=1