Browse Source

more changes

tags/3.0.0-alpha1
Angel Guevara 9 years ago
parent
commit
f978199fcc
  1. 4
      framework/BaseYii.php
  2. 20
      framework/base/Application.php
  3. 10
      framework/base/ErrorHandler.php
  4. 2
      framework/base/Module.php
  5. 6
      framework/base/View.php
  6. 20
      framework/captcha/CaptchaAsset.php
  7. 22
      framework/console/Application.php
  8. 25
      framework/console/controllers/AssetController.php
  9. 12
      framework/console/controllers/FixtureController.php
  10. 2
      framework/console/controllers/HelpController.php
  11. 8
      framework/data/BaseDataProvider.php
  12. 7
      framework/db/Schema.php
  13. 2
      framework/db/cubrid/Schema.php
  14. 6
      framework/db/oci/Schema.php
  15. 3
      framework/di/Container.php
  16. 2
      framework/filters/AccessControl.php
  17. 20
      framework/grid/GridViewAsset.php
  18. 11
      framework/log/Logger.php
  19. 4
      framework/log/Target.php
  20. 2
      framework/mutex/FileMutex.php
  21. 4
      framework/rest/Controller.php
  22. 20
      framework/validators/ValidationAsset.php
  23. 42
      framework/validators/Validator.php
  24. 10
      framework/web/Application.php
  25. 4
      framework/web/AssetBundle.php
  26. 2
      framework/web/AssetManager.php
  27. 2
      framework/web/ErrorAction.php
  28. 2
      framework/web/GroupUrlRule.php
  29. 2
      framework/web/JsonParser.php
  30. 2
      framework/web/Request.php
  31. 2
      framework/web/UrlManager.php
  32. 20
      framework/web/YiiAsset.php
  33. 20
      framework/widgets/ActiveFormAsset.php
  34. 20
      framework/widgets/MaskedInputAsset.php
  35. 20
      framework/widgets/PjaxAsset.php

4
framework/BaseYii.php

@ -303,7 +303,7 @@ class BaseYii
*
* ```php
* // 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
* $object = Yii::createObject([
@ -361,7 +361,7 @@ class BaseYii
if (self::$_logger !== null) {
return self::$_logger;
} 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()
{
try {
$this->state = self::STATE_BEFORE_REQUEST;
$this->trigger(self::EVENT_BEFORE_REQUEST);
@ -383,12 +382,9 @@ abstract class Application extends Module
$this->state = self::STATE_END;
return $response->exitStatus;
} catch (ExitException $e) {
$this->end($e->statusCode, isset($response) ? $response : null);
return $e->statusCode;
}
}
@ -616,14 +612,14 @@ abstract class Application extends Module
public function coreComponents()
{
return [
'log' => ['class' => 'yii\log\Dispatcher'],
'view' => ['class' => 'yii\web\View'],
'formatter' => ['class' => 'yii\i18n\Formatter'],
'i18n' => ['class' => 'yii\i18n\I18N'],
'mailer' => ['class' => 'yii\swiftmailer\Mailer'],
'urlManager' => ['class' => 'yii\web\UrlManager'],
'assetManager' => ['class' => 'yii\web\AssetManager'],
'security' => ['class' => 'yii\base\Security'],
'security' => ['class' => Security::class],
'formatter' => ['class' => \yii\i18n\Formatter::class],
'i18n' => ['class' => \yii\i18n\I18N::class],
'log' => ['class' => \yii\log\Dispatcher::class],
'mailer' => ['class' => \yii\swiftmailer\Mailer::class],
'assetManager' => ['class' => \yii\web\AssetManager::class],
'urlManager' => ['class' => \yii\web\UrlManager::class],
'view' => ['class' => \yii\web\View::class],
];
}

10
framework/base/ErrorHandler.php

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

2
framework/base/Module.php

@ -563,7 +563,7 @@ class Module extends ServiceLocator
return null;
}
if (is_subclass_of($className, 'yii\base\Controller')) {
if (is_subclass_of($className, Controller::class)) {
$controller = Yii::createObject($className, [$id, $this]);
return get_class($controller) === $className ? $controller : null;
} elseif (YII_DEBUG) {

6
framework/base/View.php

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

20
framework/captcha/CaptchaAsset.php

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

22
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
if (!isset($this->controllerMap['help'])) {
$this->controllerMap['help'] = 'yii\console\controllers\HelpController';
$this->controllerMap['help'] = controllers\HelpController::class;
}
}
@ -187,13 +187,13 @@ class Application extends \yii\base\Application
public function coreCommands()
{
return [
'asset' => 'yii\console\controllers\AssetController',
'cache' => 'yii\console\controllers\CacheController',
'fixture' => 'yii\console\controllers\FixtureController',
'help' => 'yii\console\controllers\HelpController',
'message' => 'yii\console\controllers\MessageController',
'migrate' => 'yii\console\controllers\MigrateController',
'serve' => 'yii\console\controllers\ServeController',
'asset' => controllers\AssetController::class,
'cache' => controllers\CacheController::class,
'fixture' => controllers\FixtureController::class,
'help' => controllers\HelpController::class,
'message' => controllers\MessageController::class,
'migrate' => controllers\MigrateController::class,
'serve' => controllers\ServeController::class,
];
}
@ -203,9 +203,9 @@ class Application extends \yii\base\Application
public function coreComponents()
{
return array_merge(parent::coreComponents(), [
'request' => ['class' => 'yii\console\Request'],
'response' => ['class' => 'yii\console\Response'],
'errorHandler' => ['class' => 'yii\console\ErrorHandler'],
'request' => ['class' => Request::class],
'response' => ['class' => Response::class],
'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\VarDumper;
use yii\web\AssetBundle;
use yii\web\AssetManager;
/**
* 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,
* 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.
*
* @author Qiang Xue <qiang.xue@gmail.com>
@ -80,8 +81,8 @@ class AssetController extends Controller
* 'css' => 'css/all-shared-{hash}.css',
* 'depends' => [
* // Include all assets shared between 'backend' and 'frontend'
* 'yii\web\YiiAsset',
* 'app\assets\SharedAsset',
* \yii\web\YiiAsset::class,
* \app\assets\SharedAsset::class,
* ],
* ],
* 'allBackEnd' => [
@ -89,7 +90,7 @@ class AssetController extends Controller
* 'css' => 'css/all-{hash}.css',
* 'depends' => [
* // Include only 'backend' assets:
* 'app\assets\AdminAsset'
* \app\assets\AdminAsset::class
* ],
* ],
* 'allFrontEnd' => [
@ -122,7 +123,7 @@ class AssetController extends Controller
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.
*/
private $_assetManager = [];
@ -137,8 +138,8 @@ class AssetController extends Controller
{
if (!is_object($this->_assetManager)) {
$options = $this->_assetManager;
if (!isset($options['class'])) {
$options['class'] = 'yii\\web\\AssetManager';
if (empty($options['class'])) {
$options['class'] = AssetManager::class;
}
if (!isset($options['basePath'])) {
throw new Exception("Please specify 'basePath' for the 'assetManager' option.");
@ -154,8 +155,8 @@ class AssetController extends Controller
/**
* Sets asset manager instance or configuration.
* @param \yii\web\AssetManager|array $assetManager asset manager instance or its array configuration.
* @throws \yii\console\Exception on invalid argument type.
* @param AssetManager|array $assetManager asset manager instance or its array configuration.
* @throws Exception on invalid argument type.
*/
public function setAssetManager($assetManager)
{
@ -403,7 +404,7 @@ class AssetController extends Controller
$depends[] = $target;
}
$targets[$bundle] = Yii::createObject([
'class' => strpos($bundle, '\\') !== false ? $bundle : 'yii\\web\\AssetBundle',
'class' => strpos($bundle, '\\') !== false ? $bundle : AssetBundle::class,
'depends' => $depends,
]);
}
@ -686,8 +687,8 @@ return [
// The list of asset bundles to compress:
'bundles' => [
// 'app\assets\AppAsset',
// 'yii\web\YiiAsset',
// 'yii\web\JqueryAsset',
// \yii\web\YiiAsset::class,
// \yii\web\JqueryAsset::class,
],
// Asset bundle for compression output:
'targets' => [

12
framework/console/controllers/FixtureController.php

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

2
framework/console/controllers/HelpController.php

@ -170,7 +170,7 @@ class HelpController extends Controller
{
if (class_exists($controllerClass)) {
$class = new \ReflectionClass($controllerClass);
return !$class->isAbstract() && $class->isSubclassOf('yii\console\Controller');
return !$class->isAbstract() && $class->isSubclassOf(Controller::class);
} else {
return false;
}

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.
* This can be one of the following:
*
* - a configuration array for creating the pagination object. The "class" element defaults
* to 'yii\data\Pagination'
* - a configuration array for creating the pagination object. The
* "class" element defaults to `yii\data\Pagination`
* - an instance of [[Pagination]] or its subclass
* - 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.
* This can be one of the following:
*
* - a configuration array for creating the sort definition object. The "class" element defaults
* to 'yii\data\Sort'
* - a configuration array for creating the sort definition object. The
* "class" element defaults to `yii\data\Sort`
* - an instance of [[Sort]] or its subclass
* - false, if sorting needs to be disabled.
*

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.
*/
public $exceptionMap = [
'SQLSTATE[23' => 'yii\db\IntegrityException',
'SQLSTATE[23' => IntegrityException::class,
];
/**
@ -101,7 +101,7 @@ abstract class Schema extends Object
*/
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);
}
/**
@ -622,7 +621,7 @@ abstract class Schema extends Object
return $e;
}
$exceptionClass = '\yii\db\Exception';
$exceptionClass = Exception::class;
foreach ($this->exceptionMap as $error => $class) {
if (strpos($e->getMessage(), $error) !== false) {
$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.
*/
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;
use yii\base\InvalidCallException;
use yii\db\ColumnSchema;
use yii\db\Connection;
use yii\db\Expression;
use yii\db\IntegrityException;
use yii\db\TableSchema;
use yii\db\ColumnSchema;
/**
* 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.
*/
public $exceptionMap = [
'ORA-00001: unique constraint' => 'yii\db\IntegrityException',
'ORA-00001: unique constraint' => IntegrityException::class,
];
@ -177,7 +178,6 @@ SQL;
*/
protected function getTableSequenceName($tableName)
{
$seq_name_sql = <<<SQL
SELECT ud.referenced_name as sequence_name
FROM user_dependencies ud

3
framework/di/Container.php

@ -9,6 +9,7 @@ namespace yii\di;
use ReflectionClass;
use Yii;
use yii\base\Configurable;
use yii\base\Component;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper;
@ -368,7 +369,7 @@ class Container extends Component
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)
$dependencies[count($dependencies) - 1] = $config;
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
* 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.
* If a rule is specified via a configuration array, it will be merged with [[ruleConfig]] first

20
framework/grid/GridViewAsset.php

@ -8,6 +8,7 @@
namespace yii\grid;
use yii\web\AssetBundle;
use yii\web\YiiAsset;
/**
* This asset bundle provides the javascript files for the [[GridView]] widget.
@ -17,11 +18,18 @@ use yii\web\AssetBundle;
*/
class GridViewAsset extends AssetBundle
{
/**
* @inheritdoc
*/
public $sourcePath = '@yii/assets';
public $js = [
'yii.gridView.js',
];
public $depends = [
'yii\web\YiiAsset',
];
/**
* @inheritdoc
*/
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.
* 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\',
* such as 'yii\db\Connection'.
* such as `yii\db\Connection`.
* @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:
* `info`, `category`, `timestamp`, `trace`, `level`, `duration`.
@ -247,7 +247,10 @@ class Logger extends Component
*/
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);
$time = 0;
foreach ($timings as $timing) {
@ -271,9 +274,9 @@ class Logger extends Component
foreach ($messages as $i => $log) {
list($token, $level, $category, $timestamp, $traces) = $log;
$log[5] = $i;
if ($level == Logger::LEVEL_PROFILE_BEGIN) {
if ($level == self::LEVEL_PROFILE_BEGIN) {
$stack[] = $log;
} elseif ($level == Logger::LEVEL_PROFILE_END) {
} elseif ($level == self::LEVEL_PROFILE_END) {
if (($last = array_pop($stack)) !== null && $last[0] === $token) {
$timings[$last[5]] = [
'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.
* 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
* categories starting with 'yii\db\', such as 'yii\db\Connection'.
* categories starting with 'yii\db\', such as `yii\db\Connection`.
*/
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]].
* 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
* categories starting with 'yii\db\', such as 'yii\db\Connection'.
* categories starting with 'yii\db\', such as `yii\db\Connection`.
* @see categories
*/
public $except = [];

2
framework/mutex/FileMutex.php

@ -21,7 +21,7 @@ use yii\helpers\FileHelper;
* [
* 'components' => [
* '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.
*/
public $serializer = 'yii\rest\Serializer';
public $serializer = Serializer::class;
/**
* @inheritdoc
*/
public $enableCsrfValidation = false;
/**
* @inheritdoc
*/

20
framework/validators/ValidationAsset.php

@ -8,6 +8,7 @@
namespace yii\validators;
use yii\web\AssetBundle;
use yii\web\YiiAsset;
/**
* This asset bundle provides the javascript files for client validation.
@ -17,11 +18,18 @@ use yii\web\AssetBundle;
*/
class ValidationAsset extends AssetBundle
{
/**
* @inheritdoc
*/
public $sourcePath = '@yii/assets';
public $js = [
'yii.validation.js',
];
public $depends = [
'yii\web\YiiAsset',
];
/**
* @inheritdoc
*/
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)
*/
public static $builtInValidators = [
'boolean' => 'yii\validators\BooleanValidator',
'captcha' => 'yii\captcha\CaptchaValidator',
'compare' => 'yii\validators\CompareValidator',
'date' => 'yii\validators\DateValidator',
'default' => 'yii\validators\DefaultValueValidator',
'double' => 'yii\validators\NumberValidator',
'each' => 'yii\validators\EachValidator',
'email' => 'yii\validators\EmailValidator',
'exist' => 'yii\validators\ExistValidator',
'file' => 'yii\validators\FileValidator',
'filter' => 'yii\validators\FilterValidator',
'image' => 'yii\validators\ImageValidator',
'in' => 'yii\validators\RangeValidator',
'boolean' => BooleanValidator::class,
'captcha' => \yii\captcha\CaptchaValidator::class,
'compare' => CompareValidator::class,
'date' => DateValidator::class,
'default' => DefaultValueValidator::class,
'double' => NumberValidator::class,
'each' => EachValidator::class,
'email' => EmailValidator::class,
'exist' => ExistValidator::class,
'file' => FileValidator::class,
'filter' => FilterValidator::class,
'image' => ImageValidator::class,
'in' => RangeValidator::class,
'integer' => [
'class' => NumberValidator::class,
'integerOnly' => true,
],
'match' => 'yii\validators\RegularExpressionValidator',
'number' => 'yii\validators\NumberValidator',
'required' => 'yii\validators\RequiredValidator',
'safe' => 'yii\validators\SafeValidator',
'string' => 'yii\validators\StringValidator',
'match' => RegularExpressionValidator::class,
'number' => NumberValidator::class,
'required' => RequiredValidator::class,
'safe' => SafeValidator::class,
'string' => StringValidator::class,
'trim' => [
'class' => FilterValidator::class,
'filter' => 'trim',
'skipOnArray' => true,
],
'unique' => 'yii\validators\UniqueValidator',
'url' => 'yii\validators\UrlValidator',
'ip' => 'yii\validators\IpValidator',
'unique' => UniqueValidator::class,
'url' => UrlValidator::class,
'ip' => IpValidator::class,
];
/**
* @var array|string attributes to be validated by this validator. For multiple attributes,

10
framework/web/Application.php

@ -147,11 +147,11 @@ class Application extends \yii\base\Application
public function coreComponents()
{
return array_merge(parent::coreComponents(), [
'request' => ['class' => 'yii\web\Request'],
'response' => ['class' => 'yii\web\Response'],
'session' => ['class' => 'yii\web\Session'],
'user' => ['class' => 'yii\web\User'],
'errorHandler' => ['class' => 'yii\web\ErrorHandler'],
'request' => ['class' => Request::class],
'response' => ['class' => Response::class],
'session' => ['class' => Session::class],
'user' => ['class' => User::class],
'errorHandler' => ['class' => ErrorHandler::class],
]);
}
}

4
framework/web/AssetBundle.php

@ -66,8 +66,8 @@ class AssetBundle extends Object
*
* ```php
* public $depends = [
* 'yii\web\YiiAsset',
* 'yii\bootstrap\BootstrapAsset',
* \yii\web\YiiAsset::class,
* \yii\bootstrap\BootstrapAsset::class,
* ];
* ```
*/

2
framework/web/AssetManager.php

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

2
framework/web/ErrorAction.php

@ -24,7 +24,7 @@ use yii\base\UserException;
* public function actions()
* {
* 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
* 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
* 'request' => [
* 'parsers' => [
* 'application/json' => 'yii\web\JsonParser',
* 'application/json' => \yii\web\JsonParser::class,
* ]
* ]
* ```

2
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,
* ]
* ```
*

2
framework/web/UrlManager.php

@ -124,7 +124,7 @@ class UrlManager extends Component
* @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.
*/
public $ruleConfig = ['class' => 'yii\web\UrlRule'];
public $ruleConfig = ['class' => UrlRule::class];
/**
* @var string the cache key for cached rules

20
framework/web/YiiAsset.php

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

20
framework/widgets/ActiveFormAsset.php

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

20
framework/widgets/MaskedInputAsset.php

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

20
framework/widgets/PjaxAsset.php

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

Loading…
Cancel
Save