mirror of
https://github.com/dg/dibi.git
synced 2025-08-09 15:47:23 +02:00
coding style: TRUE/FALSE/NULL -> true/false/null
This commit is contained in:
@@ -22,7 +22,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');
|
||||
|
@@ -31,7 +31,7 @@ Assert::same(
|
||||
(string) $fluent
|
||||
);
|
||||
|
||||
$fluent->setFlag('IGNORE', FALSE);
|
||||
$fluent->setFlag('IGNORE', false);
|
||||
|
||||
Assert::same(
|
||||
reformat('DELETE FROM [anotherTable] USING [thirdTable]'),
|
||||
|
@@ -32,7 +32,7 @@ class MockDriver extends Dibi\Drivers\SqlsrvDriver
|
||||
|
||||
function fetch(bool $type): ?array
|
||||
{
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@ $conn = new Dibi\Connection($config);
|
||||
$arr = [
|
||||
'title' => 'Super Product',
|
||||
'price' => 12,
|
||||
'brand' => NULL,
|
||||
'brand' => null,
|
||||
];
|
||||
|
||||
$fluent = $conn->insert('table', $arr)
|
||||
@@ -23,7 +23,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)'),
|
||||
|
@@ -12,7 +12,7 @@ $conn = new Dibi\Connection($config);
|
||||
$arr = [
|
||||
'title' => 'Super Product',
|
||||
'price' => 12,
|
||||
'brand' => NULL,
|
||||
'brand' => null,
|
||||
];
|
||||
|
||||
$fluent = $conn->update('table', $arr)
|
||||
|
@@ -7,19 +7,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'));
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -30,7 +30,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)
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@ class MockResult extends Dibi\Result
|
||||
function test($row)
|
||||
{
|
||||
$normalize = new ReflectionMethod(Dibi\Result::class, 'normalize');
|
||||
$normalize->setAccessible(TRUE);
|
||||
$normalize->setAccessible(true);
|
||||
$normalize->invokeArgs($this, [&$row]);
|
||||
return $row;
|
||||
}
|
||||
@@ -28,21 +28,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]));
|
||||
});
|
||||
|
||||
|
||||
@@ -50,9 +50,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']));
|
||||
@@ -66,9 +66,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']));
|
||||
@@ -138,9 +138,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']));
|
||||
@@ -164,14 +164,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]);
|
||||
}, TypeError::class);
|
||||
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']));
|
||||
@@ -183,14 +183,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]);
|
||||
}, TypeError::class);
|
||||
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']));
|
||||
@@ -201,14 +201,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]);
|
||||
}, TypeError::class);
|
||||
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']));
|
||||
});
|
||||
|
||||
@@ -217,14 +217,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]);
|
||||
}, TypeError::class);
|
||||
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']));
|
||||
});
|
||||
|
@@ -15,5 +15,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));
|
||||
|
@@ -35,7 +35,7 @@ FROM [customers] /* ... */'),
|
||||
|
||||
$conn->translate('
|
||||
SELECT *
|
||||
FROM %if', TRUE, '[customers] %else [products]'
|
||||
FROM %if', true, '[customers] %else [products]'
|
||||
));
|
||||
|
||||
|
||||
@@ -53,8 +53,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, '
|
||||
'));
|
||||
|
||||
|
||||
@@ -72,8 +72,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'
|
||||
));
|
||||
|
||||
@@ -83,7 +83,7 @@ Assert::same(
|
||||
'SELECT * FROM foo /* (limit 3) (offset 5) */',
|
||||
$conn->translate(
|
||||
'SELECT * FROM foo',
|
||||
'%if', FALSE,
|
||||
'%if', false,
|
||||
'%lmt', 3,
|
||||
'%ofs', 5,
|
||||
'%end'
|
||||
|
@@ -27,7 +27,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)'),
|
||||
@@ -108,7 +108,7 @@ Assert::same(
|
||||
|
||||
|
||||
$where = [];
|
||||
$where['age'] = NULL;
|
||||
$where['age'] = null;
|
||||
$where['email'] = 'ahoj';
|
||||
$where['id%l'] = [10, 20, 30];
|
||||
Assert::same(
|
||||
@@ -130,8 +130,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'),
|
||||
@@ -193,8 +193,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'),
|
||||
]));
|
||||
|
||||
@@ -287,7 +287,7 @@ $array3 = [
|
||||
];
|
||||
$array4 = [
|
||||
'a' => 12,
|
||||
'b' => NULL,
|
||||
'b' => null,
|
||||
'c' => new DateTime('12.3.2007'),
|
||||
'd' => 'any string',
|
||||
];
|
||||
@@ -398,9 +398,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')
|
||||
@@ -452,7 +452,7 @@ Assert::same(
|
||||
|
||||
Assert::same(
|
||||
reformat('SELECT FROM ... '),
|
||||
$conn->translate('SELECT FROM ... %lmt', NULL)
|
||||
$conn->translate('SELECT FROM ... %lmt', null)
|
||||
);
|
||||
|
||||
Assert::same(
|
||||
|
@@ -19,7 +19,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);
|
||||
}
|
||||
|
||||
|
@@ -24,14 +24,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::class, NULL, 19);
|
||||
}, Dibi\UniqueConstraintViolationException::class, 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::class, NULL, 19);
|
||||
}, Dibi\NotNullConstraintViolationException::class, null, 19);
|
||||
|
||||
Assert::same('INSERT INTO products (title) VALUES (NULL)', $e->getSql());
|
||||
|
||||
@@ -39,6 +39,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::class, NULL, 19);
|
||||
}, Dibi\ForeignKeyConstraintViolationException::class, null, 19);
|
||||
|
||||
Assert::same('INSERT INTO orders (customer_id, product_id, amount) VALUES (100, 1, 1)', $e->getSql());
|
||||
|
Reference in New Issue
Block a user