ID:               43914
 Updated by:       [EMAIL PROTECTED]
 Reported By:      mo at modejong dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: WinXP
 PHP Version:      5.2.5
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

>Use of a method call like CLASS::METHOD inside a class def does
>not mean the method being invoked is static.

Yes, it does.


Previous Comments:
------------------------------------------------------------------------

[2008-01-23 00:34:31] mo at modejong dot com

Description:
------------
PHP allows invocation of an instance method in a class that
is unrelated to the current class. I would think that the
correct thing to do in this case is to generate an error
at runtime when this specific case is detected.

Reproduce code:
---------------
class One {
  function foo() {
    $isnull = ($this == NULL) ? "TRUE" : "FALSE";
    $instanceof = ($this instanceof One) ? "TRUE" : "FALSE";
    print "One::foo is \$this null ($isnull) : is instanceof One
($instanceof)\n";
  }
}

class Two {
  function foo() {
    $isnull = ($this == NULL) ? "TRUE" : "FALSE";
    $instanceof = ($this instanceof Two) ? "TRUE" : "FALSE";
    print "Two::foo is \$this null ($isnull) : is instanceof Two
($instanceof)\n";
    return One::foo();
  }
}

$obj = new Two;
$obj->foo();


Expected result:
----------------
When executed, PHP prints:

Two::foo is $this null (FALSE) : is instanceof Two (TRUE)
One::foo is $this null (FALSE) : is instanceof One (FALSE)

It should generate an error here since Two is unrelated
to class One. This check should be done when invoking
the instance method, if the $this ref is not NULL then
the type of $this should be checked before the instance
method can be invoked in One.

I already read bug 42559, it seems to have been rejected
as "not a bug", but this issue is clearly a bug. Use of
a method call like CLASS::METHOD inside a class def does
not mean the method being invoked is static.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=43914&edit=1

Reply via email to