ID:               44011
 Updated by:       [EMAIL PROTECTED]
 Reported By:      ms419 at freezone dot co dot uk
-Status:           Open
+Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: Debian
 PHP Version:      5.2.5
 New Comment:

In this case, you will need use 'return static::bbb();'. (As of PHP
5.3.0)

http://docs.php.net/manual/en/language.oop5.late-static-bindings.php


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

[2008-02-01 06:46:39] ms419 at freezone dot co dot uk

Description:
------------
When I call Bar::aaa(); I expect the self keyword to refer to the Bar
class, even if aaa() is defined in a class which Bar extends.

The behavior I observe is that, if aaa() is defined in a class Foo
which Bar extends, even when I call Bar::aaa(), self refers to Foo.

In this case the self keyword is not actually that much use, since if I
type "self" in the definition of the Foo class, I know the class name
and might as well type "Foo".

I had hoped that the self keyword would enable me to override some
static functions from a parent class, without forcing me to override the
static functions which call them.

Reproduce code:
---------------
<?php

class Foo
{
  public static function aaa()
  {
    return self::bbb();
  }

  public static function bbb()
  {
    return 'Foo';
  }
}

class Bar extends Foo
{
  public static function bbb()
  {
    return 'Bar';
  }
}

var_dump(Bar::aaa());


Expected result:
----------------
string(3) "Bar"


Actual result:
--------------
string(3) "Foo"



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


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

Reply via email to