Browse Source

Merge pull request #11477 from Faryshta/patch-2

Use PHP 5.5+ `::class` instead of full class namespace
tags/3.0.0-alpha1
Carsten Brandt 8 years ago
parent
commit
04949e1ab4
  1. 4
      framework/BaseYii.php
  2. 20
      framework/base/Application.php
  3. 10
      framework/base/ErrorHandler.php
  4. 4
      framework/base/Module.php
  5. 6
      framework/base/View.php
  6. 20
      framework/captcha/CaptchaAsset.php
  7. 24
      framework/console/Application.php
  8. 25
      framework/console/controllers/AssetController.php
  9. 12
      framework/console/controllers/FixtureController.php
  10. 8
      framework/console/controllers/HelpController.php
  11. 8
      framework/data/BaseDataProvider.php
  12. 26
      framework/db/Connection.php
  13. 7
      framework/db/Schema.php
  14. 2
      framework/db/cubrid/Schema.php
  15. 6
      framework/db/oci/Schema.php
  16. 5
      framework/di/Container.php
  17. 2
      framework/filters/AccessControl.php
  18. 6
      framework/grid/GridView.php
  19. 20
      framework/grid/GridViewAsset.php
  20. 11
      framework/log/Logger.php
  21. 4
      framework/log/Target.php
  22. 2
      framework/mail/BaseMailer.php
  23. 2
      framework/mutex/FileMutex.php
  24. 4
      framework/rest/Controller.php
  25. 20
      framework/validators/ValidationAsset.php
  26. 42
      framework/validators/Validator.php
  27. 12
      framework/web/Application.php
  28. 6
      framework/web/AssetBundle.php
  29. 2
      framework/web/AssetManager.php
  30. 2
      framework/web/ErrorAction.php
  31. 2
      framework/web/GroupUrlRule.php
  32. 2
      framework/web/JsonParser.php
  33. 12
      framework/web/Request.php
  34. 2
      framework/web/UrlManager.php
  35. 20
      framework/web/YiiAsset.php
  36. 2
      framework/widgets/ActiveForm.php
  37. 20
      framework/widgets/ActiveFormAsset.php
  38. 20
      framework/widgets/MaskedInputAsset.php
  39. 20
      framework/widgets/PjaxAsset.php

4
framework/BaseYii.php

@ -303,7 +303,7 @@ class BaseYii
* *
* ```php * ```php
* // create an object using a class name * // create an object using a class name
* $object = Yii::createObject('yii\db\Connection'); * $object = Yii::createObject(\yii\db\Connection::class);
* *
* // create an object using a configuration array * // create an object using a configuration array
* $object = Yii::createObject([ * $object = Yii::createObject([
@ -361,7 +361,7 @@ class BaseYii
if (self::$_logger !== null) { if (self::$_logger !== null) {
return self::$_logger; return self::$_logger;
} else { } else {
return self::$_logger = static::createObject('yii\log\Logger'); return self::$_logger = static::createObject(Logger::class);
} }
} }

20
framework/base/Application.php

@ -367,7 +367,6 @@ abstract class Application extends Module
public function run() public function run()
{ {
try { try {
$this->state = self::STATE_BEFORE_REQUEST; $this->state = self::STATE_BEFORE_REQUEST;
$this->trigger(self::EVENT_BEFORE_REQUEST); $this->trigger(self::EVENT_BEFORE_REQUEST);
@ -383,12 +382,9 @@ abstract class Application extends Module
$this->state = self::STATE_END; $this->state = self::STATE_END;
return $response->exitStatus; return $response->exitStatus;
} catch (ExitException $e) { } catch (ExitException $e) {
$this->end($e->statusCode, isset($response) ? $response : null); $this->end($e->statusCode, isset($response) ? $response : null);
return $e->statusCode; return $e->statusCode;
} }
} }
@ -616,14 +612,14 @@ abstract class Application extends Module
public function coreComponents() public function coreComponents()
{ {
return [ return [
'log' => ['class' => 'yii\log\Dispatcher'], 'security' => ['class' => Security::class],
'view' => ['class' => 'yii\web\View'], 'formatter' => ['class' => \yii\i18n\Formatter::class],
'formatter' => ['class' => 'yii\i18n\Formatter'], 'i18n' => ['class' => \yii\i18n\I18N::class],
'i18n' => ['class' => 'yii\i18n\I18N'], 'log' => ['class' => \yii\log\Dispatcher::class],
'mailer' => ['class' => 'yii\swiftmailer\Mailer'], 'mailer' => ['class' => \yii\swiftmailer\Mailer::class],
'urlManager' => ['class' => 'yii\web\UrlManager'], 'assetManager' => ['class' => \yii\web\AssetManager::class],
'assetManager' => ['class' => 'yii\web\AssetManager'], 'urlManager' => ['class' => \yii\web\UrlManager::class],
'security' => ['class' => 'yii\base\Security'], 'view' => ['class' => \yii\web\View::class],
]; ];
} }

10
framework/base/ErrorHandler.php

@ -190,7 +190,7 @@ abstract class ErrorHandler extends Component
if (error_reporting() & $code) { if (error_reporting() & $code) {
// load ErrorException manually here because autoloading them will not work // load ErrorException manually here because autoloading them will not work
// when error occurs while autoloading a class // when error occurs while autoloading a class
if (!class_exists('yii\\base\\ErrorException', false)) { if (!class_exists(ErrorException::class, false)) {
require_once(__DIR__ . '/ErrorException.php'); require_once(__DIR__ . '/ErrorException.php');
} }
$exception = new ErrorException($message, $code, $code, $file, $line); $exception = new ErrorException($message, $code, $code, $file, $line);
@ -220,9 +220,9 @@ abstract class ErrorHandler extends Component
{ {
unset($this->_memoryReserve); unset($this->_memoryReserve);
// load ErrorException manually here because autoloading them will not work // load ErrorException manually here because autoloading them will not
// when error occurs while autoloading a class // work when error occurs while autoloading a class
if (!class_exists('yii\\base\\ErrorException', false)) { if (!class_exists(ErrorException::class, false)) {
require_once(__DIR__ . '/ErrorException.php'); require_once(__DIR__ . '/ErrorException.php');
} }
@ -267,7 +267,7 @@ abstract class ErrorHandler extends Component
{ {
$category = get_class($exception); $category = get_class($exception);
if ($exception instanceof HttpException) { if ($exception instanceof HttpException) {
$category = 'yii\\web\\HttpException:' . $exception->statusCode; $category = HttpException::class . ': ' . $exception->statusCode;
} elseif ($exception instanceof \ErrorException) { } elseif ($exception instanceof \ErrorException) {
$category .= ':' . $exception->getSeverity(); $category .= ':' . $exception->getSeverity();
} }

4
framework/base/Module.php

@ -496,7 +496,7 @@ class Module extends ServiceLocator
} }
if (strpos($route, '/') !== false) { if (strpos($route, '/') !== false) {
list ($id, $route) = explode('/', $route, 2); list($id, $route) = explode('/', $route, 2);
} else { } else {
$id = $route; $id = $route;
$route = ''; $route = '';
@ -563,7 +563,7 @@ class Module extends ServiceLocator
return null; return null;
} }
if (is_subclass_of($className, 'yii\base\Controller')) { if (is_subclass_of($className, Controller::class)) {
$controller = Yii::createObject($className, [$id, $this]); $controller = Yii::createObject($className, [$id, $this]);
return get_class($controller) === $className ? $controller : null; return get_class($controller) === $className ? $controller : null;
} elseif (YII_DEBUG) { } elseif (YII_DEBUG) {

6
framework/base/View.php

@ -58,8 +58,8 @@ class View extends Component
* *
* ```php * ```php
* [ * [
* 'tpl' => ['class' => 'yii\smarty\ViewRenderer'], * 'tpl' => ['class' => \yii\smarty\ViewRenderer::class],
* 'twig' => ['class' => 'yii\twig\ViewRenderer'], * 'twig' => ['class' => \yii\twig\ViewRenderer::class],
* ] * ]
* ``` * ```
* *
@ -111,7 +111,7 @@ class View extends Component
parent::init(); parent::init();
if (is_array($this->theme)) { if (is_array($this->theme)) {
if (!isset($this->theme['class'])) { if (!isset($this->theme['class'])) {
$this->theme['class'] = 'yii\base\Theme'; $this->theme['class'] = Theme::class;
} }
$this->theme = Yii::createObject($this->theme); $this->theme = Yii::createObject($this->theme);
} elseif (is_string($this->theme)) { } elseif (is_string($this->theme)) {

20
framework/captcha/CaptchaAsset.php

@ -8,6 +8,7 @@
namespace yii\captcha; namespace yii\captcha;
use yii\web\AssetBundle; use yii\web\AssetBundle;
use yii\web\YiiAsset;
/** /**
* This asset bundle provides the javascript files needed for the [[Captcha]] widget. * This asset bundle provides the javascript files needed for the [[Captcha]] widget.
@ -17,11 +18,18 @@ use yii\web\AssetBundle;
*/ */
class CaptchaAsset extends AssetBundle class CaptchaAsset extends AssetBundle
{ {
/**
* @inheritdoc
*/
public $sourcePath = '@yii/assets'; public $sourcePath = '@yii/assets';
public $js = [
'yii.captcha.js', /**
]; * @inheritdoc
public $depends = [ */
'yii\web\YiiAsset', public $js = ['yii.captcha.js',];
];
/**
* @inheritdoc
*/
public $depends = [YiiAsset::class];
} }

24
framework/console/Application.php

@ -127,7 +127,7 @@ class Application extends \yii\base\Application
} }
// ensure we have the 'help' command so that we can list the available commands // ensure we have the 'help' command so that we can list the available commands
if (!isset($this->controllerMap['help'])) { if (!isset($this->controllerMap['help'])) {
$this->controllerMap['help'] = 'yii\console\controllers\HelpController'; $this->controllerMap['help'] = controllers\HelpController::class;
} }
} }
@ -138,7 +138,7 @@ class Application extends \yii\base\Application
*/ */
public function handleRequest($request) public function handleRequest($request)
{ {
list ($route, $params) = $request->resolve(); list($route, $params) = $request->resolve();
$this->requestedRoute = $route; $this->requestedRoute = $route;
$result = $this->runAction($route, $params); $result = $this->runAction($route, $params);
if ($result instanceof Response) { if ($result instanceof Response) {
@ -187,13 +187,13 @@ class Application extends \yii\base\Application
public function coreCommands() public function coreCommands()
{ {
return [ return [
'asset' => 'yii\console\controllers\AssetController', 'asset' => controllers\AssetController::class,
'cache' => 'yii\console\controllers\CacheController', 'cache' => controllers\CacheController::class,
'fixture' => 'yii\console\controllers\FixtureController', 'fixture' => controllers\FixtureController::class,
'help' => 'yii\console\controllers\HelpController', 'help' => controllers\HelpController::class,
'message' => 'yii\console\controllers\MessageController', 'message' => controllers\MessageController::class,
'migrate' => 'yii\console\controllers\MigrateController', 'migrate' => controllers\MigrateController::class,
'serve' => 'yii\console\controllers\ServeController', 'serve' => controllers\ServeController::class,
]; ];
} }
@ -203,9 +203,9 @@ class Application extends \yii\base\Application
public function coreComponents() public function coreComponents()
{ {
return array_merge(parent::coreComponents(), [ return array_merge(parent::coreComponents(), [
'request' => ['class' => 'yii\console\Request'], 'request' => ['class' => Request::class],
'response' => ['class' => 'yii\console\Response'], 'response' => ['class' => Response::class],
'errorHandler' => ['class' => 'yii\console\ErrorHandler'], 'errorHandler' => ['class' => ErrorHandler::class],
]); ]);
} }
} }

25
framework/console/controllers/AssetController.php

@ -14,6 +14,7 @@ use yii\helpers\Console;
use yii\helpers\FileHelper; use yii\helpers\FileHelper;
use yii\helpers\VarDumper; use yii\helpers\VarDumper;
use yii\web\AssetBundle; use yii\web\AssetBundle;
use yii\web\AssetManager;
/** /**
* Allows you to combine and compress your JavaScript and CSS files. * Allows you to combine and compress your JavaScript and CSS files.
@ -37,7 +38,7 @@ use yii\web\AssetBundle;
* Note: by default this command relies on an external tools to perform actual files compression, * Note: by default this command relies on an external tools to perform actual files compression,
* check [[jsCompressor]] and [[cssCompressor]] for more details. * check [[jsCompressor]] and [[cssCompressor]] for more details.
* *
* @property \yii\web\AssetManager $assetManager Asset manager instance. Note that the type of this property * @property AssetManager $assetManager Asset manager instance. Note that the type of this property
* differs in getter and setter. See [[getAssetManager()]] and [[setAssetManager()]] for details. * differs in getter and setter. See [[getAssetManager()]] and [[setAssetManager()]] for details.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
@ -80,8 +81,8 @@ class AssetController extends Controller
* 'css' => 'css/all-shared-{hash}.css', * 'css' => 'css/all-shared-{hash}.css',
* 'depends' => [ * 'depends' => [
* // Include all assets shared between 'backend' and 'frontend' * // Include all assets shared between 'backend' and 'frontend'
* 'yii\web\YiiAsset', * \yii\web\YiiAsset::class,
* 'app\assets\SharedAsset', * \app\assets\SharedAsset::class,
* ], * ],
* ], * ],
* 'allBackEnd' => [ * 'allBackEnd' => [
@ -89,7 +90,7 @@ class AssetController extends Controller
* 'css' => 'css/all-{hash}.css', * 'css' => 'css/all-{hash}.css',
* 'depends' => [ * 'depends' => [
* // Include only 'backend' assets: * // Include only 'backend' assets:
* 'app\assets\AdminAsset' * \app\assets\AdminAsset::class
* ], * ],
* ], * ],
* 'allFrontEnd' => [ * 'allFrontEnd' => [
@ -122,7 +123,7 @@ class AssetController extends Controller
public $cssCompressor = 'java -jar yuicompressor.jar --type css {from} -o {to}'; public $cssCompressor = 'java -jar yuicompressor.jar --type css {from} -o {to}';
/** /**
* @var array|\yii\web\AssetManager [[\yii\web\AssetManager]] instance or its array configuration, which will be used * @var array|AssetManager [[AssetManager]] instance or its array configuration, which will be used
* for assets processing. * for assets processing.
*/ */
private $_assetManager = []; private $_assetManager = [];
@ -137,8 +138,8 @@ class AssetController extends Controller
{ {
if (!is_object($this->_assetManager)) { if (!is_object($this->_assetManager)) {
$options = $this->_assetManager; $options = $this->_assetManager;
if (!isset($options['class'])) { if (empty($options['class'])) {
$options['class'] = 'yii\\web\\AssetManager'; $options['class'] = AssetManager::class;
} }
if (!isset($options['basePath'])) { if (!isset($options['basePath'])) {
throw new Exception("Please specify 'basePath' for the 'assetManager' option."); throw new Exception("Please specify 'basePath' for the 'assetManager' option.");
@ -154,8 +155,8 @@ class AssetController extends Controller
/** /**
* Sets asset manager instance or configuration. * Sets asset manager instance or configuration.
* @param \yii\web\AssetManager|array $assetManager asset manager instance or its array configuration. * @param AssetManager|array $assetManager asset manager instance or its array configuration.
* @throws \yii\console\Exception on invalid argument type. * @throws Exception on invalid argument type.
*/ */
public function setAssetManager($assetManager) public function setAssetManager($assetManager)
{ {
@ -403,7 +404,7 @@ class AssetController extends Controller
$depends[] = $target; $depends[] = $target;
} }
$targets[$bundle] = Yii::createObject([ $targets[$bundle] = Yii::createObject([
'class' => strpos($bundle, '\\') !== false ? $bundle : 'yii\\web\\AssetBundle', 'class' => strpos($bundle, '\\') !== false ? $bundle : AssetBundle::class,
'depends' => $depends, 'depends' => $depends,
]); ]);
} }
@ -686,8 +687,8 @@ return [
// The list of asset bundles to compress: // The list of asset bundles to compress:
'bundles' => [ 'bundles' => [
// 'app\assets\AppAsset', // 'app\assets\AppAsset',
// 'yii\web\YiiAsset', // \yii\web\YiiAsset::class,
// 'yii\web\JqueryAsset', // \yii\web\JqueryAsset::class,
], ],
// Asset bundle for compression output: // Asset bundle for compression output:
'targets' => [ 'targets' => [

12
framework/console/controllers/FixtureController.php

@ -13,6 +13,7 @@ use yii\console\Exception;
use yii\helpers\Console; use yii\helpers\Console;
use yii\helpers\FileHelper; use yii\helpers\FileHelper;
use yii\test\FixtureTrait; use yii\test\FixtureTrait;
use yii\test\InitDb;
/** /**
* Manages fixture data loading and unloading. * Manages fixture data loading and unloading.
@ -55,9 +56,7 @@ class FixtureController extends Controller
* @var array global fixtures that should be applied when loading and unloading. By default it is set to `InitDbFixture` * @var array global fixtures that should be applied when loading and unloading. By default it is set to `InitDbFixture`
* that disables and enables integrity check, so your data can be safely loaded. * that disables and enables integrity check, so your data can be safely loaded.
*/ */
public $globalFixtures = [ public $globalFixtures = [InitDb::class];
'yii\test\InitDb',
];
/** /**
@ -116,7 +115,6 @@ class FixtureController extends Controller
$except = $filtered['except']; $except = $filtered['except'];
if (!$this->needToApplyAll($fixturesInput[0])) { if (!$this->needToApplyAll($fixturesInput[0])) {
$fixtures = $filtered['apply']; $fixtures = $filtered['apply'];
$foundFixtures = $this->findFixtures($fixtures); $foundFixtures = $this->findFixtures($fixtures);
@ -125,7 +123,6 @@ class FixtureController extends Controller
if ($notFoundFixtures) { if ($notFoundFixtures) {
$this->notifyNotFound($notFoundFixtures); $this->notifyNotFound($notFoundFixtures);
} }
} else { } else {
$foundFixtures = $this->findFixtures(); $foundFixtures = $this->findFixtures();
} }
@ -187,7 +184,6 @@ class FixtureController extends Controller
$except = $filtered['except']; $except = $filtered['except'];
if (!$this->needToApplyAll($fixturesInput[0])) { if (!$this->needToApplyAll($fixturesInput[0])) {
$fixtures = $filtered['apply']; $fixtures = $filtered['apply'];
$foundFixtures = $this->findFixtures($fixtures); $foundFixtures = $this->findFixtures($fixtures);
@ -196,7 +192,6 @@ class FixtureController extends Controller
if ($notFoundFixtures) { if ($notFoundFixtures) {
$this->notifyNotFound($notFoundFixtures); $this->notifyNotFound($notFoundFixtures);
} }
} else { } else {
$foundFixtures = $this->findFixtures(); $foundFixtures = $this->findFixtures();
} }
@ -404,7 +399,6 @@ class FixtureController extends Controller
$findAll = ($fixtures === []); $findAll = ($fixtures === []);
if (!$findAll) { if (!$findAll) {
$filesToSearch = []; $filesToSearch = [];
foreach ($fixtures as $fileName) { foreach ($fixtures as $fileName) {
@ -432,7 +426,6 @@ class FixtureController extends Controller
$config = []; $config = [];
foreach ($fixtures as $fixture) { foreach ($fixtures as $fixture) {
$isNamespaced = (strpos($fixture, '\\') !== false); $isNamespaced = (strpos($fixture, '\\') !== false);
$fullClassName = $isNamespaced ? $fixture . 'Fixture' : $this->namespace . '\\' . $fixture . 'Fixture'; $fullClassName = $isNamespaced ? $fixture . 'Fixture' : $this->namespace . '\\' . $fixture . 'Fixture';
@ -490,5 +483,4 @@ class FixtureController extends Controller
{ {
return Yii::getAlias('@' . str_replace('\\', '/', $this->namespace)); return Yii::getAlias('@' . str_replace('\\', '/', $this->namespace));
} }
} }

8
framework/console/controllers/HelpController.php

@ -170,7 +170,7 @@ class HelpController extends Controller
{ {
if (class_exists($controllerClass)) { if (class_exists($controllerClass)) {
$class = new \ReflectionClass($controllerClass); $class = new \ReflectionClass($controllerClass);
return !$class->isAbstract() && $class->isSubclassOf('yii\console\Controller'); return !$class->isAbstract() && $class->isSubclassOf(Controller::class);
} else { } else {
return false; return false;
} }
@ -268,14 +268,14 @@ class HelpController extends Controller
$maxlen = 5; $maxlen = 5;
foreach ($actions as $action) { foreach ($actions as $action) {
$len = strlen($prefix.'/'.$action) + 2 + ($action === $controller->defaultAction ? 10 : 0); $len = strlen($prefix . '/' . $action) + 2 + ($action === $controller->defaultAction ? 10 : 0);
if ($maxlen < $len) { if ($maxlen < $len) {
$maxlen = $len; $maxlen = $len;
} }
} }
foreach ($actions as $action) { foreach ($actions as $action) {
$this->stdout('- ' . $this->ansiFormat($prefix.'/'.$action, Console::FG_YELLOW)); $this->stdout('- ' . $this->ansiFormat($prefix . '/' . $action, Console::FG_YELLOW));
$len = strlen($prefix.'/'.$action) + 2; $len = strlen($prefix . '/' . $action) + 2;
if ($action === $controller->defaultAction) { if ($action === $controller->defaultAction) {
$this->stdout(' (default)', Console::FG_GREEN); $this->stdout(' (default)', Console::FG_GREEN);
$len += 10; $len += 10;

8
framework/data/BaseDataProvider.php

@ -179,8 +179,8 @@ abstract class BaseDataProvider extends Component implements DataProviderInterfa
* @param array|Pagination|boolean $value the pagination to be used by this data provider. * @param array|Pagination|boolean $value the pagination to be used by this data provider.
* This can be one of the following: * This can be one of the following:
* *
* - a configuration array for creating the pagination object. The "class" element defaults * - a configuration array for creating the pagination object. The
* to 'yii\data\Pagination' * "class" element defaults to `yii\data\Pagination`
* - an instance of [[Pagination]] or its subclass * - an instance of [[Pagination]] or its subclass
* - false, if pagination needs to be disabled. * - false, if pagination needs to be disabled.
* *
@ -219,8 +219,8 @@ abstract class BaseDataProvider extends Component implements DataProviderInterfa
* @param array|Sort|boolean $value the sort definition to be used by this data provider. * @param array|Sort|boolean $value the sort definition to be used by this data provider.
* This can be one of the following: * This can be one of the following:
* *
* - a configuration array for creating the sort definition object. The "class" element defaults * - a configuration array for creating the sort definition object. The
* to 'yii\data\Sort' * "class" element defaults to `yii\data\Sort`
* - an instance of [[Sort]] or its subclass * - an instance of [[Sort]] or its subclass
* - false, if sorting needs to be disabled. * - false, if sorting needs to be disabled.
* *

26
framework/db/Connection.php

@ -269,16 +269,16 @@ class Connection extends Component
* [[Schema]] class to support DBMS that is not supported by Yii. * [[Schema]] class to support DBMS that is not supported by Yii.
*/ */
public $schemaMap = [ public $schemaMap = [
'pgsql' => 'yii\db\pgsql\Schema', // PostgreSQL 'pgsql' => pgsql\Schema::class, // PostgreSQL
'mysqli' => 'yii\db\mysql\Schema', // MySQL 'mysqli' => mysql\Schema::class, // MySQL
'mysql' => 'yii\db\mysql\Schema', // MySQL 'mysql' => mysql\Schema::class, // MySQL
'sqlite' => 'yii\db\sqlite\Schema', // sqlite 3 'sqlite' => sqlite\Schema::class, // sqlite 3
'sqlite2' => 'yii\db\sqlite\Schema', // sqlite 2 'sqlite2' => sqlite\Schema::class, // sqlite 2
'sqlsrv' => 'yii\db\mssql\Schema', // newer MSSQL driver on MS Windows hosts 'sqlsrv' => mssql\Schema::class, // newer MSSQL driver on MS Windows hosts
'oci' => 'yii\db\oci\Schema', // Oracle driver 'oci' => oci\Schema::class, // Oracle driver
'mssql' => 'yii\db\mssql\Schema', // older MSSQL driver on MS Windows hosts 'mssql' => mssql\Schema::class, // older MSSQL driver on MS Windows hosts
'dblib' => 'yii\db\mssql\Schema', // dblib drivers on GNU/Linux (and maybe other OSes) hosts 'dblib' => mssql\Schema::class, // dblib drivers on GNU/Linux (and maybe other OSes) hosts
'cubrid' => 'yii\db\cubrid\Schema', // CUBRID 'cubrid' => cubrid\Schema::class, // CUBRID
]; ];
/** /**
* @var string Custom PDO wrapper class. If not set, it will use [[PDO]] or [[yii\db\mssql\PDO]] when MSSQL is used. * @var string Custom PDO wrapper class. If not set, it will use [[PDO]] or [[yii\db\mssql\PDO]] when MSSQL is used.
@ -291,7 +291,7 @@ class Connection extends Component
* @see createCommand * @see createCommand
* @since 2.0.7 * @since 2.0.7
*/ */
public $commandClass = 'yii\db\Command'; public $commandClass = Command::class;
/** /**
* @var boolean whether to enable [savepoint](http://en.wikipedia.org/wiki/Savepoint). * @var boolean whether to enable [savepoint](http://en.wikipedia.org/wiki/Savepoint).
* Note that if the underlying DBMS does not support savepoint, setting this property to be true will have no effect. * Note that if the underlying DBMS does not support savepoint, setting this property to be true will have no effect.
@ -586,9 +586,9 @@ class Connection extends Component
} }
if (isset($driver)) { if (isset($driver)) {
if ($driver === 'mssql' || $driver === 'dblib') { if ($driver === 'mssql' || $driver === 'dblib') {
$pdoClass = 'yii\db\mssql\PDO'; $pdoClass = mssql\PDO::class;
} elseif ($driver === 'sqlsrv') { } elseif ($driver === 'sqlsrv') {
$pdoClass = 'yii\db\mssql\SqlsrvPDO'; $pdoClass = mssql\SqlsrvPDO::class;
} }
} }
} }

7
framework/db/Schema.php

@ -74,7 +74,7 @@ abstract class Schema extends Object
* If left part is found in DB error message exception class from the right part is used. * If left part is found in DB error message exception class from the right part is used.
*/ */
public $exceptionMap = [ public $exceptionMap = [
'SQLSTATE[23' => 'yii\db\IntegrityException', 'SQLSTATE[23' => IntegrityException::class,
]; ];
/** /**
@ -101,7 +101,7 @@ abstract class Schema extends Object
*/ */
protected function createColumnSchema() protected function createColumnSchema()
{ {
return Yii::createObject('yii\db\ColumnSchema'); return Yii::createObject(ColumnSchema::class);
} }
/** /**
@ -508,7 +508,6 @@ abstract class Schema extends Object
} }
return implode('.', $parts); return implode('.', $parts);
} }
/** /**
@ -622,7 +621,7 @@ abstract class Schema extends Object
return $e; return $e;
} }
$exceptionClass = '\yii\db\Exception'; $exceptionClass = Exception::class;
foreach ($this->exceptionMap as $error => $class) { foreach ($this->exceptionMap as $error => $class) {
if (strpos($e->getMessage(), $error) !== false) { if (strpos($e->getMessage(), $error) !== false) {
$exceptionClass = $class; $exceptionClass = $class;

2
framework/db/cubrid/Schema.php

@ -69,7 +69,7 @@ class Schema extends \yii\db\Schema
* If left part is found in DB error message exception class from the right part is used. * If left part is found in DB error message exception class from the right part is used.
*/ */
public $exceptionMap = [ public $exceptionMap = [
'Operation would have caused one or more unique constraint violations' => 'yii\db\IntegrityException', 'Operation would have caused one or more unique constraint violations' => IntegrityException::class,
]; ];

6
framework/db/oci/Schema.php

@ -8,10 +8,11 @@
namespace yii\db\oci; namespace yii\db\oci;
use yii\base\InvalidCallException; use yii\base\InvalidCallException;
use yii\db\ColumnSchema;
use yii\db\Connection; use yii\db\Connection;
use yii\db\Expression; use yii\db\Expression;
use yii\db\IntegrityException;
use yii\db\TableSchema; use yii\db\TableSchema;
use yii\db\ColumnSchema;
/** /**
* Schema is the class for retrieving metadata from an Oracle database * Schema is the class for retrieving metadata from an Oracle database
@ -29,7 +30,7 @@ class Schema extends \yii\db\Schema
* If left part is found in DB error message exception class from the right part is used. * If left part is found in DB error message exception class from the right part is used.
*/ */
public $exceptionMap = [ public $exceptionMap = [
'ORA-00001: unique constraint' => 'yii\db\IntegrityException', 'ORA-00001: unique constraint' => IntegrityException::class,
]; ];
@ -177,7 +178,6 @@ SQL;
*/ */
protected function getTableSequenceName($tableName) protected function getTableSequenceName($tableName)
{ {
$seq_name_sql = <<<SQL $seq_name_sql = <<<SQL
SELECT ud.referenced_name as sequence_name SELECT ud.referenced_name as sequence_name
FROM user_dependencies ud FROM user_dependencies ud

5
framework/di/Container.php

@ -9,6 +9,7 @@ namespace yii\di;
use ReflectionClass; use ReflectionClass;
use Yii; use Yii;
use yii\base\Configurable;
use yii\base\Component; use yii\base\Component;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
@ -357,7 +358,7 @@ class Container extends Component
protected function build($class, $params, $config) protected function build($class, $params, $config)
{ {
/* @var $reflection ReflectionClass */ /* @var $reflection ReflectionClass */
list ($reflection, $dependencies) = $this->getDependencies($class); list($reflection, $dependencies) = $this->getDependencies($class);
foreach ($params as $index => $param) { foreach ($params as $index => $param) {
$dependencies[$index] = $param; $dependencies[$index] = $param;
@ -368,7 +369,7 @@ class Container extends Component
return $reflection->newInstanceArgs($dependencies); return $reflection->newInstanceArgs($dependencies);
} }
if (!empty($dependencies) && $reflection->implementsInterface('yii\base\Configurable')) { if (!empty($dependencies) && $reflection->implementsInterface(Configurable::class)) {
// set $config as the last parameter (existing one will be overwritten) // set $config as the last parameter (existing one will be overwritten)
$dependencies[count($dependencies) - 1] = $config; $dependencies[count($dependencies) - 1] = $config;
return $reflection->newInstanceArgs($dependencies); return $reflection->newInstanceArgs($dependencies);

2
framework/filters/AccessControl.php

@ -79,7 +79,7 @@ class AccessControl extends ActionFilter
* @var array the default configuration of access rules. Individual rule configurations * @var array the default configuration of access rules. Individual rule configurations
* specified via [[rules]] will take precedence when the same property of the rule is configured. * specified via [[rules]] will take precedence when the same property of the rule is configured.
*/ */
public $ruleConfig = ['class' => 'yii\filters\AccessRule']; public $ruleConfig = ['class' => AccessRule::class];
/** /**
* @var array a list of access rule objects or configuration arrays for creating the rule objects. * @var array a list of access rule objects or configuration arrays for creating the rule objects.
* If a rule is specified via a configuration array, it will be merged with [[ruleConfig]] first * If a rule is specified via a configuration array, it will be merged with [[ruleConfig]] first

6
framework/grid/GridView.php

@ -54,7 +54,7 @@ class GridView extends BaseListView
* @var string the default data column class if the class name is not explicitly specified when configuring a data column. * @var string the default data column class if the class name is not explicitly specified when configuring a data column.
* Defaults to 'yii\grid\DataColumn'. * Defaults to 'yii\grid\DataColumn'.
*/ */
public $dataColumnClass; public $dataColumnClass = DataColumn::class;
/** /**
* @var string the caption of the grid table * @var string the caption of the grid table
* @see captionOptions * @see captionOptions
@ -526,7 +526,7 @@ class GridView extends BaseListView
$column = $this->createDataColumn($column); $column = $this->createDataColumn($column);
} else { } else {
$column = Yii::createObject(array_merge([ $column = Yii::createObject(array_merge([
'class' => $this->dataColumnClass ? : DataColumn::class, 'class' => $this->dataColumnClass,
'grid' => $this, 'grid' => $this,
], $column)); ], $column));
} }
@ -551,7 +551,7 @@ class GridView extends BaseListView
} }
return Yii::createObject([ return Yii::createObject([
'class' => $this->dataColumnClass ? : DataColumn::class, 'class' => $this->dataColumnClass,
'grid' => $this, 'grid' => $this,
'attribute' => $matches[1], 'attribute' => $matches[1],
'format' => isset($matches[3]) ? $matches[3] : 'text', 'format' => isset($matches[3]) ? $matches[3] : 'text',

20
framework/grid/GridViewAsset.php

@ -8,6 +8,7 @@
namespace yii\grid; namespace yii\grid;
use yii\web\AssetBundle; use yii\web\AssetBundle;
use yii\web\YiiAsset;
/** /**
* This asset bundle provides the javascript files for the [[GridView]] widget. * This asset bundle provides the javascript files for the [[GridView]] widget.
@ -17,11 +18,18 @@ use yii\web\AssetBundle;
*/ */
class GridViewAsset extends AssetBundle class GridViewAsset extends AssetBundle
{ {
/**
* @inheritdoc
*/
public $sourcePath = '@yii/assets'; public $sourcePath = '@yii/assets';
public $js = [
'yii.gridView.js', /**
]; * @inheritdoc
public $depends = [ */
'yii\web\YiiAsset', public $js = ['yii.gridView.js'];
];
/**
* @inheritdoc
*/
public $depends = [YiiAsset::class];
} }

11
framework/log/Logger.php

@ -196,7 +196,7 @@ class Logger extends Component
* @param array $categories list of categories that you are interested in. * @param array $categories list of categories that you are interested in.
* You can use an asterisk at the end of a category to do a prefix match. * You can use an asterisk at the end of a category to do a prefix match.
* For example, 'yii\db\*' will match categories starting with 'yii\db\', * For example, 'yii\db\*' will match categories starting with 'yii\db\',
* such as 'yii\db\Connection'. * such as `yii\db\Connection`.
* @param array $excludeCategories list of categories that you want to exclude * @param array $excludeCategories list of categories that you want to exclude
* @return array the profiling results. Each element is an array consisting of these elements: * @return array the profiling results. Each element is an array consisting of these elements:
* `info`, `category`, `timestamp`, `trace`, `level`, `duration`. * `info`, `category`, `timestamp`, `trace`, `level`, `duration`.
@ -247,7 +247,10 @@ class Logger extends Component
*/ */
public function getDbProfiling() public function getDbProfiling()
{ {
$timings = $this->getProfiling(['yii\db\Command::query', 'yii\db\Command::execute']); $timings = $this->getProfiling([
'yii\db\Command::query',
'yii\db\Command::execute',
]);
$count = count($timings); $count = count($timings);
$time = 0; $time = 0;
foreach ($timings as $timing) { foreach ($timings as $timing) {
@ -271,9 +274,9 @@ class Logger extends Component
foreach ($messages as $i => $log) { foreach ($messages as $i => $log) {
list($token, $level, $category, $timestamp, $traces) = $log; list($token, $level, $category, $timestamp, $traces) = $log;
$log[5] = $i; $log[5] = $i;
if ($level == Logger::LEVEL_PROFILE_BEGIN) { if ($level == self::LEVEL_PROFILE_BEGIN) {
$stack[] = $log; $stack[] = $log;
} elseif ($level == Logger::LEVEL_PROFILE_END) { } elseif ($level == self::LEVEL_PROFILE_END) {
if (($last = array_pop($stack)) !== null && $last[0] === $token) { if (($last = array_pop($stack)) !== null && $last[0] === $token) {
$timings[$last[5]] = [ $timings[$last[5]] = [
'info' => $last[0], 'info' => $last[0],

4
framework/log/Target.php

@ -41,7 +41,7 @@ abstract class Target extends Component
* @var array list of message categories that this target is interested in. Defaults to empty, meaning all categories. * @var array list of message categories that this target is interested in. Defaults to empty, meaning all categories.
* You can use an asterisk at the end of a category so that the category may be used to * You can use an asterisk at the end of a category so that the category may be used to
* match those categories sharing the same common prefix. For example, 'yii\db\*' will match * match those categories sharing the same common prefix. For example, 'yii\db\*' will match
* categories starting with 'yii\db\', such as 'yii\db\Connection'. * categories starting with 'yii\db\', such as `yii\db\Connection`.
*/ */
public $categories = []; public $categories = [];
/** /**
@ -49,7 +49,7 @@ abstract class Target extends Component
* If this property is not empty, then any category listed here will be excluded from [[categories]]. * If this property is not empty, then any category listed here will be excluded from [[categories]].
* You can use an asterisk at the end of a category so that the category can be used to * You can use an asterisk at the end of a category so that the category can be used to
* match those categories sharing the same common prefix. For example, 'yii\db\*' will match * match those categories sharing the same common prefix. For example, 'yii\db\*' will match
* categories starting with 'yii\db\', such as 'yii\db\Connection'. * categories starting with 'yii\db\', such as `yii\db\Connection`.
* @see categories * @see categories
*/ */
public $except = []; public $except = [];

2
framework/mail/BaseMailer.php

@ -73,7 +73,7 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont
/** /**
* @var string the default class name of the new message instances created by [[createMessage()]] * @var string the default class name of the new message instances created by [[createMessage()]]
*/ */
public $messageClass = 'yii\mail\BaseMessage'; public $messageClass = BaseMessage::class;
/** /**
* @var boolean whether to save email messages as files under [[fileTransportPath]] instead of sending them * @var boolean whether to save email messages as files under [[fileTransportPath]] instead of sending them
* to the actual recipients. This is usually used during development for debugging purpose. * to the actual recipients. This is usually used during development for debugging purpose.

2
framework/mutex/FileMutex.php

@ -21,7 +21,7 @@ use yii\helpers\FileHelper;
* [ * [
* 'components' => [ * 'components' => [
* 'mutex' => [ * 'mutex' => [
* 'class' => 'yii\mutex\FileMutex' * 'class' => \yii\mutex\FileMutex::class,
* ], * ],
* ], * ],
* ] * ]

4
framework/rest/Controller.php

@ -33,13 +33,13 @@ class Controller extends \yii\web\Controller
/** /**
* @var string|array the configuration for creating the serializer that formats the response data. * @var string|array the configuration for creating the serializer that formats the response data.
*/ */
public $serializer = 'yii\rest\Serializer'; public $serializer = Serializer::class;
/** /**
* @inheritdoc * @inheritdoc
*/ */
public $enableCsrfValidation = false; public $enableCsrfValidation = false;
/** /**
* @inheritdoc * @inheritdoc
*/ */

20
framework/validators/ValidationAsset.php

@ -8,6 +8,7 @@
namespace yii\validators; namespace yii\validators;
use yii\web\AssetBundle; use yii\web\AssetBundle;
use yii\web\YiiAsset;
/** /**
* This asset bundle provides the javascript files for client validation. * This asset bundle provides the javascript files for client validation.
@ -17,11 +18,18 @@ use yii\web\AssetBundle;
*/ */
class ValidationAsset extends AssetBundle class ValidationAsset extends AssetBundle
{ {
/**
* @inheritdoc
*/
public $sourcePath = '@yii/assets'; public $sourcePath = '@yii/assets';
public $js = [
'yii.validation.js', /**
]; * @inheritdoc
public $depends = [ */
'yii\web\YiiAsset', public $js = ['yii.validation.js'];
];
/**
* @inheritdoc
*/
public $depends = [YiiAsset::class];
} }

42
framework/validators/Validator.php

@ -53,36 +53,36 @@ class Validator extends Component
* @var array list of built-in validators (name => class or configuration) * @var array list of built-in validators (name => class or configuration)
*/ */
public static $builtInValidators = [ public static $builtInValidators = [
'boolean' => 'yii\validators\BooleanValidator', 'boolean' => BooleanValidator::class,
'captcha' => 'yii\captcha\CaptchaValidator', 'captcha' => \yii\captcha\CaptchaValidator::class,
'compare' => 'yii\validators\CompareValidator', 'compare' => CompareValidator::class,
'date' => 'yii\validators\DateValidator', 'date' => DateValidator::class,
'default' => 'yii\validators\DefaultValueValidator', 'default' => DefaultValueValidator::class,
'double' => 'yii\validators\NumberValidator', 'double' => NumberValidator::class,
'each' => 'yii\validators\EachValidator', 'each' => EachValidator::class,
'email' => 'yii\validators\EmailValidator', 'email' => EmailValidator::class,
'exist' => 'yii\validators\ExistValidator', 'exist' => ExistValidator::class,
'file' => 'yii\validators\FileValidator', 'file' => FileValidator::class,
'filter' => 'yii\validators\FilterValidator', 'filter' => FilterValidator::class,
'image' => 'yii\validators\ImageValidator', 'image' => ImageValidator::class,
'in' => 'yii\validators\RangeValidator', 'in' => RangeValidator::class,
'integer' => [ 'integer' => [
'class' => NumberValidator::class, 'class' => NumberValidator::class,
'integerOnly' => true, 'integerOnly' => true,
], ],
'match' => 'yii\validators\RegularExpressionValidator', 'match' => RegularExpressionValidator::class,
'number' => 'yii\validators\NumberValidator', 'number' => NumberValidator::class,
'required' => 'yii\validators\RequiredValidator', 'required' => RequiredValidator::class,
'safe' => 'yii\validators\SafeValidator', 'safe' => SafeValidator::class,
'string' => 'yii\validators\StringValidator', 'string' => StringValidator::class,
'trim' => [ 'trim' => [
'class' => FilterValidator::class, 'class' => FilterValidator::class,
'filter' => 'trim', 'filter' => 'trim',
'skipOnArray' => true, 'skipOnArray' => true,
], ],
'unique' => 'yii\validators\UniqueValidator', 'unique' => UniqueValidator::class,
'url' => 'yii\validators\UrlValidator', 'url' => UrlValidator::class,
'ip' => 'yii\validators\IpValidator', 'ip' => IpValidator::class,
]; ];
/** /**
* @var array|string attributes to be validated by this validator. For multiple attributes, * @var array|string attributes to be validated by this validator. For multiple attributes,

12
framework/web/Application.php

@ -72,7 +72,7 @@ class Application extends \yii\base\Application
public function handleRequest($request) public function handleRequest($request)
{ {
if (empty($this->catchAll)) { if (empty($this->catchAll)) {
list ($route, $params) = $request->resolve(); list($route, $params) = $request->resolve();
} else { } else {
$route = $this->catchAll[0]; $route = $this->catchAll[0];
$params = $this->catchAll; $params = $this->catchAll;
@ -147,11 +147,11 @@ class Application extends \yii\base\Application
public function coreComponents() public function coreComponents()
{ {
return array_merge(parent::coreComponents(), [ return array_merge(parent::coreComponents(), [
'request' => ['class' => 'yii\web\Request'], 'request' => ['class' => Request::class],
'response' => ['class' => 'yii\web\Response'], 'response' => ['class' => Response::class],
'session' => ['class' => 'yii\web\Session'], 'session' => ['class' => Session::class],
'user' => ['class' => 'yii\web\User'], 'user' => ['class' => User::class],
'errorHandler' => ['class' => 'yii\web\ErrorHandler'], 'errorHandler' => ['class' => ErrorHandler::class],
]); ]);
} }
} }

6
framework/web/AssetBundle.php

@ -66,8 +66,8 @@ class AssetBundle extends Object
* *
* ```php * ```php
* public $depends = [ * public $depends = [
* 'yii\web\YiiAsset', * \yii\web\YiiAsset::class,
* 'yii\bootstrap\BootstrapAsset', * \yii\bootstrap\BootstrapAsset::class,
* ]; * ];
* ``` * ```
*/ */
@ -180,7 +180,7 @@ class AssetBundle extends Object
public function publish($am) public function publish($am)
{ {
if ($this->sourcePath !== null && !isset($this->basePath, $this->baseUrl)) { if ($this->sourcePath !== null && !isset($this->basePath, $this->baseUrl)) {
list ($this->basePath, $this->baseUrl) = $am->publish($this->sourcePath, $this->publishOptions); list($this->basePath, $this->baseUrl) = $am->publish($this->sourcePath, $this->publishOptions);
} }
if (isset($this->basePath, $this->baseUrl) && ($converter = $am->getConverter()) !== null) { if (isset($this->basePath, $this->baseUrl) && ($converter = $am->getConverter()) !== null) {

2
framework/web/AssetManager.php

@ -56,7 +56,7 @@ class AssetManager extends Component
* *
* ```php * ```php
* [ * [
* 'yii\bootstrap\BootstrapAsset' => [ * \yii\bootstrap\BootstrapAsset::class => [
* 'css' => [], * 'css' => [],
* ], * ],
* ] * ]

2
framework/web/ErrorAction.php

@ -24,7 +24,7 @@ use yii\base\UserException;
* public function actions() * public function actions()
* { * {
* return [ * return [
* 'error' => ['class' => 'yii\web\ErrorAction'], * 'error' => ['class' => \yii\web\ErrorAction::class,
* ]; * ];
* } * }
* ``` * ```

2
framework/web/GroupUrlRule.php

@ -69,7 +69,7 @@ class GroupUrlRule extends CompositeUrlRule
* @var array the default configuration of URL rules. Individual rule configurations * @var array the default configuration of URL rules. Individual rule configurations
* specified via [[rules]] will take precedence when the same property of the rule is configured. * specified via [[rules]] will take precedence when the same property of the rule is configured.
*/ */
public $ruleConfig = ['class' => 'yii\web\UrlRule']; public $ruleConfig = ['class' => UrlRule::class];
/** /**

2
framework/web/JsonParser.php

@ -18,7 +18,7 @@ use yii\helpers\Json;
* ```php * ```php
* 'request' => [ * 'request' => [
* 'parsers' => [ * 'parsers' => [
* 'application/json' => 'yii\web\JsonParser', * 'application/json' => \yii\web\JsonParser::class,
* ] * ]
* ] * ]
* ``` * ```

12
framework/web/Request.php

@ -148,7 +148,7 @@ class Request extends \yii\base\Request
* *
* ``` * ```
* [ * [
* 'application/json' => 'yii\web\JsonParser', * 'application/json' => \yii\web\JsonParser::class,
* ] * ]
* ``` * ```
* *
@ -178,7 +178,7 @@ class Request extends \yii\base\Request
{ {
$result = Yii::$app->getUrlManager()->parseRequest($this); $result = Yii::$app->getUrlManager()->parseRequest($this);
if ($result !== false) { if ($result !== false) {
list ($route, $params) = $result; list($route, $params) = $result;
if ($this->_queryParams === null) { if ($this->_queryParams === null) {
$_GET = $params + $_GET; // preserve numeric keys $_GET = $params + $_GET; // preserve numeric keys
} else { } else {
@ -231,15 +231,15 @@ class Request extends \yii\base\Request
if (isset($_POST[$this->methodParam])) { if (isset($_POST[$this->methodParam])) {
return strtoupper($_POST[$this->methodParam]); return strtoupper($_POST[$this->methodParam]);
} }
if (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) { if (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
return strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']); return strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
} }
if (isset($_SERVER['REQUEST_METHOD'])) { if (isset($_SERVER['REQUEST_METHOD'])) {
return strtoupper($_SERVER['REQUEST_METHOD']); return strtoupper($_SERVER['REQUEST_METHOD']);
} }
return 'GET'; return 'GET';
} }
@ -1101,7 +1101,7 @@ class Request extends \yii\base\Request
]; ];
foreach ($params as $param) { foreach ($params as $param) {
if (strpos($param, '=') !== false) { if (strpos($param, '=') !== false) {
list ($key, $value) = explode('=', $param, 2); list($key, $value) = explode('=', $param, 2);
if ($key === 'q') { if ($key === 'q') {
$values['q'][2] = (double) $value; $values['q'][2] = (double) $value;
} else { } else {

2
framework/web/UrlManager.php

@ -124,7 +124,7 @@ class UrlManager extends Component
* @var array the default configuration of URL rules. Individual rule configurations * @var array the default configuration of URL rules. Individual rule configurations
* specified via [[rules]] will take precedence when the same property of the rule is configured. * specified via [[rules]] will take precedence when the same property of the rule is configured.
*/ */
public $ruleConfig = ['class' => 'yii\web\UrlRule']; public $ruleConfig = ['class' => UrlRule::class];
/** /**
* @var string the cache key for cached rules * @var string the cache key for cached rules

20
framework/web/YiiAsset.php

@ -15,11 +15,19 @@ namespace yii\web;
*/ */
class YiiAsset extends AssetBundle class YiiAsset extends AssetBundle
{ {
/**
* @inheritdoc
*/
public $sourcePath = '@yii/assets'; public $sourcePath = '@yii/assets';
public $js = [
'yii.js', /**
]; * @inheritdoc
public $depends = [ */
'yii\web\JqueryAsset', public $js = ['yii.js',];
];
/**
* @inheritdoc
*/
public $depends = [JqueryAsset::class];
} }

2
framework/widgets/ActiveForm.php

@ -54,7 +54,7 @@ class ActiveForm extends Widget
* @var string the default field class name when calling [[field()]] to create a new field. * @var string the default field class name when calling [[field()]] to create a new field.
* @see fieldConfig * @see fieldConfig
*/ */
public $fieldClass = 'yii\widgets\ActiveField'; public $fieldClass = ActiveField::class;
/** /**
* @var array|\Closure the default configuration used by [[field()]] when creating a new field object. * @var array|\Closure the default configuration used by [[field()]] when creating a new field object.
* This can be either a configuration array or an anonymous function returning a configuration array. * This can be either a configuration array or an anonymous function returning a configuration array.

20
framework/widgets/ActiveFormAsset.php

@ -8,6 +8,7 @@
namespace yii\widgets; namespace yii\widgets;
use yii\web\AssetBundle; use yii\web\AssetBundle;
use yii\web\YiiAsset;
/** /**
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
@ -15,11 +16,18 @@ use yii\web\AssetBundle;
*/ */
class ActiveFormAsset extends AssetBundle class ActiveFormAsset extends AssetBundle
{ {
/**
* @inheritdoc
*/
public $sourcePath = '@yii/assets'; public $sourcePath = '@yii/assets';
public $js = [
'yii.activeForm.js', /**
]; * @inheritdoc
public $depends = [ */
'yii\web\YiiAsset', public $js = ['yii.activeForm.js'];
];
/**
* @inheritdoc
*/
public $depends = [YiiAsset::class];
} }

20
framework/widgets/MaskedInputAsset.php

@ -8,6 +8,7 @@
namespace yii\widgets; namespace yii\widgets;
use yii\web\AssetBundle; use yii\web\AssetBundle;
use yii\web\YiiAsset;
/** /**
* The asset bundle for the [[MaskedInput]] widget. * The asset bundle for the [[MaskedInput]] widget.
@ -19,11 +20,18 @@ use yii\web\AssetBundle;
*/ */
class MaskedInputAsset extends AssetBundle class MaskedInputAsset extends AssetBundle
{ {
/**
* @inheritdoc
*/
public $sourcePath = '@bower/jquery.inputmask/dist'; public $sourcePath = '@bower/jquery.inputmask/dist';
public $js = [
'jquery.inputmask.bundle.js' /**
]; * @inheritdoc
public $depends = [ */
'yii\web\YiiAsset' public $js = ['jquery.inputmask.bundle.js'];
];
/**
* @inheritdoc
*/
public $depends = [YiiAsset::class];
} }

20
framework/widgets/PjaxAsset.php

@ -8,6 +8,7 @@
namespace yii\widgets; namespace yii\widgets;
use yii\web\AssetBundle; use yii\web\AssetBundle;
use yii\web\YiiAsset;
/** /**
* This asset bundle provides the javascript files required by [[Pjax]] widget. * This asset bundle provides the javascript files required by [[Pjax]] widget.
@ -17,11 +18,18 @@ use yii\web\AssetBundle;
*/ */
class PjaxAsset extends AssetBundle class PjaxAsset extends AssetBundle
{ {
/**
* @inheritdoc
*/
public $sourcePath = '@bower/yii2-pjax'; public $sourcePath = '@bower/yii2-pjax';
public $js = [
'jquery.pjax.js', /**
]; * @inheritdoc
public $depends = [ */
'yii\web\YiiAsset', public $js = ['jquery.pjax.js',];
];
/**
* @inheritdoc
*/
public $depends = [YiiAsset::class];
} }

Loading…
Cancel
Save