Merge branch 'master' into controller-array-fix

This commit is contained in:
Christina Reichel
2025-05-19 12:22:15 +02:00
committed by GitHub
24 changed files with 479 additions and 57 deletions

View File

@ -26,6 +26,15 @@ use yii\helpers\Url;
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*
* @phpstan-import-type RegisterJsFileOptions from View
* @psalm-import-type RegisterJsFileOptions from View
*
* @phpstan-import-type RegisterCssFileOptions from View
* @psalm-import-type RegisterCssFileOptions from View
*
* @phpstan-import-type PublishOptions from AssetManager
* @psalm-import-type PublishOptions from AssetManager
*/
class AssetBundle extends BaseObject
{
@ -72,6 +81,9 @@ class AssetBundle extends BaseObject
* 'yii\bootstrap\BootstrapAsset',
* ];
* ```
*
* @phpstan-var class-string[]
* @psalm-var class-string[]
*/
public $depends = [];
/**
@ -89,6 +101,9 @@ class AssetBundle extends BaseObject
* This functionality is available since version 2.0.7.
*
* Note that only a forward slash "/" should be used as directory separator.
*
* @phpstan-var (string|array<int|string, mixed>)[]
* @psalm-var (string|array<int|string, mixed>)[]
*/
public $js = [];
/**
@ -96,21 +111,33 @@ class AssetBundle extends BaseObject
* in one of the three formats as explained in [[js]].
*
* Note that only a forward slash "/" should be used as directory separator.
*
* @phpstan-var (string|array<int|string, mixed>)[]
* @psalm-var (string|array<int|string, mixed>)[]
*/
public $css = [];
/**
* @var array the options that will be passed to [[View::registerJsFile()]]
* when registering the JS files in this bundle.
*
* @phpstan-var RegisterJsFileOptions
* @psalm-var RegisterJsFileOptions
*/
public $jsOptions = [];
/**
* @var array the options that will be passed to [[View::registerCssFile()]]
* when registering the CSS files in this bundle.
*
* @phpstan-var RegisterCssFileOptions
* @psalm-var RegisterCssFileOptions
*/
public $cssOptions = [];
/**
* @var array the options to be passed to [[AssetManager::publish()]] when the asset bundle
* is being published. This property is used only when [[sourcePath]] is set.
*
* @phpstan-var PublishOptions
* @psalm-var PublishOptions
*/
public $publishOptions = [];

View File

@ -38,6 +38,24 @@ use yii\helpers\Url;
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*
* @phpstan-type PublishOptions array{
* only?: string[],
* except?: string[],
* caseSensitive?: bool,
* beforeCopy?: callable,
* afterCopy?: callable,
* forceCopy?: bool,
* }
*
* @psalm-type PublishOptions = array{
* only?: string[],
* except?: string[],
* caseSensitive?: bool,
* beforeCopy?: callable,
* afterCopy?: callable,
* forceCopy?: bool,
* }
*/
class AssetManager extends Component
{
@ -463,6 +481,9 @@ class AssetManager extends Component
* @return array the path (directory or file path) and the URL that the asset is published as.
* @throws InvalidArgumentException if the asset to be published does not exist.
* @throws InvalidConfigException if the target directory [[basePath]] is not writeable.
*
* @phpstan-param PublishOptions $options
* @psalm-param PublishOptions $options
*/
public function publish($path, $options = [])
{

View File

@ -41,6 +41,28 @@ use yii\helpers\Url;
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*
* @phpstan-type RegisterJsFileOptions array{
* depends?: class-string[],
* position?: int,
* appendTimestamp?: boolean
* }
*
* @psalm-type RegisterJsFileOptions = array{
* depends?: class-string[],
* position?: int,
* appendTimestamp?: boolean
* }
*
* @phpstan-type RegisterCssFileOptions array{
* depends?: class-string[],
* appendTimestamp?: boolean
* }
*
* @psalm-type RegisterCssFileOptions = array{
* depends?: class-string[],
* appendTimestamp?: boolean
* }
*/
class View extends \yii\base\View
{
@ -445,6 +467,9 @@ class View extends \yii\base\View
* $url as the key. If two CSS files are registered with the same key, the latter
* will overwrite the former.
* @throws InvalidConfigException
*
* @phpstan-param RegisterCssFileOptions $options
* @psalm-param RegisterCssFileOptions $options
*/
public function registerCssFile($url, $options = [], $key = null)
{
@ -569,6 +594,9 @@ class View extends \yii\base\View
* will overwrite the former. Note that position option takes precedence, thus files registered with the same key,
* but different position option will not override each other.
* @throws InvalidConfigException
*
* @phpstan-param RegisterJsFileOptions $options
* @psalm-param RegisterJsFileOptions $options
*/
public function registerJsFile($url, $options = [], $key = null)
{