1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-11 16:44:30 +02:00

coding style: fixes in code

This commit is contained in:
David Grudl
2017-07-11 12:29:13 +02:00
parent a299c622c3
commit dac0a116a8
32 changed files with 88 additions and 86 deletions

View File

@@ -65,7 +65,7 @@ Assert::equal([
// more complex association array
function query($conn)
{
return $conn->query(in_array($conn->getConfig('system'), ['odbc', 'sqlsrv']) ? '
return $conn->query(in_array($conn->getConfig('system'), ['odbc', 'sqlsrv'], true) ? '
SELECT products.title, customers.name, orders.amount
FROM ([products]
INNER JOIN [orders] ON [products.product_id] = [orders.product_id])
@@ -172,11 +172,11 @@ Assert::equal([
Assert::equal([
new Row(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
new Row([
'title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
'title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0), ]),
new Row([
'title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
'title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0), ]),
new Row([
'title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
'title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0), ]),
], query($conn)->fetchAssoc('@,='));

View File

@@ -8,29 +8,29 @@ require __DIR__ . '/bootstrap.php';
class MockDriver extends Dibi\Drivers\SqlsrvDriver
{
function __construct()
public function __construct()
{
}
function connect(array & $config): void
public function connect(array &$config): void
{
}
function query(string $sql): ?Dibi\ResultDriver
public function query(string $sql): ?Dibi\ResultDriver
{
return $this;
}
function getResultColumns(): array
public function getResultColumns(): array
{
return [];
}
function fetch(bool $type): ?array
public function fetch(bool $type): ?array
{
return null;
}

View File

@@ -30,7 +30,7 @@ Assert::equal([
// more complex association array
if (!in_array($config['system'], ['odbc', 'sqlsrv'])) {
if (!in_array($config['system'], ['odbc', 'sqlsrv'], true)) {
$res = $conn->select(['products.title' => 'title', 'customers.name' => 'name'])->select('orders.amount')->as('amount')
->from('products')
->innerJoin('orders')->using('(product_id)')

View File

@@ -27,7 +27,7 @@ Assert::same(
);
if (!in_array($config['driver'], ['sqlite3', 'pdo', 'sqlsrv'])) {
if (!in_array($config['driver'], ['sqlite3', 'pdo', 'sqlsrv'], true)) {
Assert::same(
['products.product_id', 'orders.order_id', 'customers.name', 'xXx'],
$info->getColumnNames(true)
@@ -38,18 +38,18 @@ if (!in_array($config['driver'], ['sqlite3', 'pdo', 'sqlsrv'])) {
$columns = $info->getColumns();
Assert::same('product_id', $columns[0]->getName());
if (!in_array($config['driver'], ['sqlite3', 'pdo', 'sqlsrv'])) {
if (!in_array($config['driver'], ['sqlite3', 'pdo', 'sqlsrv'], true)) {
Assert::same('products', $columns[0]->getTableName());
}
Assert::null($columns[0]->getVendorInfo('xxx'));
if (!in_array($config['system'], ['sqlite', 'sqlsrv'])) {
if (!in_array($config['system'], ['sqlite', 'sqlsrv'], true)) {
Assert::same('i', $columns[0]->getType());
}
Assert::null($columns[0]->isNullable());
Assert::same('xXx', $columns[3]->getName());
Assert::null($columns[3]->getTableName());
if (!in_array($config['system'], ['sqlite', 'sqlsrv'])) {
if (!in_array($config['system'], ['sqlite', 'sqlsrv'], true)) {
Assert::same('i', $columns[0]->getType());
}
Assert::null($columns[3]->isNullable());

View File

@@ -9,12 +9,12 @@ require __DIR__ . '/bootstrap.php';
class MockResult extends Dibi\Result
{
function __construct()
public function __construct()
{
}
function test($row)
public function test($row)
{
$normalize = new ReflectionMethod(Dibi\Result::class, 'normalize');
$normalize->setAccessible(true);

View File

@@ -11,7 +11,7 @@ use Tester\Assert;
require __DIR__ . '/bootstrap.php';
$conn = new Dibi\Connection($config);
$conn->loadFile(__DIR__ . "/data/sqlsrv.insert.sql");
$conn->loadFile(__DIR__ . '/data/sqlsrv.insert.sql');
for ($i = 1; $i <= 5; $i++) {
$conn->query('INSERT INTO %n DEFAULT VALUES', 'aaa');

View File

@@ -12,10 +12,10 @@ class TestClass
public $public;
protected $protected;
public static $publicStatic;
protected $protected;
public function publicMethod()
{

View File

@@ -97,7 +97,7 @@ Assert::same(
$conn->translate('TEST %and', ['[cond] > 2', '[cond2] = "3"', 'cond3 < RAND()'])
);
//
$where = [];
$where[] = '[age] > 20';
$where[] = '[email] IS NOT NULL';
@@ -158,7 +158,7 @@ if ($config['system'] === 'odbc') {
Assert::same(
reformat([
'sqlsrv' => 'SELECT * FROM [products] OFFSET 1 ROWS FETCH NEXT 2 ROWS ONLY',
'SELECT * FROM [products] LIMIT 2 OFFSET 1'
'SELECT * FROM [products] LIMIT 2 OFFSET 1',
]),
$conn->translate('SELECT * FROM [products] %lmt %ofs', 2, 1)
);
@@ -551,7 +551,7 @@ Assert::same(
);
setLocale(LC_ALL, 'czech');
setlocale(LC_ALL, 'czech');
Assert::same(
reformat("UPDATE [colors] SET [color]='blue', [price]=-12.4, [spec]=-9E-005, [spec2]=1000, [spec3]=10000, [spec4]=10000 WHERE [price]=123.5"),

View File

@@ -60,7 +60,7 @@ function reformat($s)
return strtr($s, '[]', '``');
} elseif ($config['system'] === 'postgre') {
return strtr($s, '[]', '""');
} elseif (in_array($config['system'], ['odbc', 'sqlite', 'sqlsrv'])) {
} elseif (in_array($config['system'], ['odbc', 'sqlite', 'sqlsrv'], true)) {
return $s;
} else {
trigger_error("Unsupported driver $config[system]", E_USER_WARNING);

View File

@@ -17,7 +17,7 @@ $conn->loadFile(__DIR__ . "/data/$config[system].sql");
$e = Assert::exception(function () use ($conn) {
$conn->query('SELECT');
}, Dibi\DriverException::class, "%a% error in your SQL syntax;%a%", 1064);
}, Dibi\DriverException::class, '%a% error in your SQL syntax;%a%', 1064);
Assert::same('SELECT', $e->getSql());