Project

General

Profile

Actions

Task #66322

closed

Use static:: instead of self::

Added by Markus Hölzle over 9 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Code Cleanup
Target version:
-
Start date:
2015-04-08
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

Hi there,

is there a reason why TYPO3 uses "self::" to access static methods? For more flexibility it would be nice if TYPO3 uses "static::" (so you can extend the classes).

For example in the fluid translation view helper:

class TranslateViewHelper extends AbstractViewHelper implements CompilableInterface {
  public function render(...) {
    return self::renderStatic(...);
  }

  static public function renderStatic(...) {
    ...
  }
}

class MyPrefixedTranslateViewHelper extends TranslateViewHelper {
  public function render(...) {
    // this function has nothing new, it's just there to call our own static function
    return self::renderStatic(...);
  }

  static public function renderStatic(...) {
    ...
  }
}

If you just want to overwrite the static function "renderStatic", you also have to overwrite the non-static function "render". If "static::" would be used in the function "render", you just have to overwrite the function "renderStatic".
This looks this way:

class TranslateViewHelper extends AbstractViewHelper implements CompilableInterface {
  public function render(...) {
    return static::renderStatic(...);
  }

  static public function renderStatic(...) {
    ...
  }
}

class MyPrefixedTranslateViewHelper extends TranslateViewHelper {
  static public function renderStatic(...) {
    ...
  }
}

What do you think?

Actions

Also available in: Atom PDF