# RFC: LSB parent::/self:: forwarding

- Status: Implemented (PHP 5.3)
- Authors: Etienne Kneuss colder@php.net
- Date: 2008-07-22
- Version: 1.0
- Original: https://wiki.php.net/rfc/lsb_parentself_forwarding
- Page: https://externals.io/rfc/lsb_parentself_forwarding
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

## Discussions on the mailing list

No thread found.

---

## Introduction

This RFC covers the change that occured to Late Static Bindings (LSB) prior to its first alpha release.

### Terms and concepts

LSB works by passing the original call info to the function, used then by `static::` or get\_called\_class to get the original class name used. This information will only be useful in case a `fallback` occurs, which takes place when you call a static method that only exists in one of the parent classes.

```php
<?php
  class A {
     public static function who() {
        return get_called_class();
     }
  }
  class B extends A {
 
  }
  class C extends B {
 
  } 
  echo C::who(); // C
?>
```

Now let's say that you want to overwrite who in B, but still rely on A's who():

```php
<?php
  class A {
     public static function who() {
        return get_called_class();
     }
  }
  class B extends A {
     public static function who() {
         /* do stuff.. */
 
         /* call A's who() */
     }  
  }
  class C extends B {
 
  } 
  echo C::who(); // ??
?>
```

Now, depending on how you call A's `who()` from `B::who()`, you might get different results for the `C::who()` call:

1. C, if the call was `forwarding`
2. A, if the call wasn't `forwarding`.

## The change

Previously, `A::who()` and `parent::who()` would be `non-forwarding`. The only way to call A's who() with `forwarding` was to use an helper function: `forward_static_call()`.

With the change, a difference between `parent::` and `A::` is introduced, that is: `parent::` is `forwarding` while `A::` isn't. Basically, explicit calls are `non-forwarding`, but calls using keywords are.

Note that `self::` will also be made to be `forwarding`, while `<nameoftheclass>::` won't.

## ML Discussion

<http://markmail.org/message/at3ypbykl6luwr6l>
