mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 21:41:19 +08:00
Fix #20433: Added PHPStan/Psalm annotations for some controllers methods: beforeAction, afterAction and bindActionParams
This commit is contained in:
@ -4,7 +4,7 @@ Yii Framework 2 Change Log
|
||||
2.0.54 under development
|
||||
------------------------
|
||||
|
||||
- no changes in this release.
|
||||
- Enh #20433: Added PHPStan/Psalm annotations for some controllers methods: `beforeAction`, `afterAction` and `bindActionParams` (max-s-lab)
|
||||
|
||||
|
||||
2.0.53 June 27, 2025
|
||||
|
||||
@ -227,6 +227,15 @@ class Controller extends Component implements ViewContextInterface
|
||||
* @param Action $action the action to be bound with parameters.
|
||||
* @param array $params the parameters to be bound to the action.
|
||||
* @return array the valid parameters that the action can run with.
|
||||
*
|
||||
* @phpstan-param Action<static> $action
|
||||
* @psalm-param Action<static> $action
|
||||
*
|
||||
* @phpstan-param array<array-key, mixed> $params
|
||||
* @psalm-param array<array-key, mixed> $params
|
||||
*
|
||||
* @phpstan-return mixed[]
|
||||
* @psalm-return mixed[]
|
||||
*/
|
||||
public function bindActionParams($action, $params)
|
||||
{
|
||||
@ -296,6 +305,9 @@ class Controller extends Component implements ViewContextInterface
|
||||
*
|
||||
* @param Action $action the action to be executed.
|
||||
* @return bool whether the action should continue to run.
|
||||
*
|
||||
* @phpstan-param Action<static> $action
|
||||
* @psalm-param Action<static> $action
|
||||
*/
|
||||
public function beforeAction($action)
|
||||
{
|
||||
@ -324,6 +336,9 @@ class Controller extends Component implements ViewContextInterface
|
||||
* @param Action $action the action just executed.
|
||||
* @param mixed $result the action return result.
|
||||
* @return mixed the processed action result.
|
||||
*
|
||||
* @phpstan-param Action<static> $action
|
||||
* @psalm-param Action<static> $action
|
||||
*/
|
||||
public function afterAction($action, $result)
|
||||
{
|
||||
|
||||
@ -189,6 +189,15 @@ class Controller extends \yii\base\Controller
|
||||
* @param array $params the parameters to be bound to the action
|
||||
* @return array the valid parameters that the action can run with.
|
||||
* @throws Exception if there are unknown options or missing arguments
|
||||
*
|
||||
* @phpstan-param Action<static> $action
|
||||
* @psalm-param Action<static> $action
|
||||
*
|
||||
* @phpstan-param array<array-key, mixed> $params
|
||||
* @psalm-param array<array-key, mixed> $params
|
||||
*
|
||||
* @phpstan-return mixed[]
|
||||
* @psalm-return mixed[]
|
||||
*/
|
||||
public function bindActionParams($action, $params)
|
||||
{
|
||||
|
||||
@ -11,6 +11,7 @@ use Yii;
|
||||
use yii\base\Exception;
|
||||
use yii\base\InlineAction;
|
||||
use yii\helpers\Url;
|
||||
use yii\base\Action;
|
||||
|
||||
/**
|
||||
* Controller is the base class of web controllers.
|
||||
@ -108,14 +109,23 @@ class Controller extends \yii\base\Controller
|
||||
|
||||
/**
|
||||
* Binds the parameters to the action.
|
||||
* This method is invoked by [[\yii\base\Action]] when it begins to run with the given parameters.
|
||||
* This method is invoked by [[Action]] when it begins to run with the given parameters.
|
||||
* This method will check the parameter names that the action requires and return
|
||||
* the provided parameters according to the requirement. If there is any missing parameter,
|
||||
* an exception will be thrown.
|
||||
* @param \yii\base\Action $action the action to be bound with parameters
|
||||
* @param Action $action the action to be bound with parameters
|
||||
* @param array $params the parameters to be bound to the action
|
||||
* @return array the valid parameters that the action can run with.
|
||||
* @throws BadRequestHttpException if there are missing or invalid parameters.
|
||||
*
|
||||
* @phpstan-param Action<static> $action
|
||||
* @psalm-param Action<static> $action
|
||||
*
|
||||
* @phpstan-param array<array-key, mixed> $params
|
||||
* @psalm-param array<array-key, mixed> $params
|
||||
*
|
||||
* @phpstan-return mixed[]
|
||||
* @psalm-return mixed[]
|
||||
*/
|
||||
public function bindActionParams($action, $params)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user