diff --git a/framework/console/controllers/BaseMigrateController.php b/framework/console/controllers/BaseMigrateController.php index 33e65ee..6f93bdd 100644 --- a/framework/console/controllers/BaseMigrateController.php +++ b/framework/console/controllers/BaseMigrateController.php @@ -890,7 +890,7 @@ abstract class BaseMigrateController extends Controller $migrations = []; foreach ($migrationPaths as $item) { - list($migrationPath, $namespace) = $item; + [$migrationPath, $namespace] = $item; if (!file_exists($migrationPath)) { continue; } diff --git a/framework/db/ActiveQuery.php b/framework/db/ActiveQuery.php index 5122982..454338e 100644 --- a/framework/db/ActiveQuery.php +++ b/framework/db/ActiveQuery.php @@ -609,8 +609,8 @@ class ActiveQuery extends Query implements ActiveQueryInterface return; } - list($parentTable, $parentAlias) = $parent->getTableNameAndAlias(); - list($childTable, $childAlias) = $child->getTableNameAndAlias(); + [$parentTable, $parentAlias] = $parent->getTableNameAndAlias(); + [$childTable, $childAlias] = $child->getTableNameAndAlias(); if (!empty($child->link)) { if (strpos($parentAlias, '{{') === false) { @@ -785,7 +785,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface public function alias($alias) { if (empty($this->from) || count($this->from) < 2) { - list($tableName) = $this->getTableNameAndAlias(); + [$tableName] = $this->getTableNameAndAlias(); $this->from = [$alias => $tableName]; } else { $tableName = $this->getPrimaryTableName(); diff --git a/framework/db/Command.php b/framework/db/Command.php index f618144..e7cbdec 100644 --- a/framework/db/Command.php +++ b/framework/db/Command.php @@ -990,7 +990,7 @@ class Command extends Component public function execute() { $sql = $this->getSql(); - list($profile, $rawSql) = $this->logQuery(__METHOD__); + [$profile, $rawSql] = $this->logQuery(__METHOD__); if ($sql == '') { return 0; @@ -1046,7 +1046,7 @@ class Command extends Component */ protected function queryInternal($method, $fetchMode = null) { - list($profile, $rawSql) = $this->logQuery('yii\db\Command::query'); + [$profile, $rawSql] = $this->logQuery('yii\db\Command::query'); if ($method !== '') { $info = $this->db->getQueryCacheInfo($this->queryCacheDuration, $this->queryCacheDependency); diff --git a/framework/db/Query.php b/framework/db/Query.php index f82827a..61d8c98 100644 --- a/framework/db/Query.php +++ b/framework/db/Query.php @@ -527,7 +527,7 @@ $ PATTERN; if (preg_match($pattern, $tableName, $matches)) { if (isset($matches[2])) { - list(, $tableName, $alias) = $matches; + [, $tableName, $alias] = $matches; } else { $tableName = $alias = $matches[1]; } diff --git a/framework/db/oci/QueryBuilder.php b/framework/db/oci/QueryBuilder.php index 75726ca..cb683a9 100644 --- a/framework/db/oci/QueryBuilder.php +++ b/framework/db/oci/QueryBuilder.php @@ -369,7 +369,7 @@ EOD; throw new Exception("Operator '$operator' requires two operands."); } - list($column, $values) = $operands; + [$column, $values] = $operands; if ($values instanceof \Traversable) { $values = iterator_to_array($values); diff --git a/framework/db/sqlite/Command.php b/framework/db/sqlite/Command.php index 81de0ba..c66dc3d 100644 --- a/framework/db/sqlite/Command.php +++ b/framework/db/sqlite/Command.php @@ -34,7 +34,7 @@ class Command extends \yii\db\Command $result = null; foreach ($statements as $statement) { - list($statementSql, $statementParams) = $statement; + [$statementSql, $statementParams] = $statement; $this->setSql($statementSql)->bindValues($statementParams); $result = parent::execute(); } @@ -54,9 +54,9 @@ class Command extends \yii\db\Command return parent::queryInternal($method, $fetchMode); } - list($lastStatementSql, $lastStatementParams) = array_pop($statements); + [$lastStatementSql, $lastStatementParams] = array_pop($statements); foreach ($statements as $statement) { - list($statementSql, $statementParams) = $statement; + [$statementSql, $statementParams] = $statement; $this->setSql($statementSql)->bindValues($statementParams); parent::execute(); } diff --git a/framework/filters/auth/HttpBasicAuth.php b/framework/filters/auth/HttpBasicAuth.php index 64c9b1d..3654717 100644 --- a/framework/filters/auth/HttpBasicAuth.php +++ b/framework/filters/auth/HttpBasicAuth.php @@ -91,7 +91,7 @@ class HttpBasicAuth extends AuthMethod */ public function authenticate($user, $request, $response) { - list($username, $password) = $request->getAuthCredentials(); + [$username, $password] = $request->getAuthCredentials(); if ($this->auth) { if ($username !== null || $password !== null) { diff --git a/framework/filters/auth/HttpHeaderAuth.php b/framework/filters/auth/HttpHeaderAuth.php index ab4f06f..8808a3c 100644 --- a/framework/filters/auth/HttpHeaderAuth.php +++ b/framework/filters/auth/HttpHeaderAuth.php @@ -17,7 +17,7 @@ namespace yii\filters\auth; * { * return [ * 'basicAuth' => [ - * 'class' => \yii\filters\auth\HttpHeaderAuth::className(), + * 'class' => \yii\filters\auth\HttpHeaderAuth::class, * ], * ]; * } @@ -37,18 +37,18 @@ class HttpHeaderAuth extends AuthMethod * @var string the HTTP header name */ public $header = 'X-Api-Key'; - /** * @var string a pattern to use to extract the HTTP authentication value */ public $pattern; + /** * @inheritdoc */ public function authenticate($user, $request, $response) { - $authHeader = $request->getHeaders()->get($this->header); + $authHeader = $request->getHeaderLine('Authorization'); if ($authHeader !== null) { if ($this->pattern !== null && preg_match($this->pattern, $authHeader, $matches)) { diff --git a/framework/helpers/BaseIpHelper.php b/framework/helpers/BaseIpHelper.php index 74df866..3a4c35f 100644 --- a/framework/helpers/BaseIpHelper.php +++ b/framework/helpers/BaseIpHelper.php @@ -59,8 +59,8 @@ class BaseIpHelper */ public static function inRange($subnet, $range) { - list($ip, $mask) = array_pad(explode('/', $subnet), 2, null); - list($net, $netMask) = array_pad(explode('/', $range), 2, null); + [$ip, $mask] = array_pad(explode('/', $subnet), 2, null); + [$net, $netMask] = array_pad(explode('/', $range), 2, null); $ipVersion = static::getIpVersion($ip); $netVersion = static::getIpVersion($net); diff --git a/framework/i18n/Formatter.php b/framework/i18n/Formatter.php index be7d0bb..e7f612b 100644 --- a/framework/i18n/Formatter.php +++ b/framework/i18n/Formatter.php @@ -725,7 +725,7 @@ class Formatter extends Component $timeZone = $this->timeZone; // avoid time zone conversion for date-only and time-only values if ($type === 'date' || $type === 'time') { - list($timestamp, $hasTimeInfo, $hasDateInfo) = $this->normalizeDatetimeValue($value, true); + [$timestamp, $hasTimeInfo, $hasDateInfo] = $this->normalizeDatetimeValue($value, true); if ($type === 'date' && !$hasTimeInfo || $type === 'time' && !$hasDateInfo) { $timeZone = $this->defaultTimeZone; } @@ -1527,7 +1527,7 @@ class Formatter extends Component $multipliers = array_values($this->measureUnits[$unitType][$unitSystem]); - list($params, $position) = $this->formatNumber( + [$params, $position] = $this->formatNumber( $this->normalizeNumericValue($value) * $baseUnit, $decimals, null, diff --git a/framework/widgets/FragmentCache.php b/framework/widgets/FragmentCache.php index 7d49c0d..1ccf3d2 100644 --- a/framework/widgets/FragmentCache.php +++ b/framework/widgets/FragmentCache.php @@ -152,7 +152,7 @@ class FragmentCache extends Widget return $this->_content; } - list($this->_content, $placeholders) = $data; + [$this->_content, $placeholders] = $data; if (!is_array($placeholders) || count($placeholders) === 0) { return $this->_content; } diff --git a/tests/framework/base/EventTest.php b/tests/framework/base/EventTest.php index fffe477..d076ecc 100644 --- a/tests/framework/base/EventTest.php +++ b/tests/framework/base/EventTest.php @@ -97,7 +97,7 @@ class EventTest extends TestCase */ public function testOnWildcard() { - Event::on(Post::className(), '*', function ($event) { + Event::on(Post::class, '*', function ($event) { $this->counter += 1; }); Event::on('*\Post', 'save', function ($event) { @@ -108,7 +108,7 @@ class EventTest extends TestCase $post->save(); $this->assertEquals(4, $this->counter); - $this->assertTrue(Event::hasHandlers(Post::className(), 'save')); + $this->assertTrue(Event::hasHandlers(Post::class, 'save')); } /** @@ -120,11 +120,11 @@ class EventTest extends TestCase $handler = function ($event) { $this->counter++; }; - $this->assertFalse(Event::hasHandlers(Post::className(), 'save')); + $this->assertFalse(Event::hasHandlers(Post::class, 'save')); Event::on('*\Post', 'save', $handler); - $this->assertTrue(Event::hasHandlers(Post::className(), 'save')); + $this->assertTrue(Event::hasHandlers(Post::class, 'save')); Event::off('*\Post', 'save', $handler); - $this->assertFalse(Event::hasHandlers(Post::className(), 'save')); + $this->assertFalse(Event::hasHandlers(Post::class, 'save')); } } diff --git a/tests/framework/base/ModuleTest.php b/tests/framework/base/ModuleTest.php index 83a9a0c..d436b60 100644 --- a/tests/framework/base/ModuleTest.php +++ b/tests/framework/base/ModuleTest.php @@ -127,25 +127,25 @@ class ModuleTest extends TestCase $module->controllerNamespace = 'yiiunit\framework\base'; $route = 'module-test'; - $this->assertInstanceOf(ModuleTestController::className(), $module->createControllerByID($route)); + $this->assertInstanceOf(ModuleTestController::class, $module->createControllerByID($route)); $route = 'module-test-'; - $this->assertNotInstanceOf(ModuleTestController::className(), $module->createControllerByID($route)); + $this->assertNotInstanceOf(ModuleTestController::class, $module->createControllerByID($route)); $route = '-module-test'; - $this->assertNotInstanceOf(ModuleTestController::className(), $module->createControllerByID($route)); + $this->assertNotInstanceOf(ModuleTestController::class, $module->createControllerByID($route)); $route = 'very-complex-name-test'; - $this->assertInstanceOf(VeryComplexNameTestController::className(), $module->createControllerByID($route)); + $this->assertInstanceOf(VeryComplexNameTestController::class, $module->createControllerByID($route)); $route = 'very-complex-name-test--'; - $this->assertNotInstanceOf(VeryComplexNameTestController::className(), $module->createControllerByID($route)); + $this->assertNotInstanceOf(VeryComplexNameTestController::class, $module->createControllerByID($route)); $route = '--very-complex-name-test'; - $this->assertNotInstanceOf(VeryComplexNameTestController::className(), $module->createControllerByID($route)); + $this->assertNotInstanceOf(VeryComplexNameTestController::class, $module->createControllerByID($route)); $route = 'very---complex---name---test'; - $this->assertNotInstanceOf(VeryComplexNameTestController::className(), $module->createControllerByID($route)); + $this->assertNotInstanceOf(VeryComplexNameTestController::class, $module->createControllerByID($route)); } } diff --git a/tests/framework/db/ActiveQueryTest.php b/tests/framework/db/ActiveQueryTest.php index 0177680..7723d78 100644 --- a/tests/framework/db/ActiveQueryTest.php +++ b/tests/framework/db/ActiveQueryTest.php @@ -256,7 +256,7 @@ abstract class ActiveQueryTest extends DatabaseTestCase public function testGetTableNames_wontFillFrom() { - $query = new ActiveQuery(Profile::className()); + $query = new ActiveQuery(Profile::class); $this->assertEquals($query->from, null); $query->getTablesUsedInFrom(); $this->assertEquals($query->from, null); diff --git a/tests/framework/db/mysql/SchemaTest.php b/tests/framework/db/mysql/SchemaTest.php index 8f85a5d..a3feecb 100644 --- a/tests/framework/db/mysql/SchemaTest.php +++ b/tests/framework/db/mysql/SchemaTest.php @@ -38,7 +38,7 @@ SQL; $dt = $schema->columns['dt']; - $this->assertInstanceOf(Expression::className(),$dt->defaultValue); + $this->assertInstanceOf(Expression::class, $dt->defaultValue); } public function testGetSchemaNames() diff --git a/tests/framework/di/ContainerTest.php b/tests/framework/di/ContainerTest.php index 0f7be22..5227f59 100644 --- a/tests/framework/di/ContainerTest.php +++ b/tests/framework/di/ContainerTest.php @@ -98,8 +98,8 @@ class ContainerTest extends TestCase $this->assertInstanceOf($Qux, $foo->bar->qux); // predefined property parameters - $fooSetter = FooProperty::className(); - $barSetter = BarSetter::className(); + $fooSetter = FooProperty::class; + $barSetter = BarSetter::class; $container = new Container(); $container->set('foo', ['class' => $fooSetter, 'bar' => Instance::of('bar')]); diff --git a/tests/framework/filters/auth/AuthTest.php b/tests/framework/filters/auth/AuthTest.php index 2133e52..1974458 100644 --- a/tests/framework/filters/auth/AuthTest.php +++ b/tests/framework/filters/auth/AuthTest.php @@ -152,7 +152,7 @@ class AuthTest extends \yiiunit\TestCase public function testHttpHeaderAuth($token, $login) { Yii::$app->request->headers->set('X-Api-Key', $token); - $filter = ['class' => HttpHeaderAuth::className()]; + $filter = ['class' => HttpHeaderAuth::class]; $this->ensureFilterApplies($token, $login, $filter); } diff --git a/tests/framework/web/UserTest.php b/tests/framework/web/UserTest.php index 2001ea1..85cd643 100644 --- a/tests/framework/web/UserTest.php +++ b/tests/framework/web/UserTest.php @@ -355,14 +355,14 @@ class UserTest extends TestCase $appConfig = [ 'components' => [ 'user' => [ - 'identityClass' => UserIdentity::className(), - 'accessChecker' => AccessChecker::className() + 'identityClass' => UserIdentity::class, + 'accessChecker' => AccessChecker::class ] ], ]; $this->mockWebApplication($appConfig); - $this->assertInstanceOf(AccessChecker::className(), Yii::$app->user->accessChecker); + $this->assertInstanceOf(AccessChecker::class, Yii::$app->user->accessChecker); } }