Skip to content

Commit

Permalink
Remove deprecate className() method brach 2.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Jul 14, 2023
1 parent 9a5e2a5 commit 01fdf13
Show file tree
Hide file tree
Showing 142 changed files with 519 additions and 525 deletions.
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ Yii Framework 2 Change Log
- Enh: Added check to `yii\base\Model::formName()` to prevent source path disclosure when form is represented by an anonymous class (silverfire)
- Chg #15420: Handle OPTIONS request in `yii\filter\Cors` so the preflight check isn't passed trough authentication filters (michaelarnauts, leandrogehlen)
- Chg #15625: `yii\grid\DataColumn` boolean filter dropdown list values are now in reversed order (bizley)
- Chg #15633: Deprecated `yii\base\BaseObject::className()` in favor of native PHP syntax `::class`, which does not trigger autoloading (brandonkelly)
- Chg #15633: Deprecated `yii\base\BaseObject::class` in favor of native PHP syntax `::class`, which does not trigger autoloading (brandonkelly)
- Chg #15633: Deprecated XCache and Zend data cache support as caching backends (brandonkelly)
- Chg #15633: Deprecated `yii\BaseYii::powered()` method (brandonkelly)
- Chg #15633: Added `yii\base\InvalidArgumentException` and deprecated `yii\base\InvalidParamException` (brandonkelly)
Expand Down
4 changes: 2 additions & 2 deletions framework/UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ Upgrade from Yii 2.0.34
public function rules()
{
return [
['attribute', 'each', 'rule' => ['exist', 'targetClass' => static::className(), 'targetAttribute' => 'id']],
['attribute', 'each', 'rule' => ['exist', 'targetClass' => static::class, 'targetAttribute' => 'id']],
];
}
```
Expand Down Expand Up @@ -523,7 +523,7 @@ Upgrade from Yii 2.0.13

* You can start preparing your application for Yii 2.1 by doing the following:

- Replace `::className()` calls with `::class` (if you’re running PHP 5.5+).
- Replace `::class` calls with `::class` (if you’re running PHP 5.5+).
- Replace usages of `yii\base\InvalidParamException` with `yii\base\InvalidArgumentException`.
- Replace calls to `Yii::trace()` with `Yii::debug()`.
- Remove calls to `yii\BaseYii::powered()`.
Expand Down
10 changes: 0 additions & 10 deletions framework/base/BaseObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,6 @@
*/
class BaseObject implements Configurable
{
/**
* Returns the fully qualified name of this class.
* @return string the fully qualified name of this class.
* @deprecated since 2.0.14. On PHP >=5.5, use `::class` instead.
*/
public static function className()
{
return get_called_class();
}

/**
* Constructor.
*
Expand Down
4 changes: 2 additions & 2 deletions framework/base/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public function __construct($id, $module, $config = [])
public function init()
{
parent::init();
$this->request = Instance::ensure($this->request, Request::className());
$this->response = Instance::ensure($this->response, Response::className());
$this->request = Instance::ensure($this->request, Request::class);
$this->response = Instance::ensure($this->response, Response::class);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion framework/behaviors/SluggableBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ protected function validateSlug($slug)
/* @var $model BaseActiveRecord */
$validator = Yii::createObject(array_merge(
[
'class' => UniqueValidator::className(),
'class' => UniqueValidator::class,
],
$this->uniqueValidator
));
Expand Down
2 changes: 1 addition & 1 deletion framework/caching/DbCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class DbCache extends Cache
public function init()
{
parent::init();
$this->db = Instance::ensure($this->db, Connection::className());
$this->db = Instance::ensure($this->db, Connection::class);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion framework/caching/DbDependency.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DbDependency extends Dependency
protected function generateDependencyData($cache)
{
/* @var $db Connection */
$db = Instance::ensure($this->db, Connection::className());
$db = Instance::ensure($this->db, Connection::class);
if ($this->sql === null) {
throw new InvalidConfigException('DbDependency::sql must be set.');
}
Expand Down
2 changes: 1 addition & 1 deletion framework/console/controllers/CacheController.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,6 @@ private function isCacheClass($className)
*/
private function canBeFlushed($className)
{
return !is_a($className, ApcCache::className(), true) || PHP_SAPI !== 'cli';
return !is_a($className, ApcCache::class, true) || PHP_SAPI !== 'cli';

Check warning on line 303 in framework/console/controllers/CacheController.php

View check run for this annotation

Codecov / codecov/patch

framework/console/controllers/CacheController.php#L303

Added line #L303 was not covered by tests
}
}
2 changes: 1 addition & 1 deletion framework/console/controllers/FixtureController.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private function notifyLoaded($fixtures)
$fixtureClassNames = [];

foreach ($fixtures as $fixture) {
$fixtureClassNames[] = $fixture::className();
$fixtureClassNames[] = $fixture::class;

Check warning on line 261 in framework/console/controllers/FixtureController.php

View check run for this annotation

Codecov / codecov/patch

framework/console/controllers/FixtureController.php#L261

Added line #L261 was not covered by tests
}

$this->outputList($fixtureClassNames);
Expand Down
2 changes: 1 addition & 1 deletion framework/console/controllers/MessageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function actionExtract($configFile = null)
}
} elseif ($this->config['format'] === 'db') {
/** @var Connection $db */
$db = Instance::ensure($this->config['db'], Connection::className());
$db = Instance::ensure($this->config['db'], Connection::class);

Check warning on line 321 in framework/console/controllers/MessageController.php

View check run for this annotation

Codecov / codecov/patch

framework/console/controllers/MessageController.php#L321

Added line #L321 was not covered by tests
$sourceMessageTable = isset($this->config['sourceMessageTable']) ? $this->config['sourceMessageTable'] : '{{%source_message}}';
$messageTable = isset($this->config['messageTable']) ? $this->config['messageTable'] : '{{%message}}';
$this->saveMessagesToDb(
Expand Down
4 changes: 2 additions & 2 deletions framework/console/controllers/MigrateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function optionAliases()
public function beforeAction($action)
{
if (parent::beforeAction($action)) {
$this->db = Instance::ensure($this->db, Connection::className());
$this->db = Instance::ensure($this->db, Connection::class);
return true;
}

Expand Down Expand Up @@ -471,7 +471,7 @@ protected function generateMigrationSourceCode($params)
if ($relatedColumn === null) {
$relatedColumn = 'id';
try {
$this->db = Instance::ensure($this->db, Connection::className());
$this->db = Instance::ensure($this->db, Connection::class);

Check warning on line 474 in framework/console/controllers/MigrateController.php

View check run for this annotation

Codecov / codecov/patch

framework/console/controllers/MigrateController.php#L474

Added line #L474 was not covered by tests
$relatedTableSchema = $this->db->getTableSchema($relatedTable);
if ($relatedTableSchema !== null) {
$primaryKeyCount = count($relatedTableSchema->primaryKey);
Expand Down
4 changes: 2 additions & 2 deletions framework/data/BaseDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function getPagination()
public function setPagination($value)
{
if (is_array($value)) {
$config = ['class' => Pagination::className()];
$config = ['class' => Pagination::class];
if ($this->id !== null) {
$config['pageParam'] = $this->id . '-page';
$config['pageSizeParam'] = $this->id . '-per-page';
Expand Down Expand Up @@ -252,7 +252,7 @@ public function getSort()
public function setSort($value)
{
if (is_array($value)) {
$config = ['class' => Sort::className()];
$config = ['class' => Sort::class];
if ($this->id !== null) {
$config['sortParam'] = $this->id . '-sort';
}
Expand Down
4 changes: 2 additions & 2 deletions framework/data/DataFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public function getSearchModel()
if (!is_object($this->_searchModel) || $this->_searchModel instanceof \Closure) {
$model = Yii::createObject($this->_searchModel);
if (!$model instanceof Model) {
throw new InvalidConfigException('`' . get_class($this) . '::$searchModel` should be an instance of `' . Model::className() . '` or its DI compatible configuration.');
throw new InvalidConfigException('`' . get_class($this) . '::$searchModel` should be an instance of `' . Model::class . '` or its DI compatible configuration.');

Check warning on line 291 in framework/data/DataFilter.php

View check run for this annotation

Codecov / codecov/patch

framework/data/DataFilter.php#L291

Added line #L291 was not covered by tests
}
$this->_searchModel = $model;
}
Expand All @@ -302,7 +302,7 @@ public function getSearchModel()
public function setSearchModel($model)
{
if (is_object($model) && !$model instanceof Model && !$model instanceof \Closure) {
throw new InvalidConfigException('`' . get_class($this) . '::$searchModel` should be an instance of `' . Model::className() . '` or its DI compatible configuration.');
throw new InvalidConfigException('`' . get_class($this) . '::$searchModel` should be an instance of `' . Model::class . '` or its DI compatible configuration.');
}
$this->_searchModel = $model;
}
Expand Down
2 changes: 1 addition & 1 deletion framework/data/SqlDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class SqlDataProvider extends BaseDataProvider
public function init()
{
parent::init();
$this->db = Instance::ensure($this->db, Connection::className());
$this->db = Instance::ensure($this->db, Connection::class);
if ($this->sql === null) {
throw new InvalidConfigException('The "sql" property must be set.');
}
Expand Down
2 changes: 1 addition & 1 deletion framework/db/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public static function deleteAll($condition = null, $params = [])
*/
public static function find()
{
return Yii::createObject(ActiveQuery::className(), [get_called_class()]);
return Yii::createObject(ActiveQuery::class, [get_called_class()]);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions framework/db/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Migration extends Component implements MigrationInterface
public function init()
{
parent::init();
$this->db = Instance::ensure($this->db, Connection::className());
$this->db = Instance::ensure($this->db, Connection::class);
$this->db->getSchema()->refresh();
$this->db->enableSlaves = false;
}
Expand Down Expand Up @@ -311,15 +311,15 @@ public function delete($table, $condition = '', $params = [])
*
* If a column is specified with definition only (e.g. 'PRIMARY KEY (name, type)'), it will be directly
* put into the generated SQL.
*
*
* Example usage:
* ```php
* class m200000_000000_create_table_fruits extends \yii\db\Migration
* {
* public function safeUp()
* {
* $this->createTable('{{%fruits}}', [
* // ...
* // ...
* 'column_name double precision null default null',
* ```
Expand Down
4 changes: 2 additions & 2 deletions framework/db/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function prepare($builder)
public function batch($batchSize = 100, $db = null)
{
return Yii::createObject([
'class' => BatchQueryResult::className(),
'class' => BatchQueryResult::class,
'query' => $this,
'batchSize' => $batchSize,
'db' => $db,
Expand Down Expand Up @@ -226,7 +226,7 @@ public function batch($batchSize = 100, $db = null)
public function each($batchSize = 100, $db = null)
{
return Yii::createObject([
'class' => BatchQueryResult::className(),
'class' => BatchQueryResult::class,
'query' => $this,
'batchSize' => $batchSize,
'db' => $db,
Expand Down
4 changes: 2 additions & 2 deletions framework/db/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public function refreshTableSchema($name)
*/
public function createQueryBuilder()
{
return Yii::createObject(QueryBuilder::className(), [$this->db]);
return Yii::createObject(QueryBuilder::class, [$this->db]);

Check warning on line 316 in framework/db/Schema.php

View check run for this annotation

Codecov / codecov/patch

framework/db/Schema.php#L316

Added line #L316 was not covered by tests
}

/**
Expand All @@ -328,7 +328,7 @@ public function createQueryBuilder()
*/
public function createColumnSchemaBuilder($type, $length = null)
{
return Yii::createObject(ColumnSchemaBuilder::className(), [$type, $length]);
return Yii::createObject(ColumnSchemaBuilder::class, [$type, $length]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion framework/db/cubrid/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public function releaseSavepoint($name)
*/
public function createQueryBuilder()
{
return Yii::createObject(QueryBuilder::className(), [$this->db]);
return Yii::createObject(QueryBuilder::class, [$this->db]);

Check warning on line 252 in framework/db/cubrid/Schema.php

View check run for this annotation

Codecov / codecov/patch

framework/db/cubrid/Schema.php#L252

Added line #L252 was not covered by tests
}

/**
Expand Down
4 changes: 2 additions & 2 deletions framework/db/mssql/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public function rollBackSavepoint($name)
*/
public function createQueryBuilder()
{
return Yii::createObject(QueryBuilder::className(), [$this->db]);
return Yii::createObject(QueryBuilder::class, [$this->db]);

Check warning on line 335 in framework/db/mssql/Schema.php

View check run for this annotation

Codecov / codecov/patch

framework/db/mssql/Schema.php#L335

Added line #L335 was not covered by tests
}

/**
Expand Down Expand Up @@ -811,6 +811,6 @@ public function insert($table, $columns)
*/
public function createColumnSchemaBuilder($type, $length = null)
{
return Yii::createObject(ColumnSchemaBuilder::className(), [$type, $length, $this->db]);
return Yii::createObject(ColumnSchemaBuilder::class, [$type, $length, $this->db]);

Check warning on line 814 in framework/db/mssql/Schema.php

View check run for this annotation

Codecov / codecov/patch

framework/db/mssql/Schema.php#L814

Added line #L814 was not covered by tests
}
}
4 changes: 2 additions & 2 deletions framework/db/mysql/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected function loadTableDefaultValues($tableName)
*/
public function createQueryBuilder()
{
return Yii::createObject(QueryBuilder::className(), [$this->db]);
return Yii::createObject(QueryBuilder::class, [$this->db]);

Check warning on line 225 in framework/db/mysql/Schema.php

View check run for this annotation

Codecov / codecov/patch

framework/db/mysql/Schema.php#L225

Added line #L225 was not covered by tests
}

/**
Expand Down Expand Up @@ -472,7 +472,7 @@ public function findUniqueIndexes($table)
*/
public function createColumnSchemaBuilder($type, $length = null)
{
return Yii::createObject(ColumnSchemaBuilder::className(), [$type, $length, $this->db]);
return Yii::createObject(ColumnSchemaBuilder::class, [$type, $length, $this->db]);

Check warning on line 475 in framework/db/mysql/Schema.php

View check run for this annotation

Codecov / codecov/patch

framework/db/mysql/Schema.php#L475

Added line #L475 was not covered by tests
}

/**
Expand Down
4 changes: 2 additions & 2 deletions framework/db/oci/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,15 @@ public function quoteSimpleTableName($name)
*/
public function createQueryBuilder()
{
return Yii::createObject(QueryBuilder::className(), [$this->db]);
return Yii::createObject(QueryBuilder::class, [$this->db]);

Check warning on line 265 in framework/db/oci/Schema.php

View check run for this annotation

Codecov / codecov/patch

framework/db/oci/Schema.php#L265

Added line #L265 was not covered by tests
}

/**
* {@inheritdoc}
*/
public function createColumnSchemaBuilder($type, $length = null)
{
return Yii::createObject(ColumnSchemaBuilder::className(), [$type, $length]);
return Yii::createObject(ColumnSchemaBuilder::class, [$type, $length]);

Check warning on line 273 in framework/db/oci/Schema.php

View check run for this annotation

Codecov / codecov/patch

framework/db/oci/Schema.php#L273

Added line #L273 was not covered by tests
}

/**
Expand Down
2 changes: 1 addition & 1 deletion framework/db/pgsql/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ protected function loadTableDefaultValues($tableName)
*/
public function createQueryBuilder()
{
return Yii::createObject(QueryBuilder::className(), [$this->db]);
return Yii::createObject(QueryBuilder::class, [$this->db]);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions framework/db/sqlite/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ protected function loadTableDefaultValues($tableName)
*/
public function createQueryBuilder()
{
return Yii::createObject(QueryBuilder::className(), [$this->db]);
return Yii::createObject(QueryBuilder::class, [$this->db]);
}

/**
Expand All @@ -216,7 +216,7 @@ public function createQueryBuilder()
*/
public function createColumnSchemaBuilder($type, $length = null)
{
return Yii::createObject(ColumnSchemaBuilder::className(), [$type, $length]);
return Yii::createObject(ColumnSchemaBuilder::class, [$type, $length]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion framework/filters/AccessControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function init()
{
parent::init();
if ($this->user !== false) {
$this->user = Instance::ensure($this->user, User::className());
$this->user = Instance::ensure($this->user, User::class);
}
foreach ($this->rules as $i => $rule) {
if (is_array($rule)) {
Expand Down
Loading

0 comments on commit 01fdf13

Please sign in to comment.