1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-15 10:34:06 +02:00

coding style: TRUE/FALSE/NULL -> true/false/null

This commit is contained in:
David Grudl
2017-07-21 22:27:17 +02:00
parent b439ee9df1
commit ebf0be1fd0
58 changed files with 703 additions and 703 deletions

View File

@@ -20,7 +20,7 @@ test(function () use ($config) {
test(function () use ($config) { // lazy
$conn = new Connection($config + ['lazy' => TRUE]);
$conn = new Connection($config + ['lazy' => true]);
Assert::false($conn->isConnected());
$conn->query('SELECT 1');

View File

@@ -30,7 +30,7 @@ Assert::same(
(string) $fluent
);
$fluent->setFlag('IGNORE', FALSE);
$fluent->setFlag('IGNORE', false);
Assert::same(
reformat('DELETE FROM [anotherTable] USING [thirdTable]'),

View File

@@ -25,7 +25,7 @@ class MockDriver extends Dibi\Drivers\SqlsrvDriver
function fetch($assoc)
{
return FALSE;
return false;
}
}

View File

@@ -11,7 +11,7 @@ $conn = new Dibi\Connection($config);
$arr = [
'title' => 'Super Product',
'price' => 12,
'brand' => NULL,
'brand' => null,
];
$fluent = $conn->insert('table', $arr)
@@ -22,7 +22,7 @@ Assert::same(
(string) $fluent
);
$fluent->setFlag('IGNORE', FALSE);
$fluent->setFlag('IGNORE', false);
Assert::same(
reformat('INSERT DELAYED INTO [table] ([title], [price], [brand]) VALUES (\'Super Product\', 12, NULL)'),

View File

@@ -11,7 +11,7 @@ $conn = new Dibi\Connection($config);
$arr = [
'title' => 'Super Product',
'price' => 12,
'brand' => NULL,
'brand' => null,
];
$fluent = $conn->update('table', $arr)

View File

@@ -6,19 +6,19 @@ use Tester\Assert;
require __DIR__ . '/bootstrap.php';
Assert::same(NULL, Helpers::getSuggestion([], ''));
Assert::same(NULL, Helpers::getSuggestion([], 'a'));
Assert::same(NULL, Helpers::getSuggestion(['a'], 'a'));
Assert::same(null, Helpers::getSuggestion([], ''));
Assert::same(null, Helpers::getSuggestion([], 'a'));
Assert::same(null, Helpers::getSuggestion(['a'], 'a'));
Assert::same('a', Helpers::getSuggestion(['a', 'b'], ''));
Assert::same('b', Helpers::getSuggestion(['a', 'b'], 'a')); // ignore 100% match
Assert::same('a1', Helpers::getSuggestion(['a1', 'a2'], 'a')); // take first
Assert::same(NULL, Helpers::getSuggestion(['aaa', 'bbb'], 'a'));
Assert::same(NULL, Helpers::getSuggestion(['aaa', 'bbb'], 'ab'));
Assert::same(NULL, Helpers::getSuggestion(['aaa', 'bbb'], 'abc'));
Assert::same(null, Helpers::getSuggestion(['aaa', 'bbb'], 'a'));
Assert::same(null, Helpers::getSuggestion(['aaa', 'bbb'], 'ab'));
Assert::same(null, Helpers::getSuggestion(['aaa', 'bbb'], 'abc'));
Assert::same('bar', Helpers::getSuggestion(['foo', 'bar', 'baz'], 'baz'));
Assert::same('abcd', Helpers::getSuggestion(['abcd'], 'acbd'));
Assert::same('abcd', Helpers::getSuggestion(['abcd'], 'axbd'));
Assert::same(NULL, Helpers::getSuggestion(['abcd'], 'axyd'));
Assert::same(null, Helpers::getSuggestion(['abcd'], 'axyd'));
/*

View File

@@ -28,7 +28,7 @@ Assert::same(
if (!in_array($config['driver'], ['sqlite3', 'pdo', 'sqlsrv'])) {
Assert::same(
['products.product_id', 'orders.order_id', 'customers.name', 'xXx'],
$info->getColumnNames(TRUE)
$info->getColumnNames(true)
);
}

View File

@@ -14,7 +14,7 @@ class MockResult extends Dibi\Result
function test($row)
{
$normalize = new ReflectionMethod('Dibi\Result', 'normalize');
$normalize->setAccessible(TRUE);
$normalize->setAccessible(true);
$normalize->invokeArgs($this, [&$row]);
return $row;
}
@@ -25,21 +25,21 @@ test(function () {
$result = new MockResult;
$result->setType('col', Type::BOOL);
Assert::same(['col' => NULL], $result->test(['col' => NULL]));
Assert::same(['col' => TRUE], $result->test(['col' => TRUE]));
Assert::same(['col' => FALSE], $result->test(['col' => FALSE]));
Assert::same(['col' => null], $result->test(['col' => null]));
Assert::same(['col' => true], $result->test(['col' => true]));
Assert::same(['col' => false], $result->test(['col' => false]));
Assert::same(['col' => FALSE], $result->test(['col' => '']));
Assert::same(['col' => FALSE], $result->test(['col' => '0']));
Assert::same(['col' => TRUE], $result->test(['col' => '1']));
Assert::same(['col' => TRUE], $result->test(['col' => 't']));
Assert::same(['col' => FALSE], $result->test(['col' => 'f']));
Assert::same(['col' => TRUE], $result->test(['col' => 'T']));
Assert::same(['col' => FALSE], $result->test(['col' => 'F']));
Assert::same(['col' => FALSE], $result->test(['col' => 0]));
Assert::same(['col' => FALSE], $result->test(['col' => 0.0]));
Assert::same(['col' => TRUE], $result->test(['col' => 1]));
Assert::same(['col' => TRUE], $result->test(['col' => 1.0]));
Assert::same(['col' => false], $result->test(['col' => '']));
Assert::same(['col' => false], $result->test(['col' => '0']));
Assert::same(['col' => true], $result->test(['col' => '1']));
Assert::same(['col' => true], $result->test(['col' => 't']));
Assert::same(['col' => false], $result->test(['col' => 'f']));
Assert::same(['col' => true], $result->test(['col' => 'T']));
Assert::same(['col' => false], $result->test(['col' => 'F']));
Assert::same(['col' => false], $result->test(['col' => 0]));
Assert::same(['col' => false], $result->test(['col' => 0.0]));
Assert::same(['col' => true], $result->test(['col' => 1]));
Assert::same(['col' => true], $result->test(['col' => 1.0]));
});
@@ -47,9 +47,9 @@ test(function () {
$result = new MockResult;
$result->setType('col', Type::TEXT);
Assert::same(['col' => NULL], $result->test(['col' => NULL]));
Assert::same(['col' => '1'], $result->test(['col' => TRUE]));
Assert::same(['col' => ''], $result->test(['col' => FALSE]));
Assert::same(['col' => null], $result->test(['col' => null]));
Assert::same(['col' => '1'], $result->test(['col' => true]));
Assert::same(['col' => ''], $result->test(['col' => false]));
Assert::same(['col' => ''], $result->test(['col' => '']));
Assert::same(['col' => '0'], $result->test(['col' => '0']));
@@ -63,9 +63,9 @@ test(function () {
$result = new MockResult;
$result->setType('col', Type::FLOAT);
Assert::same(['col' => NULL], $result->test(['col' => NULL]));
Assert::same(['col' => 1.0], $result->test(['col' => TRUE]));
Assert::same(['col' => 0.0], $result->test(['col' => FALSE]));
Assert::same(['col' => null], $result->test(['col' => null]));
Assert::same(['col' => 1.0], $result->test(['col' => true]));
Assert::same(['col' => 0.0], $result->test(['col' => false]));
Assert::same(['col' => 0.0], $result->test(['col' => '']));
Assert::same(['col' => 0.0], $result->test(['col' => '0']));
@@ -135,9 +135,9 @@ test(function () {
$result = new MockResult;
$result->setType('col', Type::INTEGER);
Assert::same(['col' => NULL], $result->test(['col' => NULL]));
Assert::same(['col' => 1], $result->test(['col' => TRUE]));
Assert::same(['col' => 0], $result->test(['col' => FALSE]));
Assert::same(['col' => null], $result->test(['col' => null]));
Assert::same(['col' => 1], $result->test(['col' => true]));
Assert::same(['col' => 0], $result->test(['col' => false]));
Assert::same(['col' => 0], @$result->test(['col' => ''])); // triggers warning in PHP 7.1
Assert::same(['col' => 0], $result->test(['col' => '0']));
@@ -161,14 +161,14 @@ test(function () {
$result = new MockResult;
$result->setType('col', Type::DATETIME);
Assert::same(['col' => NULL], $result->test(['col' => NULL]));
Assert::same(['col' => null], $result->test(['col' => null]));
Assert::exception(function () use ($result) {
$result->test(['col' => TRUE]);
$result->test(['col' => true]);
}, 'Exception');
Assert::same(['col' => NULL], $result->test(['col' => FALSE]));
Assert::same(['col' => null], $result->test(['col' => false]));
Assert::same(['col' => NULL], $result->test(['col' => '']));
Assert::same(['col' => NULL], $result->test(['col' => '0000-00-00']));
Assert::same(['col' => null], $result->test(['col' => '']));
Assert::same(['col' => null], $result->test(['col' => '0000-00-00']));
Assert::equal(['col' => new Dibi\DateTime('00:00:00')], $result->test(['col' => '00:00:00']));
Assert::equal(['col' => new Dibi\DateTime('2015-10-13')], $result->test(['col' => '2015-10-13']));
Assert::equal(['col' => new Dibi\DateTime('2015-10-13 14:30')], $result->test(['col' => '2015-10-13 14:30']));
@@ -180,14 +180,14 @@ test(function () {
$result->setType('col', Type::DATETIME);
$result->setFormat(Type::DATETIME, 'Y-m-d H:i:s');
Assert::same(['col' => NULL], $result->test(['col' => NULL]));
Assert::same(['col' => null], $result->test(['col' => null]));
Assert::exception(function () use ($result) {
$result->test(['col' => TRUE]);
$result->test(['col' => true]);
}, 'Exception');
Assert::same(['col' => NULL], $result->test(['col' => FALSE]));
Assert::same(['col' => null], $result->test(['col' => false]));
Assert::same(['col' => NULL], $result->test(['col' => '']));
Assert::same(['col' => NULL], $result->test(['col' => '0000-00-00']));
Assert::same(['col' => null], $result->test(['col' => '']));
Assert::same(['col' => null], $result->test(['col' => '0000-00-00']));
Assert::same(['col' => date('Y-m-d 00:00:00')], $result->test(['col' => '00:00:00']));
Assert::equal(['col' => '2015-10-13 00:00:00'], $result->test(['col' => '2015-10-13']));
Assert::equal(['col' => '2015-10-13 14:30:00'], $result->test(['col' => '2015-10-13 14:30']));
@@ -198,14 +198,14 @@ test(function () {
$result = new MockResult;
$result->setType('col', Type::DATE);
Assert::same(['col' => NULL], $result->test(['col' => NULL]));
Assert::same(['col' => null], $result->test(['col' => null]));
Assert::exception(function () use ($result) {
$result->test(['col' => TRUE]);
$result->test(['col' => true]);
}, 'Exception');
Assert::same(['col' => NULL], $result->test(['col' => FALSE]));
Assert::same(['col' => null], $result->test(['col' => false]));
Assert::same(['col' => NULL], $result->test(['col' => '']));
Assert::same(['col' => NULL], $result->test(['col' => '0000-00-00']));
Assert::same(['col' => null], $result->test(['col' => '']));
Assert::same(['col' => null], $result->test(['col' => '0000-00-00']));
Assert::equal(['col' => new Dibi\DateTime('2015-10-13')], $result->test(['col' => '2015-10-13']));
});
@@ -214,14 +214,14 @@ test(function () {
$result = new MockResult;
$result->setType('col', Type::TIME);
Assert::same(['col' => NULL], $result->test(['col' => NULL]));
Assert::same(['col' => null], $result->test(['col' => null]));
Assert::exception(function () use ($result) {
$result->test(['col' => TRUE]);
$result->test(['col' => true]);
}, 'Exception');
Assert::same(['col' => NULL], $result->test(['col' => FALSE]));
Assert::same(['col' => null], $result->test(['col' => false]));
Assert::same(['col' => NULL], $result->test(['col' => '']));
Assert::same(['col' => NULL], $result->test(['col' => '0000-00-00']));
Assert::same(['col' => null], $result->test(['col' => '']));
Assert::same(['col' => null], $result->test(['col' => '0000-00-00']));
Assert::equal(['col' => new Dibi\DateTime('00:00:00')], $result->test(['col' => '00:00:00']));
Assert::equal(['col' => new Dibi\DateTime('14:30')], $result->test(['col' => '14:30']));
});

View File

@@ -13,5 +13,5 @@ $translator = new Dibi\Translator($conn);
$datetime = new DateTime('1978-01-23 00:00:00');
Assert::equal($datetime->format('U'), $translator->formatValue(new DateTime($datetime->format('c')), NULL));
Assert::equal($datetime->format('U'), $translator->formatValue(new DateTimeImmutable($datetime->format('c')), NULL));
Assert::equal($datetime->format('U'), $translator->formatValue(new DateTime($datetime->format('c')), null));
Assert::equal($datetime->format('U'), $translator->formatValue(new DateTimeImmutable($datetime->format('c')), null));

View File

@@ -33,7 +33,7 @@ FROM [customers] /* ... */'),
$conn->translate('
SELECT *
FROM %if', TRUE, '[customers] %else [products]'
FROM %if', true, '[customers] %else [products]'
));
@@ -51,8 +51,8 @@ WHERE [id] > 0
SELECT *
FROM [people]
WHERE [id] > 0
%if', FALSE, 'AND [foo]=%i', 1, '
%else %if', TRUE, 'AND [bar]=%i', 1, '
%if', false, 'AND [foo]=%i', 1, '
%else %if', true, 'AND [bar]=%i', 1, '
'));
@@ -70,8 +70,8 @@ WHERE
SELECT *
FROM [customers]
WHERE
%if', TRUE, '[name] LIKE %s', 'xxx', '
%if', FALSE, 'AND [admin]=1 %end
%if', true, '[name] LIKE %s', 'xxx', '
%if', false, 'AND [admin]=1 %end
%else 1 LIMIT 10 %end'
));
@@ -81,7 +81,7 @@ Assert::same(
'SELECT * FROM foo /* (limit 3) (offset 5) */',
$conn->translate(
'SELECT * FROM foo',
'%if', FALSE,
'%if', false,
'%lmt', 3,
'%ofs', 5,
'%end'

View File

@@ -25,7 +25,7 @@ Assert::same(
$array = [
'title' => 'Super Product',
'price' => 12,
'brand' => NULL,
'brand' => null,
];
Assert::same(
reformat('INSERT INTO [products] ([title], [price], [brand]) VALUES (\'Super Product\', 12, NULL) , (\'Super Product\', 12, NULL) , (\'Super Product\', 12, NULL)'),
@@ -106,7 +106,7 @@ Assert::same(
$where = [];
$where['age'] = NULL;
$where['age'] = null;
$where['email'] = 'ahoj';
$where['id%l'] = [10, 20, 30];
Assert::same(
@@ -128,8 +128,8 @@ $order = [
'field2' => 'desc',
'field3' => 1,
'field4' => -1,
'field5' => TRUE,
'field6' => FALSE,
'field5' => true,
'field6' => false,
];
Assert::same(
reformat('SELECT * FROM [people] ORDER BY [field1] ASC, [field2] DESC, [field3] ASC, [field4] DESC, [field5] ASC, [field6] DESC'),
@@ -191,8 +191,8 @@ Assert::same(
'b5' => new DateTime('1212-09-26'),
'b6%d' => new DateTime('1212-09-26'),
'b7%t' => new DateTime('1212-09-26'),
'b8%d' => NULL,
'b9%t' => NULL,
'b8%d' => null,
'b9%t' => null,
'c1%t' => new DateTime('1212-09-26 16:51:34.0124'),
]));
@@ -285,7 +285,7 @@ $array3 = [
];
$array4 = [
'a' => 12,
'b' => NULL,
'b' => null,
'c' => new DateTime('12.3.2007'),
'd' => 'any string',
];
@@ -396,9 +396,9 @@ WHERE ([test.a] LIKE %d', '1995-03-01', '
OR [b10] IN (', [], ")
AND [c] = 'embedded '' string'
OR [d]=%i", 10.3, '
OR [e]=%i', NULL, '
OR [true]=', TRUE, '
OR [false]=', FALSE, '
OR [e]=%i', null, '
OR [true]=', true, '
OR [false]=', false, '
OR [str_null]=%sn', '', '
OR [str_not_null]=%sn', 'hello', '
LIMIT 10')
@@ -450,7 +450,7 @@ Assert::same(
Assert::same(
reformat('SELECT FROM ... '),
$conn->translate('SELECT FROM ... %lmt', NULL)
$conn->translate('SELECT FROM ... %lmt', null)
);
Assert::same(

View File

@@ -18,7 +18,7 @@ date_default_timezone_set('Europe/Prague');
try {
$config = Tester\Environment::loadData();
} catch (Exception $e) {
$config = parse_ini_file(__DIR__ . '/../databases.ini', TRUE);
$config = parse_ini_file(__DIR__ . '/../databases.ini', true);
$config = reset($config);
}

View File

@@ -22,14 +22,14 @@ Assert::same('SELECT', $e->getSql());
$e = Assert::exception(function () use ($conn) {
$conn->query('INSERT INTO products (product_id, title) VALUES (1, "New")');
}, 'Dibi\UniqueConstraintViolationException', NULL, 19);
}, 'Dibi\UniqueConstraintViolationException', null, 19);
Assert::same("INSERT INTO products (product_id, title) VALUES (1, 'New')", $e->getSql());
$e = Assert::exception(function () use ($conn) {
$conn->query('INSERT INTO products (title) VALUES (NULL)');
}, 'Dibi\NotNullConstraintViolationException', NULL, 19);
}, 'Dibi\NotNullConstraintViolationException', null, 19);
Assert::same('INSERT INTO products (title) VALUES (NULL)', $e->getSql());
@@ -37,6 +37,6 @@ Assert::same('INSERT INTO products (title) VALUES (NULL)', $e->getSql());
$e = Assert::exception(function () use ($conn) {
$conn->query('PRAGMA foreign_keys=true');
$conn->query('INSERT INTO orders (customer_id, product_id, amount) VALUES (100, 1, 1)');
}, 'Dibi\ForeignKeyConstraintViolationException', NULL, 19);
}, 'Dibi\ForeignKeyConstraintViolationException', null, 19);
Assert::same('INSERT INTO orders (customer_id, product_id, amount) VALUES (100, 1, 1)', $e->getSql());