Replace $this with static and covariant static in generics (#20733)

This commit is contained in:
Maksim Spirkov
2026-02-12 13:20:59 +04:00
committed by GitHub
parent d0fcd4f363
commit dbd9f246de
11 changed files with 61 additions and 60 deletions

View File

@@ -575,11 +575,11 @@ class Module extends ServiceLocator
* part of the route which will be treated as the action ID. Otherwise, `false` will be returned.
*
* @param string $route the route consisting of module, controller and action IDs.
* @return array{Controller<$this>, string}|false If the controller is created successfully, it will be returned together
* @return array{Controller<static>, string}|false If the controller is created successfully, it will be returned together
* with the requested action ID. Otherwise `false` will be returned.
* @throws InvalidConfigException if the controller class and its file do not match.
*
* @phpstan-return array{Controller<$this>, string}|false
* @phpstan-return array{Controller<static>, string}|false
* @psalm-return array{Controller<self>, string}|false
*/
public function createController($route)
@@ -634,11 +634,11 @@ class Module extends ServiceLocator
* Note that this method does not check [[modules]] or [[controllerMap]].
*
* @param string $id the controller ID.
* @return Controller<$this>|null the newly created controller instance, or `null` if the controller ID is invalid.
* @return Controller<static>|null the newly created controller instance, or `null` if the controller ID is invalid.
* @throws InvalidConfigException if the controller class and its file name do not match.
* This exception is only thrown when in debug mode.
*
* @phpstan-return Controller<$this>|null
* @phpstan-return Controller<static>|null
* @psalm-return Controller<self>|null
*/
public function createControllerByID($id)
@@ -717,10 +717,10 @@ class Module extends ServiceLocator
* }
* ```
*
* @param Action<Controller<$this>> $action the action to be executed.
* @param Action<Controller<static>> $action the action to be executed.
* @return bool whether the action should continue to be executed.
*
* @phpstan-param Action<Controller<$this>> $action
* @phpstan-param Action<Controller<static>> $action
* @psalm-param Action<Controller<self>> $action
*/
public function beforeAction($action)
@@ -747,11 +747,11 @@ class Module extends ServiceLocator
* }
* ```
*
* @param Action<Controller<$this>> $action the action just executed.
* @param Action<Controller<static>> $action the action just executed.
* @param mixed $result the action return result.
* @return mixed the processed action result.
*
* @phpstan-param Action<Controller<$this>> $action
* @phpstan-param Action<Controller<static>> $action
* @psalm-param Action<Controller<self>> $action
*/
public function afterAction($action, $result)