[nycphp-talk] Static variables, self:: and abstract classes

Andrew Kamm akamm at
Tue Jun 6 11:08:20 EDT 2006

> Actually, I'm getting:
> Fatal error:  Cannot redeclare property static protected
> ParentClass::$myVar in class ChildClass
> for your example.

Yeah, I may have missed how I originally coded it -- I've been trying
several different methods so I probably got confused.

Ultimately, it comes down to any use of a "self::XXXX" reference in a parent
class method will cause a child class to use the parent's value for

Most recently, I tried assigning constants in the parent class to the value
of __CLASS__. Sure enough, when those constants were used in a static method
and called by a child class, the value of the constants were the name of the
parent class, not the class actually calling the method(!).

I'm thinking I may have to develop a separate manager class to handle the
functions. Kind of a drag, but I really don't want to cut and paste the
exact same methods into 10 child classes.

I'm not seeing the upside to this implementation of self::. How does Java
handle this?

Andrew Kamm

More information about the talk mailing list