On Thu, 22 Jul 2004 11:26:44 +0100, Marcus Bointon
<[EMAIL PROTECTED]> wrote:
> on 22/7/04 10:49, Jason Barnett at [EMAIL PROTECTED] wrote:
> 
> > The easiest way I can think of to prevent static method calls is to use the
> > $this pseudo variable in your method.  A method *cannot* be used statically if
> > the method requires use of $this.
> 
> Unfortunately that doesn't work - it is exactly the case that fails in my
> example. $this IS set in a static method that's called from any object
> instance (even one of a different class), and it's a PHP feature, not a bug.
> 

If $this is set, check to see if it's of the type of the class the
static method is in. If it is, then it's not a static call.

This can be confusing because you can call methods in the current
class with the same syntax as static calls.

class A {
  function b() {

  }

  function c() {
    //this is not a static call as it's in the current class
    A::b();
  }
}

class B {
  function c() {
    //also not a static call, just forcing use of the A's c
    A::c():
  }
}

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to