on Q1, Q2
While it sounds logical, you have to find out that you are using
static variables. The way i understand it is that when you used self::
$property it reads only as A::$property so extending it should not
affect the static variables coz B is not A on static variables. I
would suggest you to just override the method() on class B
Q3
abstract class A {
protected static $property = false; # Q1
public static function method() { # Q2
return self::$property;
}
}
class B extends A {
protected static $property = true; # Q1
public static function method() { # Q2
return self::$property;
}
}
var_dump(B::method());
On Oct 31, 7:00 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Well I guess its Halloween so we can expect a few (help) vampires
> right? hehe!
>
> On Oct 31, 4:04 am, Calvin <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
>
> > I am finding difficult to understand why this isn't working...
>
> > <?php
>
> > abstract class A {
> > protected static $property = false; # Q1
> > public static function method() { # Q2
> > return self::$property;
> > }
>
> > }
>
> > class B extends A {
> > protected static $property = true; # Q1
>
> > }
>
> > var_dump(B::method());
>
> > It prints False and I expect it to be True...
>
> > Q1. Does B::$property suppose to overwrite B::$property?
> > Q2. when B::method() is called, shouldn't it return B::$property (even
> > though the method is declared in A)?
> > Q3. Anyways to change the code to work as my expectation?
>
> > Thanks in advance
>
> > - Calvin
Almond
http://monmonja.com/blog/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---