Skip to content

Commit 7dd3ded

Browse files
authored
Add generics for all controllers (#20675)
1 parent 0998ac6 commit 7dd3ded

36 files changed

+216
-63
lines changed

build/controllers/ClassmapController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace yii\build\controllers;
99

10+
use yii\console\Application;
1011
use yii\console\Controller;
1112
use yii\console\Exception;
1213
use yii\helpers\FileHelper;
@@ -16,6 +17,8 @@
1617
*
1718
* @author Qiang Xue <[email protected]>
1819
* @since 2.0
20+
*
21+
* @extends Controller<Application>
1922
*/
2023
class ClassmapController extends Controller
2124
{

build/controllers/DevController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Yii;
1111
use yii\base\InvalidParamException;
12+
use yii\console\Application;
1213
use yii\console\Controller;
1314
use yii\console\ExitCode;
1415
use yii\helpers\Console;
@@ -22,6 +23,8 @@
2223
*
2324
* @author Carsten Brandt <[email protected]>
2425
* @since 2.0
26+
*
27+
* @extends Controller<Application>
2528
*/
2629
class DevController extends Controller
2730
{

build/controllers/MimeTypeController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace yii\build\controllers;
1010

1111
use Yii;
12+
use yii\console\Application;
1213
use yii\console\Controller;
1314
use yii\helpers\Console;
1415
use yii\helpers\VarDumper;
@@ -24,6 +25,8 @@
2425
*
2526
* @author Carsten Brandt <[email protected]>
2627
* @since 2.0
28+
*
29+
* @extends Controller<Application>
2730
*/
2831
class MimeTypeController extends Controller
2932
{

build/controllers/PhpDocController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Yii;
1212
use yii\base\Model;
1313
use yii\base\Module;
14+
use yii\console\Application;
1415
use yii\console\Controller as ConsoleController;
1516
use yii\db\QueryBuilder;
1617
use yii\helpers\Console;
@@ -27,6 +28,8 @@
2728
* @author Carsten Brandt <[email protected]>
2829
* @author Alexander Makarov <[email protected]>
2930
* @since 2.0
31+
*
32+
* @extends ConsoleController<Application>
3033
*/
3134
class PhpDocController extends ConsoleController
3235
{

build/controllers/ReleaseController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Yii;
1212
use yii\base\Exception;
13+
use yii\console\Application;
1314
use yii\console\Controller;
1415
use yii\helpers\ArrayHelper;
1516
use yii\helpers\Console;
@@ -40,6 +41,8 @@
4041
*
4142
* @author Carsten Brandt <[email protected]>
4243
* @since 2.0
44+
*
45+
* @extends Controller<Application>
4346
*/
4447
class ReleaseController extends Controller
4548
{

build/controllers/TranslationController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace yii\build\controllers;
99

1010
use DirectoryIterator;
11+
use yii\console\Application;
1112
use yii\console\Controller;
1213
use yii\helpers\Html;
1314

@@ -17,6 +18,8 @@
1718
* build translation "../docs/guide" "../docs/guide-ru" "Russian guide translation report" > report_guide_ru.html
1819
*
1920
* @author Alexander Makarov <[email protected]>
21+
*
22+
* @extends Controller<Application>
2023
*/
2124
class TranslationController extends Controller
2225
{

build/controllers/Utf8Controller.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace yii\build\controllers;
1010

11+
use yii\console\Application;
1112
use yii\console\Controller;
1213
use yii\helpers\Console;
1314
use yii\helpers\FileHelper;
@@ -16,6 +17,8 @@
1617
* Check files for broken UTF8 and non-printable characters.
1718
*
1819
* @author Carsten Brandt <[email protected]>
20+
*
21+
* @extends Controller<Application>
1922
*/
2023
class Utf8Controller extends Controller
2124
{

framework/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Yii Framework 2 Change Log
8383
- Bug #20666: Add missing generics in `yii\base`, `yii\console`, `yii\filters` and `yii\web` namespaces (mspirkov)
8484
- Bug #20673: Sanitize `null` bytes before `quoteValue()` on PHP 8.5+ in SQLite (terabytesoftw)
8585
- Bug #20671: Fix PHPDoc annotations in `yii\base`, `yii\console`, `yii\web` and `yii\widgets` namespaces (mspirkov)
86+
- Bug #20675: Add generics for all controllers (mspirkov)
8687

8788

8889
2.0.53 June 27, 2025

framework/base/ActionFilter.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public function detach()
7171
/**
7272
* @param ActionEvent $event
7373
*
74-
* @phpstan-param ActionEvent<Action<Controller>> $event
75-
* @psalm-param ActionEvent<Action<Controller>> $event
74+
* @phpstan-param ActionEvent<Action<Controller<Module>>> $event
75+
* @psalm-param ActionEvent<Action<Controller<Module>>> $event
7676
*/
7777
public function beforeFilter($event)
7878
{
@@ -93,8 +93,8 @@ public function beforeFilter($event)
9393
/**
9494
* @param ActionEvent $event
9595
*
96-
* @phpstan-param ActionEvent<Action<Controller>> $event
97-
* @psalm-param ActionEvent<Action<Controller>> $event
96+
* @phpstan-param ActionEvent<Action<Controller<Module>>> $event
97+
* @psalm-param ActionEvent<Action<Controller<Module>>> $event
9898
*/
9999
public function afterFilter($event)
100100
{
@@ -108,8 +108,8 @@ public function afterFilter($event)
108108
* @param Action $action the action to be executed.
109109
* @return bool whether the action should continue to be executed.
110110
*
111-
* @phpstan-param Action<Controller> $action
112-
* @psalm-param Action<Controller> $action
111+
* @phpstan-param Action<Controller<Module>> $action
112+
* @psalm-param Action<Controller<Module>> $action
113113
*/
114114
public function beforeAction($action)
115115
{
@@ -123,8 +123,8 @@ public function beforeAction($action)
123123
* @param mixed $result the action execution result
124124
* @return mixed the processed action result.
125125
*
126-
* @phpstan-param Action<Controller> $action
127-
* @psalm-param Action<Controller> $action
126+
* @phpstan-param Action<Controller<Module>> $action
127+
* @psalm-param Action<Controller<Module>> $action
128128
*/
129129
public function afterAction($action, $result)
130130
{
@@ -137,8 +137,8 @@ public function afterAction($action, $result)
137137
* @return string
138138
* @since 2.0.7
139139
*
140-
* @phpstan-param Action<Controller> $action
141-
* @psalm-param Action<Controller> $action
140+
* @phpstan-param Action<Controller<Module>> $action
141+
* @psalm-param Action<Controller<Module>> $action
142142
*/
143143
protected function getActionId($action)
144144
{
@@ -160,8 +160,8 @@ protected function getActionId($action)
160160
* @param Action $action the action being filtered
161161
* @return bool whether the filter is active for the given action.
162162
*
163-
* @phpstan-param Action<Controller> $action
164-
* @psalm-param Action<Controller> $action
163+
* @phpstan-param Action<Controller<Module>> $action
164+
* @psalm-param Action<Controller<Module>> $action
165165
*/
166166
protected function isActive($action)
167167
{

framework/base/Application.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ abstract class Application extends Module
114114
public $sourceLanguage = 'en-US';
115115
/**
116116
* @var Controller|null the currently active controller instance
117+
*
118+
* @phpstan-var Controller<Module>|null
119+
* @psalm-var Controller<Module>|null
117120
*/
118121
public $controller;
119122
/**
@@ -128,8 +131,8 @@ abstract class Application extends Module
128131
/**
129132
* @var Action|null the requested Action. If null, it means the request cannot be resolved into an action.
130133
*
131-
* @phpstan-var Action<covariant Controller>|null
132-
* @psalm-var Action<covariant Controller>|null
134+
* @phpstan-var Action<covariant Controller<Module>>|null
135+
* @psalm-var Action<covariant Controller<Module>>|null
133136
*/
134137
public $requestedAction;
135138
/**

0 commit comments

Comments
 (0)