---
title: "Static methods"
manual: "TYPO3 Explained"
version: "11.5"
permalink: "https://docs.typo3.org/permalink/t3coreapi:cgl-static-methods@11.5"
source: "CodingGuidelines/CodingBestPractices/StaticMethods.rst"
rendered: "2026-10-21T15:30:00+00:00"
---

> [!WARNING]
> **Attention**
>
> TYPO3 v11 has reached end-of-life as of October 31th 2024 and
> is no longer being maintained. Use the version switcher on the top
> left of this page to select documentation for a supported version of TYPO3.
>
> Need more time before upgrading?
> You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here:
> [TYPO3 ELTS](https://typo3.com/services/extended-support-elts).

# Static methods {#cgl-static-methods}

When a given class calls one of its own static methods (or one from one
of its parents), the code should use the `self` keyword instead
of the class name. For more information on when or where static methods
are a good idea (or not), see [modelling cross cutting concerns](https://docs.typo3.org/permalink/t3coreapi:cgl-model-static-methods@11.5).

## Example {#example}

```php
class MyClass
{
    public static function methodA()
    {
        //...
    }
    public static function methodB()
    {
        // instead of MyClass::methodA():
        self::methodA();
    }
}
```

Note that using `static::` does not work in closures/lambda
functions/anonymous functions.
