Browse Source

update code to match 2.1

tags/3.0.0-alpha1
Klimov Paul 7 years ago
parent
commit
359175c04b
  1. 2
      framework/console/controllers/BaseMigrateController.php
  2. 6
      framework/db/ActiveQuery.php
  3. 4
      framework/db/Command.php
  4. 2
      framework/db/Query.php
  5. 2
      framework/db/oci/QueryBuilder.php
  6. 6
      framework/db/sqlite/Command.php
  7. 2
      framework/filters/auth/HttpBasicAuth.php
  8. 6
      framework/filters/auth/HttpHeaderAuth.php
  9. 4
      framework/helpers/BaseIpHelper.php
  10. 4
      framework/i18n/Formatter.php
  11. 2
      framework/widgets/FragmentCache.php
  12. 10
      tests/framework/base/EventTest.php
  13. 14
      tests/framework/base/ModuleTest.php
  14. 2
      tests/framework/db/ActiveQueryTest.php
  15. 2
      tests/framework/db/mysql/SchemaTest.php
  16. 4
      tests/framework/di/ContainerTest.php
  17. 2
      tests/framework/filters/auth/AuthTest.php
  18. 6
      tests/framework/web/UserTest.php

2
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;
}

6
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();

4
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);

2
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];
}

2
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);

6
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();
}

2
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) {

6
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)) {

4
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);

4
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,

2
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;
}

10
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'));
}
}

14
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));
}
}

2
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);

2
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()

4
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')]);

2
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);
}

6
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);
}
}

Loading…
Cancel
Save