mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-01 20:19:42 +08:00
Fix #20591: Add PHPStan/Psalm annotations for yii\rbac\BaseManager::getItems()
This commit is contained in:
@ -49,6 +49,7 @@ Yii Framework 2 Change Log
|
||||
- Bug #20583: Fix return value in `Request::getServerPort` (mspirkov)
|
||||
- Bug #20587: Fix `@var` annotation for `yii\rbac\Item::$ruleName` (mspirkov)
|
||||
- Bug #20589: Fix `@var` annotations for `yii\rbac\DbManager` properties (mspirkov)
|
||||
- Enh #20591: Add PHPStan/Psalm annotations for `yii\rbac\BaseManager::getItems()` (mspirkov)
|
||||
- Bug #20594: Fix `@return` annotation for `Instance::get()` (mspirkov)
|
||||
- Bug #20595: Fix `@return` annotation for `BaseHtml::getAttributeValue()` (mspirkov)
|
||||
|
||||
|
||||
@ -44,6 +44,12 @@ abstract class BaseManager extends Component implements ManagerInterface
|
||||
* Returns the items of the specified type.
|
||||
* @param int $type the auth item type (either [[Item::TYPE_ROLE]] or [[Item::TYPE_PERMISSION]]
|
||||
* @return Item[] the auth items of the specified type.
|
||||
*
|
||||
* @phpstan-param Item::TYPE_ROLE|Item::TYPE_PERMISSION $type
|
||||
* @psalm-param Item::TYPE_ROLE|Item::TYPE_PERMISSION $type
|
||||
*
|
||||
* @phpstan-return ($type is Item::TYPE_ROLE ? Role[] : Permission[])
|
||||
* @psalm-return ($type is Item::TYPE_ROLE ? Role[] : Permission[])
|
||||
*/
|
||||
abstract protected function getItems($type);
|
||||
|
||||
@ -177,7 +183,12 @@ abstract class BaseManager extends Component implements ManagerInterface
|
||||
public function getRole($name)
|
||||
{
|
||||
$item = $this->getItem($name);
|
||||
return $item instanceof Item && $item->type == Item::TYPE_ROLE ? $item : null;
|
||||
if ($item instanceof Item && $item->type == Item::TYPE_ROLE) {
|
||||
/** @var Role $item */
|
||||
return $item;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,7 +197,12 @@ abstract class BaseManager extends Component implements ManagerInterface
|
||||
public function getPermission($name)
|
||||
{
|
||||
$item = $this->getItem($name);
|
||||
return $item instanceof Item && $item->type == Item::TYPE_PERMISSION ? $item : null;
|
||||
if ($item instanceof Item && $item->type == Item::TYPE_PERMISSION) {
|
||||
/** @var Permission $item */
|
||||
return $item;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user