mirror of
https://github.com/yiisoft/yii2.git
synced 2025-12-13 18:01:32 +08:00
Fix #20658: Add missing generics in yii\console, yii\captcha, yii\caching and yii\behaviors namespaces
This commit is contained in:
@@ -77,6 +77,7 @@ Yii Framework 2 Change Log
|
||||
- Enh #20650: Add PHPStan/Psalm annotations for `yii\di\Container` (mspirkov)
|
||||
- Bug #20654: Add missing generics in `yii\db` namespace. Fix PHPDoc annotations in `yii\db\ArrayExpression` (mspirkov)
|
||||
- Bug #20651: Add missing generics in `yii\filters` namespace (mspirkov)
|
||||
- Bug #20658: Add missing generics in `yii\console`, `yii\captcha`, `yii\caching` and `yii\behaviors` namespaces (mspirkov)
|
||||
- Bug #20659: Fix `PHP` `8.5` `null` array offset deprecation warnings in `MariaDB` driver (terabytesoftw)
|
||||
|
||||
|
||||
|
||||
@@ -21,9 +21,6 @@ namespace yii\base;
|
||||
* @since 2.0
|
||||
*
|
||||
* @template T of Component
|
||||
*
|
||||
* @phpstan-property T|null $owner
|
||||
* @psalm-property T|null $owner
|
||||
*/
|
||||
class Behavior extends BaseObject
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@ use Closure;
|
||||
use yii\base\Behavior;
|
||||
use yii\base\Event;
|
||||
use yii\db\ActiveRecord;
|
||||
use yii\db\BaseActiveRecord;
|
||||
|
||||
/**
|
||||
* AttributeBehavior automatically assigns a specified value to one or multiple attributes of an ActiveRecord
|
||||
@@ -47,6 +48,9 @@ use yii\db\ActiveRecord;
|
||||
* @author Luciano Baraglia <luciano.baraglia@gmail.com>
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @since 2.0
|
||||
*
|
||||
* @template T of BaseActiveRecord
|
||||
* @extends Behavior<T>
|
||||
*/
|
||||
class AttributeBehavior extends Behavior
|
||||
{
|
||||
|
||||
@@ -108,6 +108,9 @@ use yii\validators\StringValidator;
|
||||
*
|
||||
* @author Paul Klimov <klimov.paul@gmail.com>
|
||||
* @since 2.0.10
|
||||
*
|
||||
* @template T of Model|BaseActiveRecord
|
||||
* @extends Behavior<T>
|
||||
*/
|
||||
class AttributeTypecastBehavior extends Behavior
|
||||
{
|
||||
@@ -117,7 +120,10 @@ class AttributeTypecastBehavior extends Behavior
|
||||
public const TYPE_STRING = 'string';
|
||||
|
||||
/**
|
||||
* @var Model|BaseActiveRecord the owner of this behavior.
|
||||
* @var Model|BaseActiveRecord|null the owner of this behavior.
|
||||
*
|
||||
* @phpstan-var T|null
|
||||
* @psalm-var T|null
|
||||
*/
|
||||
public $owner;
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,7 @@ use Closure;
|
||||
use yii\base\Behavior;
|
||||
use yii\base\Event;
|
||||
use yii\db\ActiveRecord;
|
||||
use yii\db\BaseActiveRecord;
|
||||
|
||||
/**
|
||||
* AttributesBehavior automatically assigns values specified to one or multiple attributes of an ActiveRecord
|
||||
@@ -60,6 +61,9 @@ use yii\db\ActiveRecord;
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @author Bogdan Stepanenko <bscheshirwork@gmail.com>
|
||||
* @since 2.0.13
|
||||
*
|
||||
* @template T of BaseActiveRecord
|
||||
* @extends Behavior<T>
|
||||
*/
|
||||
class AttributesBehavior extends Behavior
|
||||
{
|
||||
|
||||
@@ -53,6 +53,9 @@ use yii\db\BaseActiveRecord;
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @author Alexander Kochetov <creocoder@gmail.com>
|
||||
* @since 2.0
|
||||
*
|
||||
* @template T of BaseActiveRecord
|
||||
* @extends AttributeBehavior<T>
|
||||
*/
|
||||
class BlameableBehavior extends AttributeBehavior
|
||||
{
|
||||
|
||||
@@ -43,6 +43,9 @@ use yii\di\Instance;
|
||||
*
|
||||
* @author Nikolay Oleynikov <oleynikovny@mail.ru>
|
||||
* @since 2.0.14
|
||||
*
|
||||
* @template T of Widget
|
||||
* @extends Behavior<Widget>
|
||||
*/
|
||||
class CacheableWidgetBehavior extends Behavior
|
||||
{
|
||||
|
||||
@@ -61,6 +61,9 @@ use yii\helpers\ArrayHelper;
|
||||
* @author Salem Ouerdani <tunecino@gmail.com>
|
||||
* @since 2.0.16
|
||||
* @see \yii\db\BaseActiveRecord::optimisticLock() for details on how to enable optimistic lock.
|
||||
*
|
||||
* @template T of BaseActiveRecord
|
||||
* @extends AttributeBehavior<T>
|
||||
*/
|
||||
class OptimisticLockBehavior extends AttributeBehavior
|
||||
{
|
||||
|
||||
@@ -60,6 +60,9 @@ use yii\validators\UniqueValidator;
|
||||
* @author Alexander Kochetov <creocoder@gmail.com>
|
||||
* @author Paul Klimov <klimov.paul@gmail.com>
|
||||
* @since 2.0
|
||||
*
|
||||
* @template T of BaseActiveRecord
|
||||
* @extends AttributeBehavior<T>
|
||||
*/
|
||||
class SluggableBehavior extends AttributeBehavior
|
||||
{
|
||||
|
||||
@@ -68,6 +68,9 @@ use yii\db\BaseActiveRecord;
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @author Alexander Kochetov <creocoder@gmail.com>
|
||||
* @since 2.0
|
||||
*
|
||||
* @template T of BaseActiveRecord
|
||||
* @extends AttributeBehavior<T>
|
||||
*/
|
||||
class TimestampBehavior extends AttributeBehavior
|
||||
{
|
||||
|
||||
@@ -39,6 +39,8 @@ namespace yii\caching;
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @author Dmitry Naumenko <d.naumenko.a@gmail.com>
|
||||
* @since 2.0.13. Previous framework versions used abstract class [[yii\caching\Cache]] as interface.
|
||||
*
|
||||
* @extends \ArrayAccess<string, mixed>
|
||||
*/
|
||||
interface CacheInterface extends \ArrayAccess
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ use yii\base\InvalidConfigException;
|
||||
use yii\helpers\Json;
|
||||
use yii\validators\ValidationAsset;
|
||||
use yii\validators\Validator;
|
||||
use yii\web\Controller;
|
||||
|
||||
/**
|
||||
* CaptchaValidator validates that the attribute value is the same as the verification code displayed in the CAPTCHA.
|
||||
@@ -67,14 +68,20 @@ class CaptchaValidator extends Validator
|
||||
* Creates the CAPTCHA action object from the route specified by [[captchaAction]].
|
||||
* @return CaptchaAction the action object
|
||||
* @throws InvalidConfigException
|
||||
*
|
||||
* @phpstan-return CaptchaAction<Controller>
|
||||
* @psalm-return CaptchaAction<Controller>
|
||||
*/
|
||||
public function createCaptchaAction()
|
||||
{
|
||||
$ca = Yii::$app->createController($this->captchaAction);
|
||||
if ($ca !== false) {
|
||||
/** @var \yii\base\Controller $controller */
|
||||
/** @var Controller $controller */
|
||||
list($controller, $actionID) = $ca;
|
||||
/** @var CaptchaAction|null */
|
||||
/**
|
||||
* @var CaptchaAction|null
|
||||
* @phpstan-var CaptchaAction<Controller>|null
|
||||
*/
|
||||
$action = $controller->createAction($actionID);
|
||||
if ($action !== null) {
|
||||
return $action;
|
||||
|
||||
@@ -545,6 +545,9 @@ class Controller extends \yii\base\Controller
|
||||
* Returns a one-line short summary describing the specified action.
|
||||
* @param Action $action action to get summary for
|
||||
* @return string a one-line short summary describing the specified action.
|
||||
*
|
||||
* @phpstan-param Action<static> $action
|
||||
* @psalm-param Action<static> $action
|
||||
*/
|
||||
public function getActionHelpSummary($action)
|
||||
{
|
||||
@@ -559,6 +562,9 @@ class Controller extends \yii\base\Controller
|
||||
* Returns the detailed help information for the specified action.
|
||||
* @param Action $action action to get help for
|
||||
* @return string the detailed help information for the specified action.
|
||||
*
|
||||
* @phpstan-param Action<static> $action
|
||||
* @psalm-param Action<static> $action
|
||||
*/
|
||||
public function getActionHelp($action)
|
||||
{
|
||||
@@ -581,6 +587,9 @@ class Controller extends \yii\base\Controller
|
||||
*
|
||||
* @param Action $action the action instance
|
||||
* @return array the help information of the action arguments
|
||||
*
|
||||
* @phpstan-param Action<static> $action
|
||||
* @psalm-param Action<static> $action
|
||||
*/
|
||||
public function getActionArgsHelp($action)
|
||||
{
|
||||
@@ -654,6 +663,9 @@ class Controller extends \yii\base\Controller
|
||||
*
|
||||
* @param Action $action
|
||||
* @return array the help information of the action options
|
||||
*
|
||||
* @phpstan-param Action<static> $action
|
||||
* @psalm-param Action<static> $action
|
||||
*/
|
||||
public function getActionOptionsHelp($action)
|
||||
{
|
||||
@@ -709,6 +721,9 @@ class Controller extends \yii\base\Controller
|
||||
/**
|
||||
* @param Action $action
|
||||
* @return \ReflectionFunctionAbstract
|
||||
*
|
||||
* @phpstan-param Action<static> $action
|
||||
* @psalm-param Action<static> $action
|
||||
*/
|
||||
protected function getActionMethodReflection($action)
|
||||
{
|
||||
@@ -727,6 +742,9 @@ class Controller extends \yii\base\Controller
|
||||
* Parses the comment block into tags.
|
||||
* @param \ReflectionClass|\ReflectionProperty|\ReflectionFunctionAbstract $reflection the comment block
|
||||
* @return array the parsed tags
|
||||
*
|
||||
* @phpstan-param \ReflectionClass<object>|\ReflectionProperty|\ReflectionFunctionAbstract $reflection
|
||||
* @psalm-param \ReflectionClass<object>|\ReflectionProperty|\ReflectionFunctionAbstract $reflection
|
||||
*/
|
||||
protected function parseDocCommentTags($reflection)
|
||||
{
|
||||
@@ -755,6 +773,9 @@ class Controller extends \yii\base\Controller
|
||||
*
|
||||
* @param \ReflectionClass|\ReflectionProperty|\ReflectionFunctionAbstract $reflection
|
||||
* @return string
|
||||
*
|
||||
* @phpstan-param \ReflectionClass<$this>|\ReflectionProperty|\ReflectionFunctionAbstract $reflection
|
||||
* @psalm-param \ReflectionClass<$this>|\ReflectionProperty|\ReflectionFunctionAbstract $reflection
|
||||
*/
|
||||
protected function parseDocCommentSummary($reflection)
|
||||
{
|
||||
@@ -771,6 +792,9 @@ class Controller extends \yii\base\Controller
|
||||
*
|
||||
* @param \ReflectionClass|\ReflectionProperty|\ReflectionFunctionAbstract $reflection
|
||||
* @return string
|
||||
*
|
||||
* @phpstan-param \ReflectionClass<$this>|\ReflectionProperty|\ReflectionFunctionAbstract $reflection
|
||||
* @psalm-param \ReflectionClass<$this>|\ReflectionProperty|\ReflectionFunctionAbstract $reflection
|
||||
*/
|
||||
protected function parseDocCommentDetail($reflection)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
namespace yii\console\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Action;
|
||||
use yii\base\BaseObject;
|
||||
use yii\base\InvalidConfigException;
|
||||
use yii\base\NotSupportedException;
|
||||
@@ -122,9 +123,12 @@ abstract class BaseMigrateController extends Controller
|
||||
/**
|
||||
* This method is invoked right before an action is to be executed (after all possible filters.)
|
||||
* It checks the existence of the [[migrationPath]].
|
||||
* @param \yii\base\Action $action the action to be executed.
|
||||
* @param Action $action the action to be executed.
|
||||
* @throws InvalidConfigException if directory specified in migrationPath doesn't exist and action isn't "create".
|
||||
* @return bool whether the action should continue to be executed.
|
||||
*
|
||||
* @phpstan-param Action<static> $action
|
||||
* @psalm-param Action<static> $action
|
||||
*/
|
||||
public function beforeAction($action)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
namespace yii\console\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Action;
|
||||
use yii\db\Connection;
|
||||
use yii\db\Query;
|
||||
use yii\di\Instance;
|
||||
@@ -174,8 +175,11 @@ class MigrateController extends BaseMigrateController
|
||||
/**
|
||||
* This method is invoked right before an action is to be executed (after all possible filters.)
|
||||
* It checks the existence of the [[migrationPath]].
|
||||
* @param \yii\base\Action $action the action to be executed.
|
||||
* @param Action $action the action to be executed.
|
||||
* @return bool whether the action should continue to be executed.
|
||||
*
|
||||
* @phpstan-param Action<static> $action
|
||||
* @psalm-param Action<static> $action
|
||||
*/
|
||||
public function beforeAction($action)
|
||||
{
|
||||
|
||||
@@ -351,27 +351,12 @@ parameters:
|
||||
path: framework/console/Controller.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method yii\\\\base\\\\Component\\:\\:isAttributeChanged\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: framework/behaviors/SluggableBehavior.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method yii\\\\base\\\\Component\\:\\:formName\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: framework/behaviors/OptimisticLockBehavior.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property yii\\\\base\\\\Component\\:\\:\\$view\\.$#"
|
||||
count: 2
|
||||
path: framework/behaviors/CacheableWidgetBehavior.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method yii\\\\base\\\\Model\\:\\:canSetOldAttribute\\(\\)\\.$#"
|
||||
message: "#^Call to an undefined method T of yii\\\\base\\\\Model\\:\\:canSetOldAttribute\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: framework/behaviors/AttributeTypecastBehavior.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method yii\\\\base\\\\Model\\:\\:setOldAttribute\\(\\)\\.$#"
|
||||
message: "#^Call to an undefined method T of yii\\\\base\\\\Model\\:\\:setOldAttribute\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: framework/behaviors/AttributeTypecastBehavior.php
|
||||
|
||||
|
||||
Reference in New Issue
Block a user