diff --git a/examples/connecting-to-databases.php b/examples/connecting-to-databases.php
index 945809e3..d7ab1c0d 100644
--- a/examples/connecting-to-databases.php
+++ b/examples/connecting-to-databases.php
@@ -89,7 +89,7 @@ try {
dibi::connect([
'driver' => 'postgre',
'string' => 'host=localhost port=5432 dbname=mary',
- 'persistent' => TRUE,
+ 'persistent' => true,
]);
echo 'OK';
} catch (Dibi\Exception $e) {
diff --git a/examples/query-language-and-conditions.php b/examples/query-language-and-conditions.php
index 16ddd8cc..63b5c69e 100644
--- a/examples/query-language-and-conditions.php
+++ b/examples/query-language-and-conditions.php
@@ -14,13 +14,13 @@ dibi::connect([
// some variables
-$cond1 = TRUE;
-$cond2 = FALSE;
+$cond1 = true;
+$cond2 = false;
$foo = -1;
$bar = 2;
// conditional variable
-$name = $cond1 ? 'K%' : NULL;
+$name = $cond1 ? 'K%' : null;
// if & end
dibi::test('
diff --git a/examples/query-language-basic-examples.php b/examples/query-language-basic-examples.php
index 6db4a1b2..c6167ad9 100644
--- a/examples/query-language-basic-examples.php
+++ b/examples/query-language-basic-examples.php
@@ -33,7 +33,7 @@ dibi::test('
REPLACE INTO products', [
'title' => 'Super product',
'price' => 318,
- 'active' => TRUE,
+ 'active' => true,
]);
// -> REPLACE INTO products ([title], [price], [active]) VALUES ('Super product', 318, 1)
@@ -42,7 +42,7 @@ dibi::test('
$array = [
'title' => 'Super Product',
'price' => 12,
- 'brand' => NULL,
+ 'brand' => null,
'created' => new DateTime,
];
dibi::test('INSERT INTO products', $array, $array, $array);
diff --git a/examples/tracy-and-exceptions.php b/examples/tracy-and-exceptions.php
index f0c0750e..385e2648 100644
--- a/examples/tracy-and-exceptions.php
+++ b/examples/tracy-and-exceptions.php
@@ -13,7 +13,7 @@ $connection = dibi::connect([
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
'profiler' => [
- 'run' => TRUE,
+ 'run' => true,
],
]);
diff --git a/examples/tracy.php b/examples/tracy.php
index 537652c6..16d1ded8 100644
--- a/examples/tracy.php
+++ b/examples/tracy.php
@@ -13,7 +13,7 @@ $connection = dibi::connect([
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
'profiler' => [
- 'run' => TRUE,
+ 'run' => true,
],
]);
diff --git a/examples/using-fluent-syntax.php b/examples/using-fluent-syntax.php
index b78d44eb..ab550888 100644
--- a/examples/using-fluent-syntax.php
+++ b/examples/using-fluent-syntax.php
@@ -19,7 +19,7 @@ $id = 10;
$record = [
'title' => 'Super product',
'price' => 318,
- 'active' => TRUE,
+ 'active' => true,
];
// SELECT ...
diff --git a/examples/using-logger.php b/examples/using-logger.php
index a935eecd..1e794734 100644
--- a/examples/using-logger.php
+++ b/examples/using-logger.php
@@ -14,7 +14,7 @@ dibi::connect([
'database' => 'data/sample.s3db',
// enable query logging to this file
'profiler' => [
- 'run' => TRUE,
+ 'run' => true,
'file' => 'data/log.sql',
],
]);
diff --git a/examples/using-profiler.php b/examples/using-profiler.php
index 11f1095a..be73afd8 100644
--- a/examples/using-profiler.php
+++ b/examples/using-profiler.php
@@ -13,7 +13,7 @@ dibi::connect([
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
'profiler' => [
- 'run' => TRUE,
+ 'run' => true,
],
]);
diff --git a/readme.md b/readme.md
index fd55d982..0ea73aea 100644
--- a/readme.md
+++ b/readme.md
@@ -49,7 +49,7 @@ dibi::query('SELECT * FROM users WHERE id = ?', $id);
$arr = [
'name' => 'John',
- 'is_admin' => TRUE,
+ 'is_admin' => true,
];
dibi::query('INSERT INTO users', $arr);
// INSERT INTO users (`name`, `is_admin`) VALUES ('John', 1)
diff --git a/src/Dibi/Bridges/Nette/DibiExtension22.php b/src/Dibi/Bridges/Nette/DibiExtension22.php
index 9d45064a..d2787f39 100644
--- a/src/Dibi/Bridges/Nette/DibiExtension22.php
+++ b/src/Dibi/Bridges/Nette/DibiExtension22.php
@@ -20,7 +20,7 @@ class DibiExtension22 extends Nette\DI\CompilerExtension
private $debugMode;
- public function __construct($debugMode = NULL)
+ public function __construct($debugMode = null)
{
$this->debugMode = $debugMode;
}
@@ -31,7 +31,7 @@ class DibiExtension22 extends Nette\DI\CompilerExtension
$container = $this->getContainerBuilder();
$config = $this->getConfig();
- if ($this->debugMode === NULL) {
+ if ($this->debugMode === null) {
$this->debugMode = $container->parameters['debugMode'];
}
@@ -51,7 +51,7 @@ class DibiExtension22 extends Nette\DI\CompilerExtension
$connection = $container->addDefinition($this->prefix('connection'))
->setClass('Dibi\Connection', [$config])
- ->setAutowired(isset($config['autowired']) ? $config['autowired'] : TRUE);
+ ->setAutowired(isset($config['autowired']) ? $config['autowired'] : true);
if (class_exists('Tracy\Debugger')) {
$connection->addSetup(
@@ -62,8 +62,8 @@ class DibiExtension22 extends Nette\DI\CompilerExtension
if ($useProfiler) {
$panel = $container->addDefinition($this->prefix('panel'))
->setClass('Dibi\Bridges\Tracy\Panel', [
- isset($config['explain']) ? $config['explain'] : TRUE,
- isset($config['filter']) && $config['filter'] === FALSE ? Dibi\Event::ALL : Dibi\Event::QUERY,
+ isset($config['explain']) ? $config['explain'] : true,
+ isset($config['filter']) && $config['filter'] === false ? Dibi\Event::ALL : Dibi\Event::QUERY,
]);
$connection->addSetup([$panel, 'register'], [$connection]);
}
diff --git a/src/Dibi/Bridges/Nette/config.sample.neon b/src/Dibi/Bridges/Nette/config.sample.neon
index f336b711..92ce2555 100644
--- a/src/Dibi/Bridges/Nette/config.sample.neon
+++ b/src/Dibi/Bridges/Nette/config.sample.neon
@@ -9,4 +9,4 @@ dibi:
username: root
password: ***
database: foo
- lazy: TRUE
+ lazy: true
diff --git a/src/Dibi/Bridges/Tracy/Panel.php b/src/Dibi/Bridges/Tracy/Panel.php
index dd2c4e1d..ecda6019 100644
--- a/src/Dibi/Bridges/Tracy/Panel.php
+++ b/src/Dibi/Bridges/Tracy/Panel.php
@@ -33,7 +33,7 @@ class Panel implements Tracy\IBarPanel
private $events = [];
- public function __construct($explain = TRUE, $filter = NULL)
+ public function __construct($explain = true, $filter = null)
{
$this->filter = $filter ? (int) $filter : Event::QUERY;
$this->explain = $explain;
@@ -63,14 +63,14 @@ class Panel implements Tracy\IBarPanel
/**
* Returns blue-screen custom tab.
- * @return array|NULL
+ * @return array|null
*/
public static function renderException($e)
{
if ($e instanceof Dibi\Exception && $e->getSql()) {
return [
'tab' => 'SQL',
- 'panel' => Helpers::dump($e->getSql(), TRUE),
+ 'panel' => Helpers::dump($e->getSql(), true),
];
}
}
@@ -96,25 +96,25 @@ class Panel implements Tracy\IBarPanel
/**
* Returns HTML code for custom panel. (Tracy\IBarPanel)
- * @return string|NULL
+ * @return string|null
*/
public function getPanel()
{
if (!$this->events) {
- return NULL;
+ return null;
}
- $totalTime = $s = NULL;
+ $totalTime = $s = null;
foreach ($this->events as $event) {
$totalTime += $event->time;
$connection = $event->connection;
- $explain = NULL; // EXPLAIN is called here to work SELECT FOUND_ROWS()
+ $explain = null; // EXPLAIN is called here to work SELECT FOUND_ROWS()
if ($this->explain && $event->type === Event::SELECT) {
try {
$backup = [$connection->onEvent, \dibi::$numOfQueries, \dibi::$totalTime];
- $connection->onEvent = NULL;
+ $connection->onEvent = null;
$cmd = is_string($this->explain) ? $this->explain : ($connection->getConfig('driver') === 'oracle' ? 'EXPLAIN PLAN FOR' : 'EXPLAIN');
- $explain = @Helpers::dump($connection->nativeQuery("$cmd $event->sql"), TRUE);
+ $explain = @Helpers::dump($connection->nativeQuery("$cmd $event->sql"), true);
} catch (Dibi\Exception $e) {
}
list($connection->onEvent, \dibi::$numOfQueries, \dibi::$totalTime) = $backup;
@@ -127,7 +127,7 @@ class Panel implements Tracy\IBarPanel
$s .= "
explain";
}
- $s .= '
' . Helpers::dump(strlen($event->sql) > self::$maxLength ? substr($event->sql, 0, self::$maxLength) . '...' : $event->sql, TRUE);
+ $s .= ' | ' . Helpers::dump(strlen($event->sql) > self::$maxLength ? substr($event->sql, 0, self::$maxLength) . '...' : $event->sql, true);
if ($explain) {
$s .= " {$explain} ";
}
@@ -142,7 +142,7 @@ class Panel implements Tracy\IBarPanel
#tracy-debug .tracy-DibiProfiler-source { color: #999 !important }
#tracy-debug tracy-DibiProfiler tr table { margin: 8px 0; max-height: 150px; overflow:auto }
Queries: ' . count($this->events)
- . ($totalTime === NULL ? '' : ', time: ' . number_format($totalTime * 1000, 1, '.', ' ') . ' ms') . ', '
+ . ($totalTime === null ? '' : ', time: ' . number_format($totalTime * 1000, 1, '.', ' ') . ' ms') . ', '
. htmlSpecialChars($connection->getConfig('driver') . ($connection->getConfig('name') ? '/' . $connection->getConfig('name') : '')
. ($connection->getConfig('host') ? ' @ ' . $connection->getConfig('host') : '')) . '
diff --git a/src/Dibi/Connection.php b/src/Dibi/Connection.php
index cbd6c58a..1539e6d1 100644
--- a/src/Dibi/Connection.php
+++ b/src/Dibi/Connection.php
@@ -33,7 +33,7 @@ class Connection
private $translator;
/** @var bool Is connected? */
- private $connected = FALSE;
+ private $connected = false;
/** @var HashMap Substitutes for identifiers */
private $substitutes;
@@ -41,7 +41,7 @@ class Connection
/**
* Connection options: (see driver-specific options too)
- * - lazy (bool) => if TRUE, connection will be established only when required
+ * - lazy (bool) => if true, connection will be established only when required
* - result (array) => result set options
* - formatDateTime => date-time format (if empty, DateTime objects will be returned)
* - profiler (array or bool)
@@ -53,7 +53,7 @@ class Connection
* @param string connection name
* @throws Exception
*/
- public function __construct($config, $name = NULL)
+ public function __construct($config, $name = null)
{
if (is_string($config)) {
parse_str($config, $config);
@@ -143,10 +143,10 @@ class Connection
*/
final public function connect()
{
- $event = $this->onEvent ? new Event($this, Event::CONNECT) : NULL;
+ $event = $this->onEvent ? new Event($this, Event::CONNECT) : null;
try {
$this->driver->connect($this->config);
- $this->connected = TRUE;
+ $this->connected = true;
$event && $this->onEvent($event->done());
} catch (Exception $e) {
@@ -163,12 +163,12 @@ class Connection
final public function disconnect()
{
$this->driver->disconnect();
- $this->connected = FALSE;
+ $this->connected = false;
}
/**
- * Returns TRUE when connection was established.
+ * Returns true when connection was established.
* @return bool
*/
final public function isConnected()
@@ -184,9 +184,9 @@ class Connection
* @param mixed default value to use if key not found
* @return mixed
*/
- final public function getConfig($key = NULL, $default = NULL)
+ final public function getConfig($key = null, $default = null)
{
- if ($key === NULL) {
+ if ($key === null) {
return $this->config;
} elseif (isset($this->config[$key])) {
@@ -253,7 +253,7 @@ class Connection
$args = func_get_args();
try {
Helpers::dump($this->translateArgs($args));
- return TRUE;
+ return true;
} catch (Exception $e) {
if ($e->getSql()) {
@@ -261,7 +261,7 @@ class Connection
} else {
echo get_class($e) . ': ' . $e->getMessage() . (PHP_SAPI === 'cli' ? "\n" : ' ');
}
- return FALSE;
+ return false;
}
}
@@ -306,7 +306,7 @@ class Connection
$this->connected || $this->connect();
\dibi::$sql = $sql;
- $event = $this->onEvent ? new Event($this, Event::QUERY, $sql) : NULL;
+ $event = $this->onEvent ? new Event($this, Event::QUERY, $sql) : null;
try {
$res = $this->driver->query($sql);
@@ -359,7 +359,7 @@ class Connection
* @return int
* @throws Exception
*/
- public function getInsertId($sequence = NULL)
+ public function getInsertId($sequence = null)
{
$this->connected || $this->connect();
$id = $this->driver->getInsertId($sequence);
@@ -376,7 +376,7 @@ class Connection
* @return int
* @throws Exception
*/
- public function insertId($sequence = NULL)
+ public function insertId($sequence = null)
{
return $this->getInsertId($sequence);
}
@@ -387,10 +387,10 @@ class Connection
* @param string optional savepoint name
* @return void
*/
- public function begin($savepoint = NULL)
+ public function begin($savepoint = null)
{
$this->connected || $this->connect();
- $event = $this->onEvent ? new Event($this, Event::BEGIN, $savepoint) : NULL;
+ $event = $this->onEvent ? new Event($this, Event::BEGIN, $savepoint) : null;
try {
$this->driver->begin($savepoint);
$event && $this->onEvent($event->done());
@@ -407,10 +407,10 @@ class Connection
* @param string optional savepoint name
* @return void
*/
- public function commit($savepoint = NULL)
+ public function commit($savepoint = null)
{
$this->connected || $this->connect();
- $event = $this->onEvent ? new Event($this, Event::COMMIT, $savepoint) : NULL;
+ $event = $this->onEvent ? new Event($this, Event::COMMIT, $savepoint) : null;
try {
$this->driver->commit($savepoint);
$event && $this->onEvent($event->done());
@@ -427,10 +427,10 @@ class Connection
* @param string optional savepoint name
* @return void
*/
- public function rollback($savepoint = NULL)
+ public function rollback($savepoint = null)
{
$this->connected || $this->connect();
- $event = $this->onEvent ? new Event($this, Event::ROLLBACK, $savepoint) : NULL;
+ $event = $this->onEvent ? new Event($this, Event::ROLLBACK, $savepoint) : null;
try {
$this->driver->rollback($savepoint);
$event && $this->onEvent($event->done());
@@ -538,7 +538,7 @@ class Connection
*/
public function substitute($value)
{
- return strpos($value, ':') === FALSE
+ return strpos($value, ':') === false
? $value
: preg_replace_callback('#:([^:\s]*):#', function ($m) { return $this->substitutes->{$m[1]}; }, $value);
}
@@ -550,7 +550,7 @@ class Connection
/**
* Executes SQL query and fetch result - shortcut for query() & fetch().
* @param array|mixed one or more arguments
- * @return Row|FALSE
+ * @return Row|false
* @throws Exception
*/
public function fetch($args)
@@ -617,7 +617,7 @@ class Connection
* @param callable function (int $count, ?float $percent): void
* @return int count of sql commands
*/
- public function loadFile($file, callable $onProgress = NULL)
+ public function loadFile($file, callable $onProgress = null)
{
return Helpers::loadFromFile($this, $file, $onProgress);
}
@@ -630,7 +630,7 @@ class Connection
public function getDatabaseInfo()
{
$this->connected || $this->connect();
- return new Reflection\Database($this->driver->getReflector(), isset($this->config['database']) ? $this->config['database'] : NULL);
+ return new Reflection\Database($this->driver->getReflector(), isset($this->config['database']) ? $this->config['database'] : null);
}
diff --git a/src/Dibi/DataSource.php b/src/Dibi/DataSource.php
index a7048fa6..5b088e75 100644
--- a/src/Dibi/DataSource.php
+++ b/src/Dibi/DataSource.php
@@ -40,10 +40,10 @@ class DataSource implements IDataSource
/** @var array */
private $conds = [];
- /** @var int|NULL */
+ /** @var int|null */
private $offset;
- /** @var int|NULL */
+ /** @var int|null */
private $limit;
@@ -53,7 +53,7 @@ class DataSource implements IDataSource
*/
public function __construct($sql, Connection $connection)
{
- if (strpbrk($sql, " \t\r\n") === FALSE) {
+ if (strpbrk($sql, " \t\r\n") === false) {
$this->sql = $connection->getDriver()->escapeIdentifier($sql); // table name
} else {
$this->sql = '(' . $sql . ') t'; // SQL command
@@ -68,14 +68,14 @@ class DataSource implements IDataSource
* @param string column alias
* @return self
*/
- public function select($col, $as = NULL)
+ public function select($col, $as = null)
{
if (is_array($col)) {
$this->cols = $col;
} else {
$this->cols[$col] = $as;
}
- $this->result = NULL;
+ $this->result = null;
return $this;
}
@@ -93,7 +93,7 @@ class DataSource implements IDataSource
} else {
$this->conds[] = func_get_args();
}
- $this->result = $this->count = NULL;
+ $this->result = $this->count = null;
return $this;
}
@@ -111,22 +111,22 @@ class DataSource implements IDataSource
} else {
$this->sorting[$row] = $sorting;
}
- $this->result = NULL;
+ $this->result = null;
return $this;
}
/**
* Limits number of rows.
- * @param int|NULL limit
+ * @param int|null limit
* @param int offset
* @return self
*/
- public function applyLimit($limit, $offset = NULL)
+ public function applyLimit($limit, $offset = null)
{
$this->limit = $limit;
$this->offset = $offset;
- $this->result = $this->count = NULL;
+ $this->result = $this->count = null;
return $this;
}
@@ -150,7 +150,7 @@ class DataSource implements IDataSource
*/
public function getResult()
{
- if ($this->result === NULL) {
+ if ($this->result === null) {
$this->result = $this->connection->nativeQuery($this->__toString());
}
return $this->result;
@@ -168,7 +168,7 @@ class DataSource implements IDataSource
/**
* Generates, executes SQL query and fetches the single row.
- * @return Row|FALSE
+ * @return Row|false
*/
public function fetch()
{
@@ -178,7 +178,7 @@ class DataSource implements IDataSource
/**
* Like fetch(), but returns only first field.
- * @return mixed value on success, FALSE if no next record
+ * @return mixed value on success, false if no next record
*/
public function fetchSingle()
{
@@ -213,7 +213,7 @@ class DataSource implements IDataSource
* @param string value
* @return array
*/
- public function fetchPairs($key = NULL, $value = NULL)
+ public function fetchPairs($key = null, $value = null)
{
return $this->getResult()->fetchPairs($key, $value);
}
@@ -225,7 +225,7 @@ class DataSource implements IDataSource
*/
public function release()
{
- $this->result = $this->count = $this->totalCount = NULL;
+ $this->result = $this->count = $this->totalCount = null;
}
@@ -262,8 +262,8 @@ class DataSource implements IDataSource
return $this->connection->translate('
SELECT %n', (empty($this->cols) ? '*' : $this->cols), '
FROM %SQL', $this->sql, '
-%ex', $this->conds ? ['WHERE %and', $this->conds] : NULL, '
-%ex', $this->sorting ? ['ORDER BY %by', $this->sorting] : NULL, '
+%ex', $this->conds ? ['WHERE %and', $this->conds] : null, '
+%ex', $this->sorting ? ['ORDER BY %by', $this->sorting] : null, '
%ofs %lmt', $this->offset, $this->limit
);
} catch (\Exception $e) {
@@ -281,7 +281,7 @@ FROM %SQL', $this->sql, '
*/
public function count()
{
- if ($this->count === NULL) {
+ if ($this->count === null) {
$this->count = $this->conds || $this->offset || $this->limit
? (int) $this->connection->nativeQuery(
'SELECT COUNT(*) FROM (' . $this->__toString() . ') t'
@@ -298,7 +298,7 @@ FROM %SQL', $this->sql, '
*/
public function getTotalCount()
{
- if ($this->totalCount === NULL) {
+ if ($this->totalCount === null) {
$this->totalCount = (int) $this->connection->nativeQuery(
'SELECT COUNT(*) FROM ' . $this->sql
)->fetchSingle();
diff --git a/src/Dibi/DateTime.php b/src/Dibi/DateTime.php
index 28871532..2a3da08e 100644
--- a/src/Dibi/DateTime.php
+++ b/src/Dibi/DateTime.php
@@ -18,12 +18,12 @@ class DateTime extends \DateTime
/**
* @param string|int
*/
- public function __construct($time = 'now', \DateTimeZone $timezone = NULL)
+ public function __construct($time = 'now', \DateTimeZone $timezone = null)
{
if (is_numeric($time)) {
parent::__construct('@' . $time);
$this->setTimeZone($timezone ? $timezone : new \DateTimeZone(date_default_timezone_get()));
- } elseif ($timezone === NULL) {
+ } elseif ($timezone === null) {
parent::__construct($time);
} else {
parent::__construct($time, $timezone);
diff --git a/src/Dibi/Drivers/FirebirdDriver.php b/src/Dibi/Drivers/FirebirdDriver.php
index 2e8f1776..e6d6b0ac 100644
--- a/src/Dibi/Drivers/FirebirdDriver.php
+++ b/src/Dibi/Drivers/FirebirdDriver.php
@@ -28,20 +28,20 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
const ERROR_EXCEPTION_THROWN = -836;
- /** @var resource|NULL */
+ /** @var resource|null */
private $connection;
- /** @var resource|NULL */
+ /** @var resource|null */
private $resultSet;
/** @var bool */
- private $autoFree = TRUE;
+ private $autoFree = true;
- /** @var resource|NULL */
+ /** @var resource|null */
private $transaction;
/** @var bool */
- private $inTransaction = FALSE;
+ private $inTransaction = false;
/**
@@ -103,7 +103,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Executes the SQL query.
* @param string SQL statement.
- * @return Dibi\ResultDriver|NULL
+ * @return Dibi\ResultDriver|null
* @throws Dibi\DriverException|Dibi\Exception
*/
public function query($sql)
@@ -111,7 +111,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
$resource = $this->inTransaction ? $this->transaction : $this->connection;
$res = ibase_query($resource, $sql);
- if ($res === FALSE) {
+ if ($res === false) {
if (ibase_errcode() == self::ERROR_EXCEPTION_THROWN) {
preg_match('/exception (\d+) (\w+) (.*)/i', ibase_errmsg(), $match);
throw new Dibi\ProcedureException($match[3], $match[1], $match[2], $sql);
@@ -123,13 +123,13 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
} elseif (is_resource($res)) {
return $this->createResultDriver($res);
}
- return NULL;
+ return null;
}
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
- * @return int|FALSE number of rows or FALSE on error
+ * @return int|false number of rows or false on error
*/
public function getAffectedRows()
{
@@ -140,7 +140,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
* @param string generator name
- * @return int|FALSE int on success or FALSE on failure
+ * @return int|false int on success or false on failure
*/
public function getInsertId($sequence)
{
@@ -154,13 +154,13 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
* @return void
* @throws Dibi\DriverException
*/
- public function begin($savepoint = NULL)
+ public function begin($savepoint = null)
{
- if ($savepoint !== NULL) {
+ if ($savepoint !== null) {
throw new Dibi\NotSupportedException('Savepoints are not supported in Firebird/Interbase.');
}
$this->transaction = ibase_trans($this->getResource());
- $this->inTransaction = TRUE;
+ $this->inTransaction = true;
}
@@ -170,9 +170,9 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
* @return void
* @throws Dibi\DriverException
*/
- public function commit($savepoint = NULL)
+ public function commit($savepoint = null)
{
- if ($savepoint !== NULL) {
+ if ($savepoint !== null) {
throw new Dibi\NotSupportedException('Savepoints are not supported in Firebird/Interbase.');
}
@@ -180,7 +180,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
throw new Dibi\DriverException('Unable to handle operation - failure when commiting transaction.');
}
- $this->inTransaction = FALSE;
+ $this->inTransaction = false;
}
@@ -190,9 +190,9 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
* @return void
* @throws Dibi\DriverException
*/
- public function rollback($savepoint = NULL)
+ public function rollback($savepoint = null)
{
- if ($savepoint !== NULL) {
+ if ($savepoint !== null) {
throw new Dibi\NotSupportedException('Savepoints are not supported in Firebird/Interbase.');
}
@@ -200,7 +200,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
throw new Dibi\DriverException('Unable to handle operation - failure when rolbacking transaction.');
}
- $this->inTransaction = FALSE;
+ $this->inTransaction = false;
}
@@ -216,11 +216,11 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Returns the connection resource.
- * @return resource|NULL
+ * @return resource|null
*/
public function getResource()
{
- return is_resource($this->connection) ? $this->connection : NULL;
+ return is_resource($this->connection) ? $this->connection : null;
}
@@ -351,8 +351,8 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
- * @param int|NULL
- * @param int|NULL
+ * @param int|null
+ * @param int|null
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -389,7 +389,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Fetches the row at current position and moves the internal cursor to the next position.
- * @param bool TRUE for associative array, FALSE for numeric
+ * @param bool true for associative array, false for numeric
* @return array array on success, nonarray if no next record
*/
public function fetch($assoc)
@@ -413,7 +413,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
- * @return bool TRUE on success, FALSE if unable to seek to specified record
+ * @return bool true on success, false if unable to seek to specified record
* @throws Dibi\Exception
*/
public function seek($row)
@@ -429,18 +429,18 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
public function free()
{
ibase_free_result($this->resultSet);
- $this->resultSet = NULL;
+ $this->resultSet = null;
}
/**
* Returns the result set resource.
- * @return resource|NULL
+ * @return resource|null
*/
public function getResultResource()
{
- $this->autoFree = FALSE;
- return is_resource($this->resultSet) ? $this->resultSet : NULL;
+ $this->autoFree = false;
+ return is_resource($this->resultSet) ? $this->resultSet : null;
}
@@ -481,7 +481,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
WHERE RDB\$SYSTEM_FLAG = 0;"
);
$tables = [];
- while ($row = $res->fetch(FALSE)) {
+ while ($row = $res->fetch(false)) {
$tables[] = [
'name' => $row[0],
'view' => $row[1] === 'TRUE',
@@ -530,7 +530,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
);
$columns = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$key = $row['FIELD_NAME'];
$columns[$key] = [
'name' => $key,
@@ -539,7 +539,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
'size' => $row['FIELD_LENGTH'],
'nullable' => $row['NULLABLE'] === 'TRUE',
'default' => $row['DEFAULT_VALUE'],
- 'autoincrement' => FALSE,
+ 'autoincrement' => false,
];
}
return $columns;
@@ -568,7 +568,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
ORDER BY s.RDB\$FIELD_POSITION"
);
$indexes = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$key = $row['INDEX_NAME'];
$indexes[$key]['name'] = $key;
$indexes[$key]['unique'] = $row['UNIQUE_FLAG'] === 1;
@@ -598,7 +598,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
ORDER BY s.RDB\$FIELD_POSITION"
);
$keys = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$key = $row['INDEX_NAME'];
$keys[$key] = [
'name' => $key,
@@ -625,7 +625,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
AND RDB\$FOREIGN_KEY IS NULL;"
);
$indices = [];
- while ($row = $res->fetch(FALSE)) {
+ while ($row = $res->fetch(false)) {
$indices[] = $row[0];
}
return $indices;
@@ -649,7 +649,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
);"
);
$constraints = [];
- while ($row = $res->fetch(FALSE)) {
+ while ($row = $res->fetch(false)) {
$constraints[] = $row[0];
}
return $constraints;
@@ -663,7 +663,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
* @param string
* @return array
*/
- public function getTriggersMeta($table = NULL)
+ public function getTriggersMeta($table = null)
{
$res = $this->query("
SELECT TRIM(RDB\$TRIGGER_NAME) AS TRIGGER_NAME,
@@ -689,10 +689,10 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
END AS TRIGGER_ENABLED
FROM RDB\$TRIGGERS
WHERE RDB\$SYSTEM_FLAG = 0"
- . ($table === NULL ? ';' : " AND RDB\$RELATION_NAME = UPPER('$table');")
+ . ($table === null ? ';' : " AND RDB\$RELATION_NAME = UPPER('$table');")
);
$triggers = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$triggers[$row['TRIGGER_NAME']] = [
'name' => $row['TRIGGER_NAME'],
'table' => $row['TABLE_NAME'],
@@ -711,16 +711,16 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
* @param string
* @return array
*/
- public function getTriggers($table = NULL)
+ public function getTriggers($table = null)
{
$q = "SELECT TRIM(RDB\$TRIGGER_NAME)
FROM RDB\$TRIGGERS
WHERE RDB\$SYSTEM_FLAG = 0";
- $q .= $table === NULL ? ';' : " AND RDB\$RELATION_NAME = UPPER('$table')";
+ $q .= $table === null ? ';' : " AND RDB\$RELATION_NAME = UPPER('$table')";
$res = $this->query($q);
$triggers = [];
- while ($row = $res->fetch(FALSE)) {
+ while ($row = $res->fetch(false)) {
$triggers[] = $row[0];
}
return $triggers;
@@ -767,7 +767,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
ORDER BY p.RDB\$PARAMETER_TYPE, p.RDB\$PARAMETER_NUMBER;"
);
$procedures = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$key = $row['PROCEDURE_NAME'];
$io = trim($row['PARAMETER_TYPE']);
$num = $row['PARAMETER_NUMBER'];
@@ -791,7 +791,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
FROM RDB\$PROCEDURES;"
);
$procedures = [];
- while ($row = $res->fetch(FALSE)) {
+ while ($row = $res->fetch(false)) {
$procedures[] = $row[0];
}
return $procedures;
@@ -810,7 +810,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
WHERE RDB\$SYSTEM_FLAG = 0;"
);
$generators = [];
- while ($row = $res->fetch(FALSE)) {
+ while ($row = $res->fetch(false)) {
$generators[] = $row[0];
}
return $generators;
@@ -829,7 +829,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
WHERE RDB\$SYSTEM_FLAG = 0;"
);
$functions = [];
- while ($row = $res->fetch(FALSE)) {
+ while ($row = $res->fetch(false)) {
$functions[] = $row[0];
}
return $functions;
diff --git a/src/Dibi/Drivers/MsSqlDriver.php b/src/Dibi/Drivers/MsSqlDriver.php
index b718122d..06c68787 100644
--- a/src/Dibi/Drivers/MsSqlDriver.php
+++ b/src/Dibi/Drivers/MsSqlDriver.php
@@ -26,14 +26,14 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
{
use Dibi\Strict;
- /** @var resource|NULL */
+ /** @var resource|null */
private $connection;
- /** @var resource|NULL */
+ /** @var resource|null */
private $resultSet;
/** @var bool */
- private $autoFree = TRUE;
+ private $autoFree = true;
/**
@@ -57,7 +57,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
if (isset($config['resource'])) {
$this->connection = $config['resource'];
} elseif (empty($config['persistent'])) {
- $this->connection = @mssql_connect($config['host'], $config['username'], $config['password'], TRUE); // intentionally @
+ $this->connection = @mssql_connect($config['host'], $config['username'], $config['password'], true); // intentionally @
} else {
$this->connection = @mssql_pconnect($config['host'], $config['username'], $config['password']); // intentionally @
}
@@ -85,26 +85,26 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Executes the SQL query.
* @param string SQL statement.
- * @return Dibi\ResultDriver|NULL
+ * @return Dibi\ResultDriver|null
* @throws Dibi\DriverException
*/
public function query($sql)
{
$res = @mssql_query($sql, $this->connection); // intentionally @
- if ($res === FALSE) {
+ if ($res === false) {
throw new Dibi\DriverException(mssql_get_last_message(), 0, $sql);
} elseif (is_resource($res)) {
return $this->createResultDriver($res);
}
- return NULL;
+ return null;
}
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
- * @return int|FALSE number of rows or FALSE on error
+ * @return int|false number of rows or false on error
*/
public function getAffectedRows()
{
@@ -114,7 +114,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
- * @return int|FALSE int on success or FALSE on failure
+ * @return int|false int on success or false on failure
*/
public function getInsertId($sequence)
{
@@ -123,7 +123,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
$row = mssql_fetch_row($res);
return $row[0];
}
- return FALSE;
+ return false;
}
@@ -133,7 +133,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function begin($savepoint = NULL)
+ public function begin($savepoint = null)
{
$this->query('BEGIN TRANSACTION');
}
@@ -145,7 +145,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function commit($savepoint = NULL)
+ public function commit($savepoint = null)
{
$this->query('COMMIT');
}
@@ -157,7 +157,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function rollback($savepoint = NULL)
+ public function rollback($savepoint = null)
{
$this->query('ROLLBACK');
}
@@ -165,11 +165,11 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the connection resource.
- * @return resource|NULL
+ * @return resource|null
*/
public function getResource()
{
- return is_resource($this->connection) ? $this->connection : NULL;
+ return is_resource($this->connection) ? $this->connection : null;
}
@@ -302,8 +302,8 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
- * @param int|NULL
- * @param int|NULL
+ * @param int|null
+ * @param int|null
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -314,7 +314,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
} elseif ($limit < 0) {
throw new Dibi\NotSupportedException('Negative offset or limit.');
- } elseif ($limit !== NULL) {
+ } elseif ($limit !== null) {
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ') t';
}
}
@@ -345,7 +345,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Fetches the row at current position and moves the internal cursor to the next position.
- * @param bool TRUE for associative array, FALSE for numeric
+ * @param bool true for associative array, false for numeric
* @return array array on success, nonarray if no next record
*/
public function fetch($assoc)
@@ -357,7 +357,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
- * @return boolean TRUE on success, FALSE if unable to seek to specified record
+ * @return boolean true on success, false if unable to seek to specified record
*/
public function seek($row)
{
@@ -372,7 +372,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
public function free()
{
mssql_free_result($this->resultSet);
- $this->resultSet = NULL;
+ $this->resultSet = null;
}
@@ -399,11 +399,11 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the result set resource.
- * @return resource|NULL
+ * @return resource|null
*/
public function getResultResource()
{
- $this->autoFree = FALSE;
- return is_resource($this->resultSet) ? $this->resultSet : NULL;
+ $this->autoFree = false;
+ return is_resource($this->resultSet) ? $this->resultSet : null;
}
}
diff --git a/src/Dibi/Drivers/MsSqlReflector.php b/src/Dibi/Drivers/MsSqlReflector.php
index 653111ac..4d9fa837 100644
--- a/src/Dibi/Drivers/MsSqlReflector.php
+++ b/src/Dibi/Drivers/MsSqlReflector.php
@@ -39,7 +39,7 @@ class MsSqlReflector implements Dibi\Reflector
FROM INFORMATION_SCHEMA.TABLES
');
$tables = [];
- while ($row = $res->fetch(FALSE)) {
+ while ($row = $res->fetch(false)) {
$tables[] = [
'name' => $row[0],
'view' => isset($row[1]) && $row[1] === 'VIEW',
@@ -54,24 +54,24 @@ class MsSqlReflector implements Dibi\Reflector
* @param string
* @return int
*/
- public function getTableCount($table, $fallback = TRUE)
+ public function getTableCount($table, $fallback = true)
{
if (empty($table)) {
- return FALSE;
+ return false;
}
$result = $this->driver->query("
SELECT MAX(rowcnt)
FROM sys.sysindexes
WHERE id=OBJECT_ID({$this->driver->escapeIdentifier($table)})
");
- $row = $result->fetch(FALSE);
+ $row = $result->fetch(false);
if (!is_array($row) || count($row) < 1) {
if ($fallback) {
- $row = $this->driver->query("SELECT COUNT(*) FROM {$this->driver->escapeIdentifier($table)}")->fetch(FALSE);
+ $row = $this->driver->query("SELECT COUNT(*) FROM {$this->driver->escapeIdentifier($table)}")->fetch(false);
$count = intval($row[0]);
} else {
- $count = FALSE;
+ $count = false;
}
} else {
$count = intval($row[0]);
@@ -95,8 +95,8 @@ class MsSqlReflector implements Dibi\Reflector
ORDER BY TABLE_NAME, ORDINAL_POSITION
");
$columns = [];
- while ($row = $res->fetch(TRUE)) {
- $size = FALSE;
+ while ($row = $res->fetch(true)) {
+ $size = false;
$type = strtoupper($row['DATA_TYPE']);
$size_cols = [
@@ -119,10 +119,10 @@ class MsSqlReflector implements Dibi\Reflector
'table' => $table,
'nativetype' => $type,
'size' => $size,
- 'unsigned' => NULL,
+ 'unsigned' => null,
'nullable' => $row['IS_NULLABLE'] === 'YES',
'default' => $row['COLUMN_DEFAULT'],
- 'autoincrement' => FALSE,
+ 'autoincrement' => false,
'vendor' => $row,
];
}
@@ -155,7 +155,7 @@ class MsSqlReflector implements Dibi\Reflector
");
$indexes = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$index_name = $row['index_name'];
if (!isset($indexes[$index_name])) {
@@ -195,7 +195,7 @@ class MsSqlReflector implements Dibi\Reflector
");
$keys = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$key_name = $row['foreign_key'];
if (!isset($keys[$key_name])) {
@@ -203,8 +203,8 @@ class MsSqlReflector implements Dibi\Reflector
$keys[$key_name]['local'] = [$row['column_name']]; // local columns
$keys[$key_name]['table'] = $row['reference_table_name']; // referenced table
$keys[$key_name]['foreign'] = [$row['reference_column_name']]; // referenced columns
- $keys[$key_name]['onDelete'] = FALSE;
- $keys[$key_name]['onUpdate'] = FALSE;
+ $keys[$key_name]['onDelete'] = false;
+ $keys[$key_name]['onUpdate'] = false;
} else {
$keys[$key_name]['local'][] = $row['column_name']; // local columns
$keys[$key_name]['foreign'][] = $row['reference_column_name']; // referenced columns
diff --git a/src/Dibi/Drivers/MySqlDriver.php b/src/Dibi/Drivers/MySqlDriver.php
index 875ce3f7..629a7541 100644
--- a/src/Dibi/Drivers/MySqlDriver.php
+++ b/src/Dibi/Drivers/MySqlDriver.php
@@ -36,14 +36,14 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
const ERROR_DUPLICATE_ENTRY = 1062;
const ERROR_DATA_TRUNCATED = 1265;
- /** @var resource|NULL */
+ /** @var resource|null */
private $connection;
- /** @var resource|NULL */
+ /** @var resource|null */
private $resultSet;
/** @var bool */
- private $autoFree = TRUE;
+ private $autoFree = true;
/** @var bool Is buffered (seekable and countable)? */
private $buffered;
@@ -88,7 +88,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
if (!isset($config['socket'])) {
$config['socket'] = ini_get('mysql.default_socket');
}
- $config['host'] = NULL;
+ $config['host'] = null;
}
}
@@ -99,7 +99,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
}
if (empty($config['persistent'])) {
- $this->connection = @mysql_connect($host, $config['username'], $config['password'], TRUE, $config['flags']); // intentionally @
+ $this->connection = @mysql_connect($host, $config['username'], $config['password'], true, $config['flags']); // intentionally @
} else {
$this->connection = @mysql_pconnect($host, $config['username'], $config['password'], $config['flags']); // intentionally @
}
@@ -146,7 +146,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Executes the SQL query.
* @param string SQL statement.
- * @return Dibi\ResultDriver|NULL
+ * @return Dibi\ResultDriver|null
* @throws Dibi\DriverException
*/
public function query($sql)
@@ -187,7 +187,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
- * @return int|FALSE number of rows or FALSE on error
+ * @return int|false number of rows or false on error
*/
public function getAffectedRows()
{
@@ -197,7 +197,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
- * @return int|FALSE int on success or FALSE on failure
+ * @return int|false int on success or false on failure
*/
public function getInsertId($sequence)
{
@@ -211,7 +211,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function begin($savepoint = NULL)
+ public function begin($savepoint = null)
{
$this->query($savepoint ? "SAVEPOINT $savepoint" : 'START TRANSACTION');
}
@@ -223,7 +223,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function commit($savepoint = NULL)
+ public function commit($savepoint = null)
{
$this->query($savepoint ? "RELEASE SAVEPOINT $savepoint" : 'COMMIT');
}
@@ -235,7 +235,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function rollback($savepoint = NULL)
+ public function rollback($savepoint = null)
{
$this->query($savepoint ? "ROLLBACK TO SAVEPOINT $savepoint" : 'ROLLBACK');
}
@@ -243,11 +243,11 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the connection resource.
- * @return resource|NULL
+ * @return resource|null
*/
public function getResource()
{
- return is_resource($this->connection) ? $this->connection : NULL;
+ return is_resource($this->connection) ? $this->connection : null;
}
@@ -386,8 +386,8 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
- * @param int|NULL
- * @param int|NULL
+ * @param int|null
+ * @param int|null
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -395,9 +395,9 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
if ($limit < 0 || $offset < 0) {
throw new Dibi\NotSupportedException('Negative offset or limit.');
- } elseif ($limit !== NULL || $offset) {
+ } elseif ($limit !== null || $offset) {
// see http://dev.mysql.com/doc/refman/5.0/en/select.html
- $sql .= ' LIMIT ' . ($limit === NULL ? '18446744073709551615' : (int) $limit)
+ $sql .= ' LIMIT ' . ($limit === null ? '18446744073709551615' : (int) $limit)
. ($offset ? ' OFFSET ' . (int) $offset : '');
}
}
@@ -431,7 +431,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Fetches the row at current position and moves the internal cursor to the next position.
- * @param bool TRUE for associative array, FALSE for numeric
+ * @param bool true for associative array, false for numeric
* @return array array on success, nonarray if no next record
*/
public function fetch($assoc)
@@ -443,7 +443,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
- * @return bool TRUE on success, FALSE if unable to seek to specified record
+ * @return bool true on success, false if unable to seek to specified record
* @throws Dibi\Exception
*/
public function seek($row)
@@ -463,7 +463,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
public function free()
{
mysql_free_result($this->resultSet);
- $this->resultSet = NULL;
+ $this->resultSet = null;
}
@@ -482,7 +482,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
'table' => $row['table'],
'fullname' => $row['table'] ? $row['table'] . '.' . $row['name'] : $row['name'],
'nativetype' => strtoupper($row['type']),
- 'type' => $row['type'] === 'time' ? Dibi\Type::TIME_INTERVAL : NULL,
+ 'type' => $row['type'] === 'time' ? Dibi\Type::TIME_INTERVAL : null,
'vendor' => $row,
];
}
@@ -492,11 +492,11 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the result set resource.
- * @return resource|NULL
+ * @return resource|null
*/
public function getResultResource()
{
- $this->autoFree = FALSE;
- return is_resource($this->resultSet) ? $this->resultSet : NULL;
+ $this->autoFree = false;
+ return is_resource($this->resultSet) ? $this->resultSet : null;
}
}
diff --git a/src/Dibi/Drivers/MySqlReflector.php b/src/Dibi/Drivers/MySqlReflector.php
index 4fa34ab8..ac884571 100644
--- a/src/Dibi/Drivers/MySqlReflector.php
+++ b/src/Dibi/Drivers/MySqlReflector.php
@@ -36,7 +36,7 @@ class MySqlReflector implements Dibi\Reflector
{
$res = $this->driver->query('SHOW FULL TABLES');
$tables = [];
- while ($row = $res->fetch(FALSE)) {
+ while ($row = $res->fetch(false)) {
$tables[] = [
'name' => $row[0],
'view' => isset($row[1]) && $row[1] === 'VIEW',
@@ -55,13 +55,13 @@ class MySqlReflector implements Dibi\Reflector
{
$res = $this->driver->query("SHOW FULL COLUMNS FROM {$this->driver->escapeIdentifier($table)}");
$columns = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$type = explode('(', $row['Type']);
$columns[] = [
'name' => $row['Field'],
'table' => $table,
'nativetype' => strtoupper($type[0]),
- 'size' => isset($type[1]) ? (int) $type[1] : NULL,
+ 'size' => isset($type[1]) ? (int) $type[1] : null,
'unsigned' => (bool) strstr($row['Type'], 'unsigned'),
'nullable' => $row['Null'] === 'YES',
'default' => $row['Default'],
@@ -82,7 +82,7 @@ class MySqlReflector implements Dibi\Reflector
{
$res = $this->driver->query("SHOW INDEX FROM {$this->driver->escapeIdentifier($table)}");
$indexes = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$indexes[$row['Key_name']]['name'] = $row['Key_name'];
$indexes[$row['Key_name']]['unique'] = !$row['Non_unique'];
$indexes[$row['Key_name']]['primary'] = $row['Key_name'] === 'PRIMARY';
@@ -100,7 +100,7 @@ class MySqlReflector implements Dibi\Reflector
*/
public function getForeignKeys($table)
{
- $data = $this->driver->query("SELECT `ENGINE` FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = {$this->driver->escapeText($table)}")->fetch(TRUE);
+ $data = $this->driver->query("SELECT `ENGINE` FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = {$this->driver->escapeText($table)}")->fetch(true);
if ($data['ENGINE'] !== 'InnoDB') {
throw new Dibi\NotSupportedException("Foreign keys are not supported in {$data['ENGINE']} tables.");
}
@@ -119,7 +119,7 @@ class MySqlReflector implements Dibi\Reflector
");
$foreignKeys = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$keyName = $row['CONSTRAINT_NAME'];
$foreignKeys[$keyName]['name'] = $keyName;
diff --git a/src/Dibi/Drivers/MySqliDriver.php b/src/Dibi/Drivers/MySqliDriver.php
index 4fce01e0..cd06fa18 100644
--- a/src/Dibi/Drivers/MySqliDriver.php
+++ b/src/Dibi/Drivers/MySqliDriver.php
@@ -37,14 +37,14 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
const ERROR_DUPLICATE_ENTRY = 1062;
const ERROR_DATA_TRUNCATED = 1265;
- /** @var \mysqli|NULL */
+ /** @var \mysqli|null */
private $connection;
- /** @var \mysqli_result|NULL */
+ /** @var \mysqli_result|null */
private $resultSet;
/** @var bool */
- private $autoFree = TRUE;
+ private $autoFree = true;
/** @var bool Is buffered (seekable and countable)? */
private $buffered;
@@ -80,7 +80,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
'username' => ini_get('mysqli.default_user'),
'password' => ini_get('mysqli.default_pw'),
'socket' => (string) ini_get('mysqli.default_socket'),
- 'port' => NULL,
+ 'port' => null,
];
if (!isset($config['host'])) {
$host = ini_get('mysqli.default_host');
@@ -88,8 +88,8 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
$config['host'] = $host;
$config['port'] = ini_get('mysqli.default_port');
} else {
- $config['host'] = NULL;
- $config['port'] = NULL;
+ $config['host'] = null;
+ $config['port'] = null;
}
}
@@ -145,7 +145,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Executes the SQL query.
* @param string SQL statement.
- * @return Dibi\ResultDriver|NULL
+ * @return Dibi\ResultDriver|null
* @throws Dibi\DriverException
*/
public function query($sql)
@@ -158,7 +158,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
} elseif (is_object($res)) {
return $this->createResultDriver($res);
}
- return NULL;
+ return null;
}
@@ -167,13 +167,13 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
*/
public static function createException($message, $code, $sql)
{
- if (in_array($code, [1216, 1217, 1451, 1452, 1701], TRUE)) {
+ if (in_array($code, [1216, 1217, 1451, 1452, 1701], true)) {
return new Dibi\ForeignKeyConstraintViolationException($message, $code, $sql);
- } elseif (in_array($code, [1062, 1557, 1569, 1586], TRUE)) {
+ } elseif (in_array($code, [1062, 1557, 1569, 1586], true)) {
return new Dibi\UniqueConstraintViolationException($message, $code, $sql);
- } elseif (in_array($code, [1048, 1121, 1138, 1171, 1252, 1263, 1566], TRUE)) {
+ } elseif (in_array($code, [1048, 1121, 1138, 1171, 1252, 1263, 1566], true)) {
return new Dibi\NotNullConstraintViolationException($message, $code, $sql);
} else {
@@ -203,17 +203,17 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
- * @return int|FALSE number of rows or FALSE on error
+ * @return int|false number of rows or false on error
*/
public function getAffectedRows()
{
- return mysqli_affected_rows($this->connection) === -1 ? FALSE : mysqli_affected_rows($this->connection);
+ return mysqli_affected_rows($this->connection) === -1 ? false : mysqli_affected_rows($this->connection);
}
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
- * @return int|FALSE int on success or FALSE on failure
+ * @return int|false int on success or false on failure
*/
public function getInsertId($sequence)
{
@@ -227,7 +227,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function begin($savepoint = NULL)
+ public function begin($savepoint = null)
{
$this->query($savepoint ? "SAVEPOINT $savepoint" : 'START TRANSACTION');
}
@@ -239,7 +239,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function commit($savepoint = NULL)
+ public function commit($savepoint = null)
{
$this->query($savepoint ? "RELEASE SAVEPOINT $savepoint" : 'COMMIT');
}
@@ -251,7 +251,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function rollback($savepoint = NULL)
+ public function rollback($savepoint = null)
{
$this->query($savepoint ? "ROLLBACK TO SAVEPOINT $savepoint" : 'ROLLBACK');
}
@@ -263,7 +263,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
*/
public function getResource()
{
- return @$this->connection->thread_id ? $this->connection : NULL;
+ return @$this->connection->thread_id ? $this->connection : null;
}
@@ -394,8 +394,8 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
- * @param int|NULL
- * @param int|NULL
+ * @param int|null
+ * @param int|null
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -403,9 +403,9 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
if ($limit < 0 || $offset < 0) {
throw new Dibi\NotSupportedException('Negative offset or limit.');
- } elseif ($limit !== NULL || $offset) {
+ } elseif ($limit !== null || $offset) {
// see http://dev.mysql.com/doc/refman/5.0/en/select.html
- $sql .= ' LIMIT ' . ($limit === NULL ? '18446744073709551615' : (int) $limit)
+ $sql .= ' LIMIT ' . ($limit === null ? '18446744073709551615' : (int) $limit)
. ($offset ? ' OFFSET ' . (int) $offset : '');
}
}
@@ -439,7 +439,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Fetches the row at current position and moves the internal cursor to the next position.
- * @param bool TRUE for associative array, FALSE for numeric
+ * @param bool true for associative array, false for numeric
* @return array array on success, nonarray if no next record
*/
public function fetch($assoc)
@@ -451,7 +451,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
- * @return bool TRUE on success, FALSE if unable to seek to specified record
+ * @return bool true on success, false if unable to seek to specified record
* @throws Dibi\Exception
*/
public function seek($row)
@@ -470,7 +470,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
public function free()
{
mysqli_free_result($this->resultSet);
- $this->resultSet = NULL;
+ $this->resultSet = null;
}
@@ -481,8 +481,8 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
public function getResultColumns()
{
static $types;
- if ($types === NULL) {
- $consts = get_defined_constants(TRUE);
+ if ($types === null) {
+ $consts = get_defined_constants(true);
$types = [];
foreach (isset($consts['mysqli']) ? $consts['mysqli'] : [] as $key => $value) {
if (strncmp($key, 'MYSQLI_TYPE_', 12) === 0) {
@@ -501,7 +501,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
'table' => $row['orgtable'],
'fullname' => $row['table'] ? $row['table'] . '.' . $row['name'] : $row['name'],
'nativetype' => isset($types[$row['type']]) ? $types[$row['type']] : $row['type'],
- 'type' => $row['type'] === MYSQLI_TYPE_TIME ? Dibi\Type::TIME_INTERVAL : NULL,
+ 'type' => $row['type'] === MYSQLI_TYPE_TIME ? Dibi\Type::TIME_INTERVAL : null,
'vendor' => $row,
];
}
@@ -511,11 +511,11 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the result set resource.
- * @return \mysqli_result|NULL
+ * @return \mysqli_result|null
*/
public function getResultResource()
{
- $this->autoFree = FALSE;
+ $this->autoFree = false;
return $this->resultSet;
}
}
diff --git a/src/Dibi/Drivers/OdbcDriver.php b/src/Dibi/Drivers/OdbcDriver.php
index 3b725286..e8a46f98 100644
--- a/src/Dibi/Drivers/OdbcDriver.php
+++ b/src/Dibi/Drivers/OdbcDriver.php
@@ -25,17 +25,17 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
{
use Dibi\Strict;
- /** @var resource|NULL */
+ /** @var resource|null */
private $connection;
- /** @var resource|NULL */
+ /** @var resource|null */
private $resultSet;
/** @var bool */
- private $autoFree = TRUE;
+ private $autoFree = true;
- /** @var int|FALSE Affected rows */
- private $affectedRows = FALSE;
+ /** @var int|false Affected rows */
+ private $affectedRows = false;
/** @var int Cursor */
private $row = 0;
@@ -95,28 +95,28 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Executes the SQL query.
* @param string SQL statement.
- * @return Dibi\ResultDriver|NULL
+ * @return Dibi\ResultDriver|null
* @throws Dibi\DriverException
*/
public function query($sql)
{
- $this->affectedRows = FALSE;
+ $this->affectedRows = false;
$res = @odbc_exec($this->connection, $sql); // intentionally @
- if ($res === FALSE) {
+ if ($res === false) {
throw new Dibi\DriverException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection), 0, $sql);
} elseif (is_resource($res)) {
$this->affectedRows = odbc_num_rows($res);
return $this->createResultDriver($res);
}
- return NULL;
+ return null;
}
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
- * @return int|FALSE number of rows or FALSE on error
+ * @return int|false number of rows or false on error
*/
public function getAffectedRows()
{
@@ -126,7 +126,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
- * @return int|FALSE int on success or FALSE on failure
+ * @return int|false int on success or false on failure
*/
public function getInsertId($sequence)
{
@@ -140,9 +140,9 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
* @return void
* @throws Dibi\DriverException
*/
- public function begin($savepoint = NULL)
+ public function begin($savepoint = null)
{
- if (!odbc_autocommit($this->connection, FALSE)) {
+ if (!odbc_autocommit($this->connection, false)) {
throw new Dibi\DriverException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection));
}
}
@@ -154,12 +154,12 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
* @return void
* @throws Dibi\DriverException
*/
- public function commit($savepoint = NULL)
+ public function commit($savepoint = null)
{
if (!odbc_commit($this->connection)) {
throw new Dibi\DriverException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection));
}
- odbc_autocommit($this->connection, TRUE);
+ odbc_autocommit($this->connection, true);
}
@@ -169,12 +169,12 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
* @return void
* @throws Dibi\DriverException
*/
- public function rollback($savepoint = NULL)
+ public function rollback($savepoint = null)
{
if (!odbc_rollback($this->connection)) {
throw new Dibi\DriverException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection));
}
- odbc_autocommit($this->connection, TRUE);
+ odbc_autocommit($this->connection, true);
}
@@ -190,11 +190,11 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Returns the connection resource.
- * @return resource|NULL
+ * @return resource|null
*/
public function getResource()
{
- return is_resource($this->connection) ? $this->connection : NULL;
+ return is_resource($this->connection) ? $this->connection : null;
}
@@ -326,8 +326,8 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
- * @param int|NULL
- * @param int|NULL
+ * @param int|null
+ * @param int|null
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -338,7 +338,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
} elseif ($limit < 0) {
throw new Dibi\NotSupportedException('Negative offset or limit.');
- } elseif ($limit !== NULL) {
+ } elseif ($limit !== null) {
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ') t';
}
}
@@ -370,7 +370,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Fetches the row at current position and moves the internal cursor to the next position.
- * @param bool TRUE for associative array, FALSE for numeric
+ * @param bool true for associative array, false for numeric
* @return array array on success, nonarray if no next record
*/
public function fetch($assoc)
@@ -380,7 +380,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
} else {
$set = $this->resultSet;
if (!odbc_fetch_row($set, ++$this->row)) {
- return FALSE;
+ return false;
}
$count = odbc_num_fields($set);
$cols = [];
@@ -395,12 +395,12 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
- * @return bool TRUE on success, FALSE if unable to seek to specified record
+ * @return bool true on success, false if unable to seek to specified record
*/
public function seek($row)
{
$this->row = $row;
- return TRUE;
+ return true;
}
@@ -411,7 +411,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
public function free()
{
odbc_free_result($this->resultSet);
- $this->resultSet = NULL;
+ $this->resultSet = null;
}
@@ -426,7 +426,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
for ($i = 1; $i <= $count; $i++) {
$columns[] = [
'name' => odbc_field_name($this->resultSet, $i),
- 'table' => NULL,
+ 'table' => null,
'fullname' => odbc_field_name($this->resultSet, $i),
'nativetype' => odbc_field_type($this->resultSet, $i),
];
@@ -437,12 +437,12 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Returns the result set resource.
- * @return resource|NULL
+ * @return resource|null
*/
public function getResultResource()
{
- $this->autoFree = FALSE;
- return is_resource($this->resultSet) ? $this->resultSet : NULL;
+ $this->autoFree = false;
+ return is_resource($this->resultSet) ? $this->resultSet : null;
}
diff --git a/src/Dibi/Drivers/OracleDriver.php b/src/Dibi/Drivers/OracleDriver.php
index 76c3d4b4..219d05da 100644
--- a/src/Dibi/Drivers/OracleDriver.php
+++ b/src/Dibi/Drivers/OracleDriver.php
@@ -19,7 +19,7 @@ use Dibi;
* - password (or pass)
* - charset => character encoding to set
* - schema => alters session schema
- * - nativeDate => use native date format (defaults to FALSE)
+ * - nativeDate => use native date format (defaults to false)
* - resource (resource) => existing connection resource
* - persistent => Creates persistent connections with oci_pconnect instead of oci_new_connect
* - lazy, profiler, result, substitutes, ... => see Dibi\Connection options
@@ -28,23 +28,23 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
{
use Dibi\Strict;
- /** @var resource|NULL */
+ /** @var resource|null */
private $connection;
- /** @var resource|NULL */
+ /** @var resource|null */
private $resultSet;
/** @var bool */
- private $autoFree = TRUE;
+ private $autoFree = true;
/** @var bool */
- private $autocommit = TRUE;
+ private $autocommit = true;
/** @var string Date and datetime format */
private $fmtDate, $fmtDateTime;
- /** @var int|FALSE Number of affected rows */
- private $affectedRows = FALSE;
+ /** @var int|false Number of affected rows */
+ private $affectedRows = false;
/**
@@ -107,12 +107,12 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Executes the SQL query.
* @param string SQL statement.
- * @return Dibi\ResultDriver|NULL
+ * @return Dibi\ResultDriver|null
* @throws Dibi\DriverException
*/
public function query($sql)
{
- $this->affectedRows = FALSE;
+ $this->affectedRows = false;
$res = oci_parse($this->connection, $sql);
if ($res) {
@oci_execute($res, $this->autocommit ? OCI_COMMIT_ON_SUCCESS : OCI_DEFAULT);
@@ -128,7 +128,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
$err = oci_error($this->connection);
throw new Dibi\DriverException($err['message'], $err['code'], $sql);
}
- return NULL;
+ return null;
}
@@ -137,13 +137,13 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
*/
public static function createException($message, $code, $sql)
{
- if (in_array($code, [1, 2299, 38911], TRUE)) {
+ if (in_array($code, [1, 2299, 38911], true)) {
return new Dibi\UniqueConstraintViolationException($message, $code, $sql);
- } elseif (in_array($code, [1400], TRUE)) {
+ } elseif (in_array($code, [1400], true)) {
return new Dibi\NotNullConstraintViolationException($message, $code, $sql);
- } elseif (in_array($code, [2266, 2291, 2292], TRUE)) {
+ } elseif (in_array($code, [2266, 2291, 2292], true)) {
return new Dibi\ForeignKeyConstraintViolationException($message, $code, $sql);
} else {
@@ -154,7 +154,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
- * @return int|FALSE number of rows or FALSE on error
+ * @return int|false number of rows or false on error
*/
public function getAffectedRows()
{
@@ -164,12 +164,12 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
- * @return int|FALSE int on success or FALSE on failure
+ * @return int|false int on success or false on failure
*/
public function getInsertId($sequence)
{
- $row = $this->query("SELECT $sequence.CURRVAL AS ID FROM DUAL")->fetch(TRUE);
- return isset($row['ID']) ? (int) $row['ID'] : FALSE;
+ $row = $this->query("SELECT $sequence.CURRVAL AS ID FROM DUAL")->fetch(true);
+ return isset($row['ID']) ? (int) $row['ID'] : false;
}
@@ -178,9 +178,9 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
* @param string optional savepoint name
* @return void
*/
- public function begin($savepoint = NULL)
+ public function begin($savepoint = null)
{
- $this->autocommit = FALSE;
+ $this->autocommit = false;
}
@@ -190,13 +190,13 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
* @return void
* @throws Dibi\DriverException
*/
- public function commit($savepoint = NULL)
+ public function commit($savepoint = null)
{
if (!oci_commit($this->connection)) {
$err = oci_error($this->connection);
throw new Dibi\DriverException($err['message'], $err['code']);
}
- $this->autocommit = TRUE;
+ $this->autocommit = true;
}
@@ -206,23 +206,23 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
* @return void
* @throws Dibi\DriverException
*/
- public function rollback($savepoint = NULL)
+ public function rollback($savepoint = null)
{
if (!oci_rollback($this->connection)) {
$err = oci_error($this->connection);
throw new Dibi\DriverException($err['message'], $err['code']);
}
- $this->autocommit = TRUE;
+ $this->autocommit = true;
}
/**
* Returns the connection resource.
- * @return resource|NULL
+ * @return resource|null
*/
public function getResource()
{
- return is_resource($this->connection) ? $this->connection : NULL;
+ return is_resource($this->connection) ? $this->connection : null;
}
@@ -360,8 +360,8 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
- * @param int|NULL
- * @param int|NULL
+ * @param int|null
+ * @param int|null
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -372,10 +372,10 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
} elseif ($offset) {
// see http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
$sql = 'SELECT * FROM (SELECT t.*, ROWNUM AS "__rnum" FROM (' . $sql . ') t '
- . ($limit !== NULL ? 'WHERE ROWNUM <= ' . ((int) $offset + (int) $limit) : '')
+ . ($limit !== null ? 'WHERE ROWNUM <= ' . ((int) $offset + (int) $limit) : '')
. ') WHERE "__rnum" > '. (int) $offset;
- } elseif ($limit !== NULL) {
+ } elseif ($limit !== null) {
$sql = 'SELECT * FROM (' . $sql . ') WHERE ROWNUM <= ' . (int) $limit;
}
}
@@ -406,7 +406,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Fetches the row at current position and moves the internal cursor to the next position.
- * @param bool TRUE for associative array, FALSE for numeric
+ * @param bool true for associative array, false for numeric
* @return array array on success, nonarray if no next record
*/
public function fetch($assoc)
@@ -418,7 +418,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
- * @return bool TRUE on success, FALSE if unable to seek to specified record
+ * @return bool true on success, false if unable to seek to specified record
*/
public function seek($row)
{
@@ -433,7 +433,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
public function free()
{
oci_free_statement($this->resultSet);
- $this->resultSet = NULL;
+ $this->resultSet = null;
}
@@ -449,7 +449,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
$type = oci_field_type($this->resultSet, $i);
$columns[] = [
'name' => oci_field_name($this->resultSet, $i),
- 'table' => NULL,
+ 'table' => null,
'fullname' => oci_field_name($this->resultSet, $i),
'nativetype' => $type === 'NUMBER' && oci_field_scale($this->resultSet, $i) === 0 ? 'INTEGER' : $type,
];
@@ -460,12 +460,12 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Returns the result set resource.
- * @return resource|NULL
+ * @return resource|null
*/
public function getResultResource()
{
- $this->autoFree = FALSE;
- return is_resource($this->resultSet) ? $this->resultSet : NULL;
+ $this->autoFree = false;
+ return is_resource($this->resultSet) ? $this->resultSet : null;
}
@@ -480,7 +480,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
{
$res = $this->query('SELECT * FROM cat');
$tables = [];
- while ($row = $res->fetch(FALSE)) {
+ while ($row = $res->fetch(false)) {
if ($row[1] === 'TABLE' || $row[1] === 'VIEW') {
$tables[] = [
'name' => $row[0],
@@ -501,12 +501,12 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
{
$res = $this->query('SELECT * FROM "ALL_TAB_COLUMNS" WHERE "TABLE_NAME" = ' . $this->escapeText($table));
$columns = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$columns[] = [
'table' => $row['TABLE_NAME'],
'name' => $row['COLUMN_NAME'],
'nativetype' => $row['DATA_TYPE'],
- 'size' => isset($row['DATA_LENGTH']) ? $row['DATA_LENGTH'] : NULL,
+ 'size' => isset($row['DATA_LENGTH']) ? $row['DATA_LENGTH'] : null,
'nullable' => $row['NULLABLE'] === 'Y',
'default' => $row['DATA_DEFAULT'],
'vendor' => $row,
diff --git a/src/Dibi/Drivers/PdoDriver.php b/src/Dibi/Drivers/PdoDriver.php
index 7f24a865..4f3b2f25 100644
--- a/src/Dibi/Drivers/PdoDriver.php
+++ b/src/Dibi/Drivers/PdoDriver.php
@@ -30,11 +30,11 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
/** @var PDO Connection resource */
private $connection;
- /** @var \PDOStatement|NULL Resultset resource */
+ /** @var \PDOStatement|null Resultset resource */
private $resultSet;
- /** @var int|FALSE Affected rows */
- private $affectedRows = FALSE;
+ /** @var int|false Affected rows */
+ private $affectedRows = false;
/** @var string */
private $driverName;
@@ -92,14 +92,14 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
*/
public function disconnect()
{
- $this->connection = NULL;
+ $this->connection = null;
}
/**
* Executes the SQL query.
* @param string SQL statement.
- * @return Dibi\ResultDriver|NULL
+ * @return Dibi\ResultDriver|null
* @throws Dibi\DriverException
*/
public function query($sql)
@@ -107,12 +107,12 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
// must detect if SQL returns result set or num of affected rows
$cmd = strtoupper(substr(ltrim($sql), 0, 6));
static $list = ['UPDATE' => 1, 'DELETE' => 1, 'INSERT' => 1, 'REPLAC' => 1];
- $this->affectedRows = FALSE;
+ $this->affectedRows = false;
if (isset($list[$cmd])) {
$this->affectedRows = $this->connection->exec($sql);
- if ($this->affectedRows !== FALSE) {
- return NULL;
+ if ($this->affectedRows !== false) {
+ return null;
}
} else {
$res = $this->connection->query($sql);
@@ -144,7 +144,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
- * @return int|FALSE number of rows or FALSE on error
+ * @return int|false number of rows or false on error
*/
public function getAffectedRows()
{
@@ -154,7 +154,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
- * @return int|FALSE int on success or FALSE on failure
+ * @return int|false int on success or false on failure
*/
public function getInsertId($sequence)
{
@@ -168,7 +168,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function begin($savepoint = NULL)
+ public function begin($savepoint = null)
{
if (!$this->connection->beginTransaction()) {
$err = $this->connection->errorInfo();
@@ -183,7 +183,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function commit($savepoint = NULL)
+ public function commit($savepoint = null)
{
if (!$this->connection->commit()) {
$err = $this->connection->errorInfo();
@@ -198,7 +198,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function rollback($savepoint = NULL)
+ public function rollback($savepoint = null)
{
if (!$this->connection->rollBack()) {
$err = $this->connection->errorInfo();
@@ -415,8 +415,8 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
- * @param int|NULL
- * @param int|NULL
+ * @param int|null
+ * @param int|null
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -427,15 +427,15 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
switch ($this->driverName) {
case 'mysql':
- if ($limit !== NULL || $offset) {
+ if ($limit !== null || $offset) {
// see http://dev.mysql.com/doc/refman/5.0/en/select.html
- $sql .= ' LIMIT ' . ($limit === NULL ? '18446744073709551615' : (int) $limit)
+ $sql .= ' LIMIT ' . ($limit === null ? '18446744073709551615' : (int) $limit)
. ($offset ? ' OFFSET ' . (int) $offset : '');
}
break;
case 'pgsql':
- if ($limit !== NULL) {
+ if ($limit !== null) {
$sql .= ' LIMIT ' . (int) $limit;
}
if ($offset) {
@@ -444,8 +444,8 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
break;
case 'sqlite':
- if ($limit !== NULL || $offset) {
- $sql .= ' LIMIT ' . ($limit === NULL ? '-1' : (int) $limit)
+ if ($limit !== null || $offset) {
+ $sql .= ' LIMIT ' . ($limit === null ? '-1' : (int) $limit)
. ($offset ? ' OFFSET ' . (int) $offset : '');
}
break;
@@ -454,10 +454,10 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
if ($offset) {
// see http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
$sql = 'SELECT * FROM (SELECT t.*, ROWNUM AS "__rnum" FROM (' . $sql . ') t '
- . ($limit !== NULL ? 'WHERE ROWNUM <= ' . ((int) $offset + (int) $limit) : '')
+ . ($limit !== null ? 'WHERE ROWNUM <= ' . ((int) $offset + (int) $limit) : '')
. ') WHERE "__rnum" > '. (int) $offset;
- } elseif ($limit !== NULL) {
+ } elseif ($limit !== null) {
$sql = 'SELECT * FROM (' . $sql . ') WHERE ROWNUM <= ' . (int) $limit;
}
break;
@@ -467,7 +467,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
case 'dblib':
if (version_compare($this->serverVersion, '11.0') >= 0) { // 11 == SQL Server 2012
// requires ORDER BY, see https://technet.microsoft.com/en-us/library/gg699618(v=sql.110).aspx
- if ($limit !== NULL) {
+ if ($limit !== null) {
$sql = sprintf('%s OFFSET %d ROWS FETCH NEXT %d ROWS ONLY', rtrim($sql), $offset, $limit);
} elseif ($offset) {
$sql = sprintf('%s OFFSET %d ROWS', rtrim($sql), $offset);
@@ -480,7 +480,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
if ($offset) {
throw new Dibi\NotSupportedException('Offset is not supported by this database.');
- } elseif ($limit !== NULL) {
+ } elseif ($limit !== null) {
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ') t';
break;
}
@@ -507,7 +507,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Fetches the row at current position and moves the internal cursor to the next position.
- * @param bool TRUE for associative array, FALSE for numeric
+ * @param bool true for associative array, false for numeric
* @return array array on success, nonarray if no next record
*/
public function fetch($assoc)
@@ -519,7 +519,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
- * @return bool TRUE on success, FALSE if unable to seek to specified record
+ * @return bool true on success, false if unable to seek to specified record
*/
public function seek($row)
{
@@ -533,7 +533,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
*/
public function free()
{
- $this->resultSet = NULL;
+ $this->resultSet = null;
}
@@ -548,11 +548,11 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
$columns = [];
for ($i = 0; $i < $count; $i++) {
$row = @$this->resultSet->getColumnMeta($i); // intentionally @
- if ($row === FALSE) {
+ if ($row === false) {
throw new Dibi\NotSupportedException('Driver does not support meta data.');
}
$row = $row + [
- 'table' => NULL,
+ 'table' => null,
'native_type' => 'VAR_STRING',
];
@@ -560,7 +560,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
'name' => $row['name'],
'table' => $row['table'],
'nativetype' => $row['native_type'],
- 'type' => $row['native_type'] === 'TIME' && $this->driverName === 'mysql' ? Dibi\Type::TIME_INTERVAL : NULL,
+ 'type' => $row['native_type'] === 'TIME' && $this->driverName === 'mysql' ? Dibi\Type::TIME_INTERVAL : null,
'fullname' => $row['table'] ? $row['table'] . '.' . $row['name'] : $row['name'],
'vendor' => $row,
];
@@ -571,7 +571,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the result set resource.
- * @return \PDOStatement|NULL
+ * @return \PDOStatement|null
*/
public function getResultResource()
{
diff --git a/src/Dibi/Drivers/PostgreDriver.php b/src/Dibi/Drivers/PostgreDriver.php
index fd53a193..5f274599 100644
--- a/src/Dibi/Drivers/PostgreDriver.php
+++ b/src/Dibi/Drivers/PostgreDriver.php
@@ -26,17 +26,17 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
{
use Dibi\Strict;
- /** @var resource|NULL */
+ /** @var resource|null */
private $connection;
- /** @var resource|NULL */
+ /** @var resource|null */
private $resultSet;
/** @var bool */
- private $autoFree = TRUE;
+ private $autoFree = true;
- /** @var int|FALSE Affected rows */
- private $affectedRows = FALSE;
+ /** @var int|false Affected rows */
+ private $affectedRows = false;
/**
@@ -57,7 +57,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
*/
public function connect(array &$config)
{
- $error = NULL;
+ $error = null;
if (isset($config['resource'])) {
$this->connection = $config['resource'];
@@ -128,16 +128,16 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Executes the SQL query.
* @param string SQL statement.
- * @return Dibi\ResultDriver|NULL
+ * @return Dibi\ResultDriver|null
* @throws Dibi\DriverException
*/
public function query($sql)
{
- $this->affectedRows = FALSE;
+ $this->affectedRows = false;
$res = @pg_query($this->connection, $sql); // intentionally @
- if ($res === FALSE) {
- throw self::createException(pg_last_error($this->connection), NULL, $sql);
+ if ($res === false) {
+ throw self::createException(pg_last_error($this->connection), null, $sql);
} elseif (is_resource($res)) {
$this->affectedRows = pg_affected_rows($res);
@@ -145,21 +145,21 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
return $this->createResultDriver($res);
}
}
- return NULL;
+ return null;
}
/**
* @return Dibi\DriverException
*/
- public static function createException($message, $code = NULL, $sql = NULL)
+ public static function createException($message, $code = null, $sql = null)
{
- if ($code === NULL && preg_match('#^ERROR:\s+(\S+):\s*#', $message, $m)) {
+ if ($code === null && preg_match('#^ERROR:\s+(\S+):\s*#', $message, $m)) {
$code = $m[1];
$message = substr($message, strlen($m[0]));
}
- if ($code === '0A000' && strpos($message, 'truncate') !== FALSE) {
+ if ($code === '0A000' && strpos($message, 'truncate') !== false) {
return new Dibi\ForeignKeyConstraintViolationException($message, $code, $sql);
} elseif ($code === '23502') {
@@ -179,7 +179,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
- * @return int|FALSE number of rows or FALSE on error
+ * @return int|false number of rows or false on error
*/
public function getAffectedRows()
{
@@ -189,11 +189,11 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
- * @return int|FALSE int on success or FALSE on failure
+ * @return int|false int on success or false on failure
*/
public function getInsertId($sequence)
{
- if ($sequence === NULL) {
+ if ($sequence === null) {
// PostgreSQL 8.1 is needed
$res = $this->query('SELECT LASTVAL()');
} else {
@@ -201,11 +201,11 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
}
if (!$res) {
- return FALSE;
+ return false;
}
- $row = $res->fetch(FALSE);
- return is_array($row) ? $row[0] : FALSE;
+ $row = $res->fetch(false);
+ return is_array($row) ? $row[0] : false;
}
@@ -215,7 +215,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
* @return void
* @throws Dibi\DriverException
*/
- public function begin($savepoint = NULL)
+ public function begin($savepoint = null)
{
$this->query($savepoint ? "SAVEPOINT $savepoint" : 'START TRANSACTION');
}
@@ -227,7 +227,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
* @return void
* @throws Dibi\DriverException
*/
- public function commit($savepoint = NULL)
+ public function commit($savepoint = null)
{
$this->query($savepoint ? "RELEASE SAVEPOINT $savepoint" : 'COMMIT');
}
@@ -239,7 +239,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
* @return void
* @throws Dibi\DriverException
*/
- public function rollback($savepoint = NULL)
+ public function rollback($savepoint = null)
{
$this->query($savepoint ? "ROLLBACK TO SAVEPOINT $savepoint" : 'ROLLBACK');
}
@@ -251,17 +251,17 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
*/
public function inTransaction()
{
- return !in_array(pg_transaction_status($this->connection), [PGSQL_TRANSACTION_UNKNOWN, PGSQL_TRANSACTION_IDLE], TRUE);
+ return !in_array(pg_transaction_status($this->connection), [PGSQL_TRANSACTION_UNKNOWN, PGSQL_TRANSACTION_IDLE], true);
}
/**
* Returns the connection resource.
- * @return resource|NULL
+ * @return resource|null
*/
public function getResource()
{
- return is_resource($this->connection) ? $this->connection : NULL;
+ return is_resource($this->connection) ? $this->connection : null;
}
@@ -402,8 +402,8 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
- * @param int|NULL
- * @param int|NULL
+ * @param int|null
+ * @param int|null
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -411,7 +411,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
if ($limit < 0 || $offset < 0) {
throw new Dibi\NotSupportedException('Negative offset or limit.');
}
- if ($limit !== NULL) {
+ if ($limit !== null) {
$sql .= ' LIMIT ' . (int) $limit;
}
if ($offset) {
@@ -445,19 +445,19 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Fetches the row at current position and moves the internal cursor to the next position.
- * @param bool TRUE for associative array, FALSE for numeric
+ * @param bool true for associative array, false for numeric
* @return array array on success, nonarray if no next record
*/
public function fetch($assoc)
{
- return pg_fetch_array($this->resultSet, NULL, $assoc ? PGSQL_ASSOC : PGSQL_NUM);
+ return pg_fetch_array($this->resultSet, null, $assoc ? PGSQL_ASSOC : PGSQL_NUM);
}
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
- * @return bool TRUE on success, FALSE if unable to seek to specified record
+ * @return bool true on success, false if unable to seek to specified record
*/
public function seek($row)
{
@@ -472,7 +472,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
public function free()
{
pg_free_result($this->resultSet);
- $this->resultSet = NULL;
+ $this->resultSet = null;
}
@@ -499,12 +499,12 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
/**
* Returns the result set resource.
- * @return resource|NULL
+ * @return resource|null
*/
public function getResultResource()
{
- $this->autoFree = FALSE;
- return is_resource($this->resultSet) ? $this->resultSet : NULL;
+ $this->autoFree = false;
+ return is_resource($this->resultSet) ? $this->resultSet : null;
}
@@ -601,13 +601,13 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
}
$columns = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$size = (int) max($row['character_maximum_length'], $row['numeric_precision']);
$columns[] = [
'name' => $row['column_name'],
'table' => $table,
'nativetype' => strtoupper($row['udt_name']),
- 'size' => $size > 0 ? $size : NULL,
+ 'size' => $size > 0 ? $size : null,
'nullable' => $row['is_nullable'] === 'YES' || $row['is_nullable'] === 't',
'default' => $row['column_default'],
'autoincrement' => (int) $row['ordinal_position'] === $primary && substr($row['column_default'], 0, 7) === 'nextval',
@@ -641,7 +641,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
");
$columns = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$columns[$row['ordinal_position']] = $row['column_name'];
}
@@ -654,7 +654,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
");
$indexes = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$indexes[$row['relname']]['name'] = $row['relname'];
$indexes[$row['relname']]['unique'] = $row['indisunique'] === 't';
$indexes[$row['relname']]['primary'] = $row['indisprimary'] === 't';
@@ -715,7 +715,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
");
$fKeys = $references = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
if (!isset($fKeys[$row['name']])) {
$fKeys[$row['name']] = [
'name' => $row['name'],
diff --git a/src/Dibi/Drivers/Sqlite3Driver.php b/src/Dibi/Drivers/Sqlite3Driver.php
index c9e936fe..077279fe 100644
--- a/src/Dibi/Drivers/Sqlite3Driver.php
+++ b/src/Dibi/Drivers/Sqlite3Driver.php
@@ -27,14 +27,14 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
{
use Dibi\Strict;
- /** @var SQLite3|NULL */
+ /** @var SQLite3|null */
private $connection;
- /** @var \SQLite3Result|NULL */
+ /** @var \SQLite3Result|null */
private $resultSet;
/** @var bool */
- private $autoFree = TRUE;
+ private $autoFree = true;
/** @var string Date and datetime format */
private $fmtDate, $fmtDateTime;
@@ -78,7 +78,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
$this->dbcharset = empty($config['dbcharset']) ? 'UTF-8' : $config['dbcharset'];
$this->charset = empty($config['charset']) ? 'UTF-8' : $config['charset'];
if (strcasecmp($this->dbcharset, $this->charset) === 0) {
- $this->dbcharset = $this->charset = NULL;
+ $this->dbcharset = $this->charset = null;
}
// enable foreign keys support (defaultly disabled; if disabled then foreign key constraints are not enforced)
@@ -102,12 +102,12 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
/**
* Executes the SQL query.
* @param string SQL statement.
- * @return Dibi\ResultDriver|NULL
+ * @return Dibi\ResultDriver|null
* @throws Dibi\DriverException
*/
public function query($sql)
{
- if ($this->dbcharset !== NULL) {
+ if ($this->dbcharset !== null) {
$sql = iconv($this->charset, $this->dbcharset . '//IGNORE', $sql);
}
@@ -118,7 +118,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
} elseif ($res instanceof \SQLite3Result) {
return $this->createResultDriver($res);
}
- return NULL;
+ return null;
}
@@ -130,19 +130,19 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
if ($code !== 19) {
return new Dibi\DriverException($message, $code, $sql);
- } elseif (strpos($message, 'must be unique') !== FALSE
- || strpos($message, 'is not unique') !== FALSE
- || strpos($message, 'UNIQUE constraint failed') !== FALSE
+ } elseif (strpos($message, 'must be unique') !== false
+ || strpos($message, 'is not unique') !== false
+ || strpos($message, 'UNIQUE constraint failed') !== false
) {
return new Dibi\UniqueConstraintViolationException($message, $code, $sql);
- } elseif (strpos($message, 'may not be NULL') !== FALSE
- || strpos($message, 'NOT NULL constraint failed') !== FALSE
+ } elseif (strpos($message, 'may not be NULL') !== false
+ || strpos($message, 'NOT NULL constraint failed') !== false
) {
return new Dibi\NotNullConstraintViolationException($message, $code, $sql);
- } elseif (strpos($message, 'foreign key constraint failed') !== FALSE
- || strpos($message, 'FOREIGN KEY constraint failed') !== FALSE
+ } elseif (strpos($message, 'foreign key constraint failed') !== false
+ || strpos($message, 'FOREIGN KEY constraint failed') !== false
) {
return new Dibi\ForeignKeyConstraintViolationException($message, $code, $sql);
@@ -154,7 +154,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
- * @return int|FALSE number of rows or FALSE on error
+ * @return int|false number of rows or false on error
*/
public function getAffectedRows()
{
@@ -164,7 +164,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
- * @return int|FALSE int on success or FALSE on failure
+ * @return int|false int on success or false on failure
*/
public function getInsertId($sequence)
{
@@ -178,7 +178,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function begin($savepoint = NULL)
+ public function begin($savepoint = null)
{
$this->query($savepoint ? "SAVEPOINT $savepoint" : 'BEGIN');
}
@@ -190,7 +190,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function commit($savepoint = NULL)
+ public function commit($savepoint = null)
{
$this->query($savepoint ? "RELEASE SAVEPOINT $savepoint" : 'COMMIT');
}
@@ -202,7 +202,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function rollback($savepoint = NULL)
+ public function rollback($savepoint = null)
{
$this->query($savepoint ? "ROLLBACK TO SAVEPOINT $savepoint" : 'ROLLBACK');
}
@@ -346,8 +346,8 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
- * @param int|NULL
- * @param int|NULL
+ * @param int|null
+ * @param int|null
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -355,8 +355,8 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
if ($limit < 0 || $offset < 0) {
throw new Dibi\NotSupportedException('Negative offset or limit.');
- } elseif ($limit !== NULL || $offset) {
- $sql .= ' LIMIT ' . ($limit === NULL ? '-1' : (int) $limit)
+ } elseif ($limit !== null || $offset) {
+ $sql .= ' LIMIT ' . ($limit === null ? '-1' : (int) $limit)
. ($offset ? ' OFFSET ' . (int) $offset : '');
}
}
@@ -388,17 +388,17 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
/**
* Fetches the row at current position and moves the internal cursor to the next position.
- * @param bool TRUE for associative array, FALSE for numeric
+ * @param bool true for associative array, false for numeric
* @return array array on success, nonarray if no next record
*/
public function fetch($assoc)
{
$row = $this->resultSet->fetchArray($assoc ? SQLITE3_ASSOC : SQLITE3_NUM);
- $charset = $this->charset === NULL ? NULL : $this->charset . '//TRANSLIT';
+ $charset = $this->charset === null ? null : $this->charset . '//TRANSLIT';
if ($row && ($assoc || $charset)) {
$tmp = [];
foreach ($row as $k => $v) {
- if ($charset !== NULL && is_string($v)) {
+ if ($charset !== null && is_string($v)) {
$v = iconv($this->dbcharset, $charset, $v);
}
$tmp[str_replace(['[', ']'], '', $k)] = $v;
@@ -412,7 +412,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
- * @return bool TRUE on success, FALSE if unable to seek to specified record
+ * @return bool true on success, false if unable to seek to specified record
* @throws Dibi\NotSupportedException
*/
public function seek($row)
@@ -428,7 +428,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
public function free()
{
$this->resultSet->finalize();
- $this->resultSet = NULL;
+ $this->resultSet = null;
}
@@ -444,7 +444,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
for ($i = 0; $i < $count; $i++) {
$columns[] = [
'name' => $this->resultSet->columnName($i),
- 'table' => NULL,
+ 'table' => null,
'fullname' => $this->resultSet->columnName($i),
'nativetype' => $types[$this->resultSet->columnType($i)],
];
@@ -455,11 +455,11 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the result set resource.
- * @return \SQLite3Result|NULL
+ * @return \SQLite3Result|null
*/
public function getResultResource()
{
- $this->autoFree = FALSE;
+ $this->autoFree = false;
return $this->resultSet;
}
diff --git a/src/Dibi/Drivers/SqliteReflector.php b/src/Dibi/Drivers/SqliteReflector.php
index f7ba46ef..4058888c 100644
--- a/src/Dibi/Drivers/SqliteReflector.php
+++ b/src/Dibi/Drivers/SqliteReflector.php
@@ -41,7 +41,7 @@ class SqliteReflector implements Dibi\Reflector
ORDER BY name
");
$tables = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$tables[] = $row;
}
return $tables;
@@ -57,7 +57,7 @@ class SqliteReflector implements Dibi\Reflector
{
$res = $this->driver->query("PRAGMA table_info({$this->driver->escapeIdentifier($table)})");
$columns = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$column = $row['name'];
$type = explode('(', $row['type']);
$columns[] = [
@@ -65,7 +65,7 @@ class SqliteReflector implements Dibi\Reflector
'table' => $table,
'fullname' => "$table.$column",
'nativetype' => strtoupper($type[0]),
- 'size' => isset($type[1]) ? (int) $type[1] : NULL,
+ 'size' => isset($type[1]) ? (int) $type[1] : null,
'nullable' => $row['notnull'] == '0',
'default' => $row['dflt_value'],
'autoincrement' => $row['pk'] && $type[0] === 'INTEGER',
@@ -85,14 +85,14 @@ class SqliteReflector implements Dibi\Reflector
{
$res = $this->driver->query("PRAGMA index_list({$this->driver->escapeIdentifier($table)})");
$indexes = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$indexes[$row['name']]['name'] = $row['name'];
$indexes[$row['name']]['unique'] = (bool) $row['unique'];
}
foreach ($indexes as $index => $values) {
$res = $this->driver->query("PRAGMA index_info({$this->driver->escapeIdentifier($index)})");
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$indexes[$index]['columns'][$row['seqno']] = $row['name'];
}
}
@@ -100,7 +100,7 @@ class SqliteReflector implements Dibi\Reflector
$columns = $this->getColumns($table);
foreach ($indexes as $index => $values) {
$column = $indexes[$index]['columns'][0];
- $primary = FALSE;
+ $primary = false;
foreach ($columns as $info) {
if ($column == $info['name']) {
$primary = $info['vendor']['pk'];
@@ -114,8 +114,8 @@ class SqliteReflector implements Dibi\Reflector
if ($column['vendor']['pk']) {
$indexes[] = [
'name' => 'ROWID',
- 'unique' => TRUE,
- 'primary' => TRUE,
+ 'unique' => true,
+ 'primary' => true,
'columns' => [$column['name']],
];
break;
@@ -136,7 +136,7 @@ class SqliteReflector implements Dibi\Reflector
{
$res = $this->driver->query("PRAGMA foreign_key_list({$this->driver->escapeIdentifier($table)})");
$keys = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$keys[$row['id']]['name'] = $row['id']; // foreign key name
$keys[$row['id']]['local'][$row['seq']] = $row['from']; // local columns
$keys[$row['id']]['table'] = $row['table']; // referenced table
@@ -144,8 +144,8 @@ class SqliteReflector implements Dibi\Reflector
$keys[$row['id']]['onDelete'] = $row['on_delete'];
$keys[$row['id']]['onUpdate'] = $row['on_update'];
- if ($keys[$row['id']]['foreign'][0] == NULL) {
- $keys[$row['id']]['foreign'] = NULL;
+ if ($keys[$row['id']]['foreign'][0] == null) {
+ $keys[$row['id']]['foreign'] = null;
}
}
return array_values($keys);
diff --git a/src/Dibi/Drivers/SqlsrvDriver.php b/src/Dibi/Drivers/SqlsrvDriver.php
index 652fb12a..469216ec 100644
--- a/src/Dibi/Drivers/SqlsrvDriver.php
+++ b/src/Dibi/Drivers/SqlsrvDriver.php
@@ -29,17 +29,17 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
{
use Dibi\Strict;
- /** @var resource|NULL */
+ /** @var resource|null */
private $connection;
- /** @var resource|NULL */
+ /** @var resource|null */
private $resultSet;
/** @var bool */
- private $autoFree = TRUE;
+ private $autoFree = true;
- /** @var int|FALSE Affected rows */
- private $affectedRows = FALSE;
+ /** @var int|false Affected rows */
+ private $affectedRows = false;
/** @var string */
private $version = '';
@@ -106,15 +106,15 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Executes the SQL query.
* @param string SQL statement.
- * @return Dibi\ResultDriver|NULL
+ * @return Dibi\ResultDriver|null
* @throws Dibi\DriverException
*/
public function query($sql)
{
- $this->affectedRows = FALSE;
+ $this->affectedRows = false;
$res = sqlsrv_query($this->connection, $sql);
- if ($res === FALSE) {
+ if ($res === false) {
$info = sqlsrv_errors();
throw new Dibi\DriverException($info[0]['message'], $info[0]['code'], $sql);
@@ -122,13 +122,13 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
$this->affectedRows = sqlsrv_rows_affected($res);
return $this->createResultDriver($res);
}
- return NULL;
+ return null;
}
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
- * @return int|FALSE number of rows or FALSE on error
+ * @return int|false number of rows or false on error
*/
public function getAffectedRows()
{
@@ -138,7 +138,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
- * @return int|FALSE int on success or FALSE on failure
+ * @return int|false int on success or false on failure
*/
public function getInsertId($sequence)
{
@@ -147,7 +147,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
$row = sqlsrv_fetch_array($res, SQLSRV_FETCH_NUMERIC);
return $row[0];
}
- return FALSE;
+ return false;
}
@@ -157,7 +157,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function begin($savepoint = NULL)
+ public function begin($savepoint = null)
{
sqlsrv_begin_transaction($this->connection);
}
@@ -169,7 +169,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function commit($savepoint = NULL)
+ public function commit($savepoint = null)
{
sqlsrv_commit($this->connection);
}
@@ -181,7 +181,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
* @return void
* @throws Dibi\DriverException
*/
- public function rollback($savepoint = NULL)
+ public function rollback($savepoint = null)
{
sqlsrv_rollback($this->connection);
}
@@ -189,11 +189,11 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the connection resource.
- * @return resource|NULL
+ * @return resource|null
*/
public function getResource()
{
- return is_resource($this->connection) ? $this->connection : NULL;
+ return is_resource($this->connection) ? $this->connection : null;
}
@@ -326,8 +326,8 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
- * @param int|NULL
- * @param int|NULL
+ * @param int|null
+ * @param int|null
* @return void
*/
public function applyLimit(&$sql, $limit, $offset)
@@ -339,11 +339,11 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
if ($offset) {
throw new Dibi\NotSupportedException('Offset is not supported by this database.');
- } elseif ($limit !== NULL) {
+ } elseif ($limit !== null) {
$sql = sprintf('SELECT TOP (%d) * FROM (%s) t', $limit, $sql);
}
- } elseif ($limit !== NULL) {
+ } elseif ($limit !== null) {
// requires ORDER BY, see https://technet.microsoft.com/en-us/library/gg699618(v=sql.110).aspx
$sql = sprintf('%s OFFSET %d ROWS FETCH NEXT %d ROWS ONLY', rtrim($sql), $offset, $limit);
} elseif ($offset) {
@@ -378,7 +378,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Fetches the row at current position and moves the internal cursor to the next position.
- * @param bool TRUE for associative array, FALSE for numeric
+ * @param bool true for associative array, false for numeric
* @return array array on success, nonarray if no next record
*/
public function fetch($assoc)
@@ -390,7 +390,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
- * @return bool TRUE on success, FALSE if unable to seek to specified record
+ * @return bool true on success, false if unable to seek to specified record
*/
public function seek($row)
{
@@ -405,7 +405,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
public function free()
{
sqlsrv_free_stmt($this->resultSet);
- $this->resultSet = NULL;
+ $this->resultSet = null;
}
@@ -429,11 +429,11 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
/**
* Returns the result set resource.
- * @return resource|NULL
+ * @return resource|null
*/
public function getResultResource()
{
- $this->autoFree = FALSE;
- return is_resource($this->resultSet) ? $this->resultSet : NULL;
+ $this->autoFree = false;
+ return is_resource($this->resultSet) ? $this->resultSet : null;
}
}
diff --git a/src/Dibi/Drivers/SqlsrvReflector.php b/src/Dibi/Drivers/SqlsrvReflector.php
index 748783e9..ba80f4c3 100644
--- a/src/Dibi/Drivers/SqlsrvReflector.php
+++ b/src/Dibi/Drivers/SqlsrvReflector.php
@@ -36,7 +36,7 @@ class SqlsrvReflector implements Dibi\Reflector
{
$res = $this->driver->query("SELECT TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES WHERE [TABLE_SCHEMA] = 'dbo'");
$tables = [];
- while ($row = $res->fetch(FALSE)) {
+ while ($row = $res->fetch(false)) {
$tables[] = [
'name' => $row[0],
'view' => isset($row[1]) && $row[1] === 'VIEW',
@@ -61,7 +61,7 @@ class SqlsrvReflector implements Dibi\Reflector
");
$autoIncrements = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$autoIncrements[$row['COLUMN_NAME']] = (bool) $row['AUTO_INCREMENT'];
}
@@ -81,13 +81,13 @@ class SqlsrvReflector implements Dibi\Reflector
WHERE C.TABLE_NAME = {$this->driver->escapeText($table)}
");
$columns = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$columns[] = [
'name' => $row['COLUMN_NAME'],
'table' => $table,
'nativetype' => strtoupper($row['DATA_TYPE']),
'size' => $row['CHARACTER_MAXIMUM_LENGTH'],
- 'unsigned' => TRUE,
+ 'unsigned' => true,
'nullable' => $row['IS_NULLABLE'] === 'YES',
'default' => $row['COLUMN_DEFAULT'],
'autoincrement' => $autoIncrements[$row['COLUMN_NAME']],
@@ -107,13 +107,13 @@ class SqlsrvReflector implements Dibi\Reflector
{
$keyUsagesRes = $this->driver->query(sprintf("EXEC [sys].[sp_helpindex] @objname = N%s", $this->driver->escapeText($table)));
$keyUsages = [];
- while ($row = $keyUsagesRes->fetch(TRUE)) {
+ while ($row = $keyUsagesRes->fetch(true)) {
$keyUsages[$row['index_name']] = explode(',', $row['index_keys']);
}
$res = $this->driver->query("SELECT [i].* FROM [sys].[indexes] [i] INNER JOIN [sys].[tables] [t] ON [i].[object_id] = [t].[object_id] WHERE [t].[name] = {$this->driver->escapeText($table)}");
$indexes = [];
- while ($row = $res->fetch(TRUE)) {
+ while ($row = $res->fetch(true)) {
$indexes[$row['name']]['name'] = $row['name'];
$indexes[$row['name']]['unique'] = $row['is_unique'] === 1;
$indexes[$row['name']]['primary'] = $row['is_primary_key'] === 1;
diff --git a/src/Dibi/Event.php b/src/Dibi/Event.php
index 6a521d0e..0eb4699a 100644
--- a/src/Dibi/Event.php
+++ b/src/Dibi/Event.php
@@ -37,7 +37,7 @@ class Event
/** @var string */
public $sql;
- /** @var Result|DriverException|NULL */
+ /** @var Result|DriverException|null */
public $result;
/** @var float */
@@ -50,12 +50,12 @@ class Event
public $source;
- public function __construct(Connection $connection, $type, $sql = NULL)
+ public function __construct(Connection $connection, $type, $sql = null)
{
$this->connection = $connection;
$this->type = $type;
$this->sql = trim($sql);
- $this->time = -microtime(TRUE);
+ $this->time = -microtime(true);
if ($type === self::QUERY && preg_match('#\(?\s*(SELECT|UPDATE|INSERT|DELETE)#iA', $this->sql, $matches)) {
static $types = [
@@ -67,29 +67,29 @@ class Event
$rc = new \ReflectionClass('dibi');
$dibiDir = dirname($rc->getFileName()) . DIRECTORY_SEPARATOR;
- foreach (debug_backtrace(FALSE) as $row) {
+ foreach (debug_backtrace(false) as $row) {
if (isset($row['file']) && is_file($row['file']) && strpos($row['file'], $dibiDir) !== 0) {
$this->source = [$row['file'], (int) $row['line']];
break;
}
}
- \dibi::$elapsedTime = FALSE;
+ \dibi::$elapsedTime = false;
\dibi::$numOfQueries++;
\dibi::$sql = $sql;
}
- public function done($result = NULL)
+ public function done($result = null)
{
$this->result = $result;
try {
- $this->count = $result instanceof Result ? count($result) : NULL;
+ $this->count = $result instanceof Result ? count($result) : null;
} catch (Exception $e) {
- $this->count = NULL;
+ $this->count = null;
}
- $this->time += microtime(TRUE);
+ $this->time += microtime(true);
\dibi::$elapsedTime = $this->time;
\dibi::$totalTime += $this->time;
return $this;
diff --git a/src/Dibi/Fluent.php b/src/Dibi/Fluent.php
index 7eb2960c..6288866b 100644
--- a/src/Dibi/Fluent.php
+++ b/src/Dibi/Fluent.php
@@ -33,7 +33,7 @@ class Fluent implements IDataSource
{
use Strict;
- const REMOVE = FALSE;
+ const REMOVE = false;
/** @var array */
public static $masks = [
@@ -65,11 +65,11 @@ class Fluent implements IDataSource
'GROUP BY' => ',',
'HAVING' => 'AND',
'ORDER BY' => ',',
- 'LIMIT' => FALSE,
- 'OFFSET' => FALSE,
+ 'LIMIT' => false,
+ 'OFFSET' => false,
'SET' => ',',
'VALUES' => ',',
- 'INTO' => FALSE,
+ 'INTO' => false,
];
/** @var array clauses */
@@ -109,7 +109,7 @@ class Fluent implements IDataSource
{
$this->connection = $connection;
- if (self::$normalizer === NULL) {
+ if (self::$normalizer === null) {
self::$normalizer = new HashMap([__CLASS__, '_formatClause']);
}
}
@@ -126,9 +126,9 @@ class Fluent implements IDataSource
$clause = self::$normalizer->$clause;
// lazy initialization
- if ($this->command === NULL) {
+ if ($this->command === null) {
if (isset(self::$masks[$clause])) {
- $this->clauses = array_fill_keys(self::$masks[$clause], NULL);
+ $this->clauses = array_fill_keys(self::$masks[$clause], null);
}
$this->cursor = &$this->clauses[$clause];
$this->cursor = [];
@@ -146,13 +146,13 @@ class Fluent implements IDataSource
// TODO: really delete?
if ($args === [self::REMOVE]) {
- $this->cursor = NULL;
+ $this->cursor = null;
return $this;
}
if (isset(self::$separators[$clause])) {
$sep = self::$separators[$clause];
- if ($sep === FALSE) { // means: replace
+ if ($sep === false) { // means: replace
$this->cursor = [];
} elseif (!empty($this->cursor)) {
@@ -169,15 +169,15 @@ class Fluent implements IDataSource
$this->cursor[] = $clause;
}
- if ($this->cursor === NULL) {
+ if ($this->cursor === null) {
$this->cursor = [];
}
// special types or argument
if (count($args) === 1) {
$arg = $args[0];
- // TODO: really ignore TRUE?
- if ($arg === TRUE) { // flag
+ // TODO: really ignore true?
+ if ($arg === true) { // flag
return $this;
} elseif (is_string($arg) && preg_match('#^[a-z:_][a-z0-9_.:]*\z#i', $arg)) { // identifier
@@ -190,7 +190,7 @@ class Fluent implements IDataSource
} elseif (is_string(key($arg))) { // associative array
$args = ['%a', $arg];
}
- } // case $arg === FALSE is handled above
+ } // case $arg === false is handled above
}
foreach ($args as $arg) {
@@ -212,7 +212,7 @@ class Fluent implements IDataSource
public function clause($clause)
{
$this->cursor = &$this->clauses[self::$normalizer->$clause];
- if ($this->cursor === NULL) {
+ if ($this->cursor === null) {
$this->cursor = [];
}
@@ -227,7 +227,7 @@ class Fluent implements IDataSource
*/
public function removeClause($clause)
{
- $this->clauses[self::$normalizer->$clause] = NULL;
+ $this->clauses[self::$normalizer->$clause] = null;
return $this;
}
@@ -238,11 +238,11 @@ class Fluent implements IDataSource
* @param bool value
* @return self
*/
- public function setFlag($flag, $value = TRUE)
+ public function setFlag($flag, $value = true)
{
$flag = strtoupper($flag);
if ($value) {
- $this->flags[$flag] = TRUE;
+ $this->flags[$flag] = true;
} else {
unset($this->flags[$flag]);
}
@@ -303,7 +303,7 @@ class Fluent implements IDataSource
* @return Result|int result set or number of affected rows
* @throws Exception
*/
- public function execute($return = NULL)
+ public function execute($return = null)
{
$res = $this->query($this->_export());
switch ($return) {
@@ -319,12 +319,12 @@ class Fluent implements IDataSource
/**
* Generates, executes SQL query and fetches the single row.
- * @return Row|FALSE
+ * @return Row|false
*/
public function fetch()
{
if ($this->command === 'SELECT' && !$this->clauses['LIMIT']) {
- return $this->query($this->_export(NULL, ['%lmt', 1]))->fetch();
+ return $this->query($this->_export(null, ['%lmt', 1]))->fetch();
} else {
return $this->query($this->_export())->fetch();
}
@@ -333,12 +333,12 @@ class Fluent implements IDataSource
/**
* Like fetch(), but returns only first field.
- * @return mixed value on success, FALSE if no next record
+ * @return mixed value on success, false if no next record
*/
public function fetchSingle()
{
if ($this->command === 'SELECT' && !$this->clauses['LIMIT']) {
- return $this->query($this->_export(NULL, ['%lmt', 1]))->fetchSingle();
+ return $this->query($this->_export(null, ['%lmt', 1]))->fetchSingle();
} else {
return $this->query($this->_export())->fetchSingle();
}
@@ -351,9 +351,9 @@ class Fluent implements IDataSource
* @param int limit
* @return array
*/
- public function fetchAll($offset = NULL, $limit = NULL)
+ public function fetchAll($offset = null, $limit = null)
{
- return $this->query($this->_export(NULL, ['%ofs %lmt', $offset, $limit]))->fetchAll();
+ return $this->query($this->_export(null, ['%ofs %lmt', $offset, $limit]))->fetchAll();
}
@@ -374,7 +374,7 @@ class Fluent implements IDataSource
* @param string value
* @return array
*/
- public function fetchPairs($key = NULL, $value = NULL)
+ public function fetchPairs($key = null, $value = null)
{
return $this->query($this->_export())->fetchPairs($key, $value);
}
@@ -386,9 +386,9 @@ class Fluent implements IDataSource
* @param int limit
* @return ResultIterator
*/
- public function getIterator($offset = NULL, $limit = NULL)
+ public function getIterator($offset = null, $limit = null)
{
- return $this->query($this->_export(NULL, ['%ofs %lmt', $offset, $limit]))->getIterator();
+ return $this->query($this->_export(null, ['%ofs %lmt', $offset, $limit]))->getIterator();
}
@@ -397,7 +397,7 @@ class Fluent implements IDataSource
* @param string clause name
* @return bool
*/
- public function test($clause = NULL)
+ public function test($clause = null)
{
return $this->connection->test($this->_export($clause));
}
@@ -458,9 +458,9 @@ class Fluent implements IDataSource
* @param string clause name
* @return array
*/
- protected function _export($clause = NULL, $args = [])
+ protected function _export($clause = null, $args = [])
{
- if ($clause === NULL) {
+ if ($clause === null) {
$data = $this->clauses;
if ($this->command === 'SELECT' && ($data['LIMIT'] || $data['OFFSET'])) {
$args = array_merge(['%lmt %ofs', $data['LIMIT'][0], $data['OFFSET'][0]], $args);
@@ -477,7 +477,7 @@ class Fluent implements IDataSource
}
foreach ($data as $clause => $statement) {
- if ($statement !== NULL) {
+ if ($statement !== null) {
$args[] = $clause;
if ($clause === $this->command && $this->flags) {
$args[] = implode(' ', array_keys($this->flags));
diff --git a/src/Dibi/Helpers.php b/src/Dibi/Helpers.php
index 5bcd709e..bda55799 100644
--- a/src/Dibi/Helpers.php
+++ b/src/Dibi/Helpers.php
@@ -22,7 +22,7 @@ class Helpers
* @param bool return output instead of printing it?
* @return string
*/
- public static function dump($sql = NULL, $return = FALSE)
+ public static function dump($sql = null, $return = false)
{
ob_start();
if ($sql instanceof Result && PHP_SAPI === 'cli') {
@@ -68,7 +68,7 @@ class Helpers
: "\n\n";
} else {
- if ($sql === NULL) {
+ if ($sql === null) {
$sql = \dibi::$sql;
}
@@ -136,12 +136,12 @@ class Helpers
/**
* Finds the best suggestion.
- * @return string|NULL
+ * @return string|null
* @internal
*/
public static function getSuggestion(array $items, $value)
{
- $best = NULL;
+ $best = null;
$min = (strlen($value) / 4 + 1) * 10 + .1;
foreach (array_unique($items, SORT_REGULAR) as $item) {
$item = is_object($item) ? $item->getName() : $item;
@@ -176,7 +176,7 @@ class Helpers
/**
* Heuristic type detection.
* @param string
- * @return string|NULL
+ * @return string|null
* @internal
*/
public static function detectType($type)
@@ -198,7 +198,7 @@ class Helpers
return $val;
}
}
- return NULL;
+ return null;
}
@@ -207,7 +207,7 @@ class Helpers
*/
public static function getTypeCache()
{
- if (self::$types === NULL) {
+ if (self::$types === null) {
self::$types = new HashMap([__CLASS__, 'detectType']);
}
return self::$types;
@@ -239,7 +239,7 @@ class Helpers
* Import SQL dump from file.
* @return int count of sql commands
*/
- public static function loadFromFile(Connection $connection, $file, callable $onProgress = NULL)
+ public static function loadFromFile(Connection $connection, $file, callable $onProgress = null)
{
@set_time_limit(0); // intentionally @
@@ -253,7 +253,7 @@ class Helpers
$delimiter = ';';
$sql = '';
$driver = $connection->getDriver();
- while (($s = fgets($handle)) !== FALSE) {
+ while (($s = fgets($handle)) !== false) {
$size += strlen($s);
if (strtoupper(substr($s, 0, 10)) === 'DELIMITER ') {
$delimiter = trim(substr($s, 10));
@@ -264,7 +264,7 @@ class Helpers
$sql = '';
$count++;
if ($onProgress) {
- call_user_func($onProgress, $count, isset($stat['size']) ? $size * 100 / $stat['size'] : NULL);
+ call_user_func($onProgress, $count, isset($stat['size']) ? $size * 100 / $stat['size'] : null);
}
} else {
@@ -276,7 +276,7 @@ class Helpers
$driver->query($sql);
$count++;
if ($onProgress) {
- call_user_func($onProgress, $count, isset($stat['size']) ? 100 : NULL);
+ call_user_func($onProgress, $count, isset($stat['size']) ? 100 : null);
}
}
fclose($handle);
diff --git a/src/Dibi/Loggers/FileLogger.php b/src/Dibi/Loggers/FileLogger.php
index fc3dbb53..c4bfd06f 100644
--- a/src/Dibi/Loggers/FileLogger.php
+++ b/src/Dibi/Loggers/FileLogger.php
@@ -24,7 +24,7 @@ class FileLogger
public $filter;
- public function __construct($file, $filter = NULL)
+ public function __construct($file, $filter = null)
{
$this->file = $file;
$this->filter = $filter ? (int) $filter : Dibi\Event::QUERY;
diff --git a/src/Dibi/Loggers/FirePhpLogger.php b/src/Dibi/Loggers/FirePhpLogger.php
index 843e661a..deee24e4 100644
--- a/src/Dibi/Loggers/FirePhpLogger.php
+++ b/src/Dibi/Loggers/FirePhpLogger.php
@@ -48,7 +48,7 @@ class FirePhpLogger
}
- public function __construct($filter = NULL)
+ public function __construct($filter = null)
{
$this->filter = $filter ? (int) $filter : Dibi\Event::QUERY;
}
diff --git a/src/Dibi/Reflection/Column.php b/src/Dibi/Reflection/Column.php
index 31753cb7..c360c190 100644
--- a/src/Dibi/Reflection/Column.php
+++ b/src/Dibi/Reflection/Column.php
@@ -19,24 +19,24 @@ use Dibi\Type;
* @property-read Table $table
* @property-read string $type
* @property-read mixed $nativeType
- * @property-read int|NULL $size
- * @property-read bool|NULL $unsigned
- * @property-read bool|NULL $nullable
- * @property-read bool|NULL $autoIncrement
+ * @property-read int|null $size
+ * @property-read bool|null $unsigned
+ * @property-read bool|null $nullable
+ * @property-read bool|null $autoIncrement
* @property-read mixed $default
*/
class Column
{
use Dibi\Strict;
- /** @var Dibi\Reflector|NULL when created by Result */
+ /** @var Dibi\Reflector|null when created by Result */
private $reflector;
/** @var array (name, nativetype, [table], [fullname], [size], [nullable], [default], [autoincrement], [vendor]) */
private $info;
- public function __construct(Dibi\Reflector $reflector = NULL, array $info)
+ public function __construct(Dibi\Reflector $reflector = null, array $info)
{
$this->reflector = $reflector;
$this->info = $info;
@@ -57,7 +57,7 @@ class Column
*/
public function getFullName()
{
- return isset($this->info['fullname']) ? $this->info['fullname'] : NULL;
+ return isset($this->info['fullname']) ? $this->info['fullname'] : null;
}
@@ -83,11 +83,11 @@ class Column
/**
- * @return string|NULL
+ * @return string|null
*/
public function getTableName()
{
- return isset($this->info['table']) && $this->info['table'] != NULL ? $this->info['table'] : NULL; // intentionally ==
+ return isset($this->info['table']) && $this->info['table'] != null ? $this->info['table'] : null; // intentionally ==
}
@@ -110,38 +110,38 @@ class Column
/**
- * @return int|NULL
+ * @return int|null
*/
public function getSize()
{
- return isset($this->info['size']) ? (int) $this->info['size'] : NULL;
+ return isset($this->info['size']) ? (int) $this->info['size'] : null;
}
/**
- * @return bool|NULL
+ * @return bool|null
*/
public function isUnsigned()
{
- return isset($this->info['unsigned']) ? (bool) $this->info['unsigned'] : NULL;
+ return isset($this->info['unsigned']) ? (bool) $this->info['unsigned'] : null;
}
/**
- * @return bool|NULL
+ * @return bool|null
*/
public function isNullable()
{
- return isset($this->info['nullable']) ? (bool) $this->info['nullable'] : NULL;
+ return isset($this->info['nullable']) ? (bool) $this->info['nullable'] : null;
}
/**
- * @return bool|NULL
+ * @return bool|null
*/
public function isAutoIncrement()
{
- return isset($this->info['autoincrement']) ? (bool) $this->info['autoincrement'] : NULL;
+ return isset($this->info['autoincrement']) ? (bool) $this->info['autoincrement'] : null;
}
@@ -150,7 +150,7 @@ class Column
*/
public function getDefault()
{
- return isset($this->info['default']) ? $this->info['default'] : NULL;
+ return isset($this->info['default']) ? $this->info['default'] : null;
}
@@ -160,6 +160,6 @@ class Column
*/
public function getVendorInfo($key)
{
- return isset($this->info['vendor'][$key]) ? $this->info['vendor'][$key] : NULL;
+ return isset($this->info['vendor'][$key]) ? $this->info['vendor'][$key] : null;
}
}
diff --git a/src/Dibi/Reflection/Database.php b/src/Dibi/Reflection/Database.php
index 8c46663e..9e2a07b5 100644
--- a/src/Dibi/Reflection/Database.php
+++ b/src/Dibi/Reflection/Database.php
@@ -104,7 +104,7 @@ class Database
*/
protected function init()
{
- if ($this->tables === NULL) {
+ if ($this->tables === null) {
$this->tables = [];
foreach ($this->reflector->getTables() as $info) {
$this->tables[strtolower($info['name'])] = new Table($this->reflector, $info);
diff --git a/src/Dibi/Reflection/Result.php b/src/Dibi/Reflection/Result.php
index b6a5f2f0..c7499056 100644
--- a/src/Dibi/Reflection/Result.php
+++ b/src/Dibi/Reflection/Result.php
@@ -50,7 +50,7 @@ class Result
* @param bool
* @return string[]
*/
- public function getColumnNames($fullNames = FALSE)
+ public function getColumnNames($fullNames = false)
{
$this->initColumns();
$res = [];
@@ -94,9 +94,9 @@ class Result
*/
protected function initColumns()
{
- if ($this->columns === NULL) {
+ if ($this->columns === null) {
$this->columns = [];
- $reflector = $this->driver instanceof Dibi\Reflector ? $this->driver : NULL;
+ $reflector = $this->driver instanceof Dibi\Reflector ? $this->driver : null;
foreach ($this->driver->getResultColumns() as $info) {
$this->columns[] = $this->names[strtolower($info['name'])] = new Column($reflector, $info);
}
diff --git a/src/Dibi/Reflection/Table.php b/src/Dibi/Reflection/Table.php
index c7f4e2b5..bee91246 100644
--- a/src/Dibi/Reflection/Table.php
+++ b/src/Dibi/Reflection/Table.php
@@ -160,7 +160,7 @@ class Table
*/
protected function initColumns()
{
- if ($this->columns === NULL) {
+ if ($this->columns === null) {
$this->columns = [];
foreach ($this->reflector->getColumns($this->name) as $info) {
$this->columns[strtolower($info['name'])] = new Column($this->reflector, $info);
@@ -174,7 +174,7 @@ class Table
*/
protected function initIndexes()
{
- if ($this->indexes === NULL) {
+ if ($this->indexes === null) {
$this->initColumns();
$this->indexes = [];
foreach ($this->reflector->getIndexes($this->name) as $info) {
diff --git a/src/Dibi/Result.php b/src/Dibi/Result.php
index f25d5aee..6c1893ff 100644
--- a/src/Dibi/Result.php
+++ b/src/Dibi/Result.php
@@ -40,7 +40,7 @@ class Result implements IDataSource
private $meta;
/** @var bool Already fetched? Used for allowance for first seek(0) */
- private $fetched = FALSE;
+ private $fetched = false;
/** @var string returned object class */
private $rowClass = 'Dibi\Row';
@@ -78,9 +78,9 @@ class Result implements IDataSource
*/
final public function free()
{
- if ($this->driver !== NULL) {
+ if ($this->driver !== null) {
$this->driver->free();
- $this->driver = $this->meta = NULL;
+ $this->driver = $this->meta = null;
}
}
@@ -92,7 +92,7 @@ class Result implements IDataSource
*/
final public function getResultDriver()
{
- if ($this->driver === NULL) {
+ if ($this->driver === null) {
throw new \RuntimeException('Result-set was released from memory.');
}
@@ -106,12 +106,12 @@ class Result implements IDataSource
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
- * @return bool TRUE on success, FALSE if unable to seek to specified record
+ * @return bool true on success, false if unable to seek to specified record
* @throws Exception
*/
final public function seek($row)
{
- return ($row !== 0 || $this->fetched) ? (bool) $this->getResultDriver()->seek($row) : TRUE;
+ return ($row !== 0 || $this->fetched) ? (bool) $this->getResultDriver()->seek($row) : true;
}
@@ -184,15 +184,15 @@ class Result implements IDataSource
/**
* Fetches the row at current position, process optional type conversion.
* and moves the internal cursor to the next position
- * @return Row|FALSE
+ * @return Row|false
*/
final public function fetch()
{
- $row = $this->getResultDriver()->fetch(TRUE);
+ $row = $this->getResultDriver()->fetch(true);
if (!is_array($row)) {
- return FALSE;
+ return false;
}
- $this->fetched = TRUE;
+ $this->fetched = true;
$this->normalize($row);
if ($this->rowFactory) {
return call_user_func($this->rowFactory, $row);
@@ -205,15 +205,15 @@ class Result implements IDataSource
/**
* Like fetch(), but returns only first field.
- * @return mixed value on success, FALSE if no next record
+ * @return mixed value on success, false if no next record
*/
final public function fetchSingle()
{
- $row = $this->getResultDriver()->fetch(TRUE);
+ $row = $this->getResultDriver()->fetch(true);
if (!is_array($row)) {
- return FALSE;
+ return false;
}
- $this->fetched = TRUE;
+ $this->fetched = true;
$this->normalize($row);
return reset($row);
}
@@ -225,9 +225,9 @@ class Result implements IDataSource
* @param int limit
* @return Row[]
*/
- final public function fetchAll($offset = NULL, $limit = NULL)
+ final public function fetchAll($offset = null, $limit = null)
{
- $limit = $limit === NULL ? -1 : (int) $limit;
+ $limit = $limit === null ? -1 : (int) $limit;
$this->seek((int) $offset);
$row = $this->fetch();
if (!$row) {
@@ -260,7 +260,7 @@ class Result implements IDataSource
*/
final public function fetchAssoc($assoc)
{
- if (strpos($assoc, ',') !== FALSE) {
+ if (strpos($assoc, ',') !== false) {
return $this->oldFetchAssoc($assoc);
}
@@ -270,12 +270,12 @@ class Result implements IDataSource
return []; // empty result set
}
- $data = NULL;
+ $data = null;
$assoc = preg_split('#(\[\]|->|=|\|)#', $assoc, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
// check columns
foreach ($assoc as $as) {
- // offsetExists ignores NULL in PHP 5.2.1, isset() surprisingly NULL accepts
+ // offsetExists ignores null in PHP 5.2.1, isset() surprisingly null accepts
if ($as !== '[]' && $as !== '=' && $as !== '->' && $as !== '|' && !property_exists($row, $as)) {
throw new \InvalidArgumentException("Unknown column '$as' in associative descriptor.");
}
@@ -303,10 +303,10 @@ class Result implements IDataSource
continue 2;
} elseif ($as === '->') { // "object" node
- if ($x === NULL) {
+ if ($x === null) {
$x = clone $row;
$x = &$x->{$assoc[$i + 1]};
- $x = NULL; // prepare child node
+ $x = null; // prepare child node
} else {
$x = &$x->{$assoc[$i + 1]};
}
@@ -316,7 +316,7 @@ class Result implements IDataSource
}
}
- if ($x === NULL) { // build leaf
+ if ($x === null) { // build leaf
$x = $row;
}
} while ($row = $this->fetch());
@@ -337,7 +337,7 @@ class Result implements IDataSource
return []; // empty result set
}
- $data = NULL;
+ $data = null;
$assoc = explode(',', $assoc);
// strip leading = and @
@@ -362,19 +362,19 @@ class Result implements IDataSource
$x = &$x[];
} elseif ($as === '=') { // "record" node
- if ($x === NULL) {
+ if ($x === null) {
$x = $row->toArray();
$x = &$x[ $assoc[$i + 1] ];
- $x = NULL; // prepare child node
+ $x = null; // prepare child node
} else {
$x = &$x[ $assoc[$i + 1] ];
}
} elseif ($as === '@') { // "object" node
- if ($x === NULL) {
+ if ($x === null) {
$x = clone $row;
$x = &$x->{$assoc[$i + 1]};
- $x = NULL; // prepare child node
+ $x = null; // prepare child node
} else {
$x = &$x->{$assoc[$i + 1]};
}
@@ -384,7 +384,7 @@ class Result implements IDataSource
}
}
- if ($x === NULL) { // build leaf
+ if ($x === null) { // build leaf
if ($leaf === '=') {
$x = $row->toArray();
} else {
@@ -405,7 +405,7 @@ class Result implements IDataSource
* @return array
* @throws \InvalidArgumentException
*/
- final public function fetchPairs($key = NULL, $value = NULL)
+ final public function fetchPairs($key = null, $value = null)
{
$this->seek(0);
$row = $this->fetch();
@@ -415,8 +415,8 @@ class Result implements IDataSource
$data = [];
- if ($value === NULL) {
- if ($key !== NULL) {
+ if ($value === null) {
+ if ($key !== null) {
throw new \InvalidArgumentException('Either none or both columns must be specified.');
}
@@ -437,7 +437,7 @@ class Result implements IDataSource
throw new \InvalidArgumentException("Unknown value column '$value'.");
}
- if ($key === NULL) { // indexed-array
+ if ($key === null) { // indexed-array
do {
$data[] = $row[$value];
} while ($row = $this->fetch());
@@ -484,7 +484,7 @@ class Result implements IDataSource
private function normalize(array &$row)
{
foreach ($this->types as $key => $type) {
- if (!isset($row[$key])) { // NULL
+ if (!isset($row[$key])) { // null
continue;
}
$value = $row[$key];
@@ -499,7 +499,7 @@ class Result implements IDataSource
} elseif ($type === Type::FLOAT) {
$value = ltrim((string) $value, '0');
$p = strpos($value, '.');
- if ($p !== FALSE) {
+ if ($p !== false) {
$value = rtrim(rtrim($value, '0'), '.');
}
if ($value === '' || $value[0] === '.') {
@@ -513,11 +513,11 @@ class Result implements IDataSource
$row[$key] = ((bool) $value) && $value !== 'f' && $value !== 'F';
} elseif ($type === Type::DATETIME || $type === Type::DATE || $type === Type::TIME) {
- if ($value && substr((string) $value, 0, 3) !== '000') { // '', NULL, FALSE, '0000-00-00', ...
+ if ($value && substr((string) $value, 0, 3) !== '000') { // '', null, false, '0000-00-00', ...
$value = new DateTime($value);
$row[$key] = empty($this->formats[$type]) ? $value : $value->format($this->formats[$type]);
} else {
- $row[$key] = NULL;
+ $row[$key] = null;
}
} elseif ($type === Type::TIME_INTERVAL) {
@@ -551,14 +551,14 @@ class Result implements IDataSource
*/
final public function getType($col)
{
- return isset($this->types[$col]) ? $this->types[$col] : NULL;
+ return isset($this->types[$col]) ? $this->types[$col] : null;
}
/**
* Sets date format.
* @param string
- * @param string|NULL format
+ * @param string|null format
* @return self
*/
final public function setFormat($type, $format)
@@ -570,11 +570,11 @@ class Result implements IDataSource
/**
* Returns data format.
- * @return string|NULL
+ * @return string|null
*/
final public function getFormat($type)
{
- return isset($this->formats[$type]) ? $this->formats[$type] : NULL;
+ return isset($this->formats[$type]) ? $this->formats[$type] : null;
}
@@ -587,7 +587,7 @@ class Result implements IDataSource
*/
public function getInfo()
{
- if ($this->meta === NULL) {
+ if ($this->meta === null) {
$this->meta = new Reflection\Result($this->getResultDriver());
}
return $this->meta;
diff --git a/src/Dibi/Row.php b/src/Dibi/Row.php
index 2a95e668..b175ae4c 100644
--- a/src/Dibi/Row.php
+++ b/src/Dibi/Row.php
@@ -33,16 +33,16 @@ class Row implements \ArrayAccess, \IteratorAggregate, \Countable
* @param string format
* @return \DateTime
*/
- public function asDateTime($key, $format = NULL)
+ public function asDateTime($key, $format = null)
{
$time = $this[$key];
if (!$time instanceof DateTime) {
- if (!$time || substr((string) $time, 0, 3) === '000') { // '', NULL, FALSE, '0000-00-00', ...
- return NULL;
+ if (!$time || substr((string) $time, 0, 3) === '000') { // '', null, false, '0000-00-00', ...
+ return null;
}
$time = new DateTime($time);
}
- return $format === NULL ? $time : $time->format($format);
+ return $format === null ? $time : $time->format($format);
}
diff --git a/src/Dibi/Strict.php b/src/Dibi/Strict.php
index 93487e0b..56ff00fe 100644
--- a/src/Dibi/Strict.php
+++ b/src/Dibi/Strict.php
@@ -88,7 +88,7 @@ trait Strict
*/
public function __isset($name)
{
- return FALSE;
+ return false;
}
@@ -108,29 +108,29 @@ trait Strict
* @param callable
* @return mixed
*/
- public static function extensionMethod($name, $callback = NULL)
+ public static function extensionMethod($name, $callback = null)
{
- if (strpos($name, '::') === FALSE) {
+ if (strpos($name, '::') === false) {
$class = get_called_class();
} else {
list($class, $name) = explode('::', $name);
$class = (new ReflectionClass($class))->getName();
}
- if (self::$extMethods === NULL) { // for backwards compatibility
+ if (self::$extMethods === null) { // for backwards compatibility
$list = get_defined_functions();
foreach ($list['user'] as $fce) {
$pair = explode('_prototype_', $fce);
if (count($pair) === 2) {
trigger_error("Extension method defined as $fce() is deprecated, use $class::extensionMethod('$name', ...).", E_USER_DEPRECATED);
self::$extMethods[$pair[1]][(new ReflectionClass($pair[0]))->getName()] = $fce;
- self::$extMethods[$pair[1]][''] = NULL;
+ self::$extMethods[$pair[1]][''] = null;
}
}
}
$list = & self::$extMethods[strtolower($name)];
- if ($callback === NULL) { // getter
+ if ($callback === null) { // getter
$cache = &$list[''][$class];
if (isset($cache)) {
return $cache;
@@ -141,11 +141,11 @@ trait Strict
return $cache = $list[$cl];
}
}
- return $cache = FALSE;
+ return $cache = false;
} else { // setter
$list[$class] = $callback;
- $list[''] = NULL;
+ $list[''] = null;
}
}
}
diff --git a/src/Dibi/Translator.php b/src/Dibi/Translator.php
index cfb672c5..d789f76d 100644
--- a/src/Dibi/Translator.php
+++ b/src/Dibi/Translator.php
@@ -31,7 +31,7 @@ final class Translator
private $errors;
/** @var bool */
- private $comment = FALSE;
+ private $comment = false;
/** @var int */
private $ifLevel = 0;
@@ -71,8 +71,8 @@ final class Translator
}
$this->args = $args;
- $commandIns = NULL;
- $lastArr = NULL;
+ $commandIns = null;
+ $lastArr = null;
$cursor = &$this->cursor;
$comment = &$this->comment;
@@ -127,7 +127,7 @@ final class Translator
if (is_array($arg) && is_string(key($arg))) {
// associative array -> autoselect between SET or VALUES & LIST
- if ($commandIns === NULL) {
+ if ($commandIns === null) {
$commandIns = strtoupper(substr(ltrim($this->args[0]), 0, 6));
$commandIns = $commandIns === 'INSERT' || $commandIns === 'REPLAC';
$sql[] = $this->formatValue($arg, $commandIns ? 'v' : 'a');
@@ -142,7 +142,7 @@ final class Translator
}
// default processing
- $sql[] = $this->formatValue($arg, FALSE);
+ $sql[] = $this->formatValue($arg, false);
} // while
@@ -157,7 +157,7 @@ final class Translator
}
// apply limit
- if ($this->limit !== NULL || $this->offset !== NULL) {
+ if ($this->limit !== null || $this->offset !== null) {
$this->driver->applyLimit($sql, $this->limit, $this->offset);
}
@@ -196,7 +196,7 @@ final class Translator
$pair = explode('%', $k, 2); // split into identifier & modifier
$k = $this->identifiers->{$pair[0]} . ' ';
if (!isset($pair[1])) {
- $v = $this->formatValue($v, FALSE);
+ $v = $this->formatValue($v, false);
$vx[] = $k . ($v === 'NULL' ? 'IS ' : '= ') . $v;
} elseif ($pair[1] === 'ex') {
@@ -206,7 +206,7 @@ final class Translator
$v = $this->formatValue($v, $pair[1]);
if ($pair[1] === 'l' || $pair[1] === 'in') {
$op = 'IN ';
- } elseif (strpos($pair[1], 'like') !== FALSE) {
+ } elseif (strpos($pair[1], 'like') !== false) {
$op = 'LIKE ';
} elseif ($v === 'NULL') {
$op = 'IS ';
@@ -238,7 +238,7 @@ final class Translator
foreach ($value as $k => $v) {
$pair = explode('%', $k, 2); // split into identifier & modifier
$vx[] = $this->identifiers->{$pair[0]} . '='
- . $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : FALSE));
+ . $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : false));
}
return implode(', ', $vx);
@@ -247,7 +247,7 @@ final class Translator
case 'l': // (val, val, ...)
foreach ($value as $k => $v) {
$pair = explode('%', (string) $k, 2); // split into identifier & modifier
- $vx[] = $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : FALSE));
+ $vx[] = $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : false));
}
return '(' . (($vx || $modifier === 'l') ? implode(', ', $vx) : 'NULL') . ')';
@@ -256,7 +256,7 @@ final class Translator
foreach ($value as $k => $v) {
$pair = explode('%', $k, 2); // split into identifier & modifier
$kx[] = $this->identifiers->{$pair[0]};
- $vx[] = $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : FALSE));
+ $vx[] = $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : false));
}
return '(' . implode(', ', $kx) . ') VALUES (' . implode(', ', $vx) . ')';
@@ -277,7 +277,7 @@ final class Translator
$pair = explode('%', $k, 2); // split into identifier & modifier
$kx[] = $this->identifiers->{$pair[0]};
foreach ($v as $k2 => $v2) {
- $vx[$k2][] = $this->formatValue($v2, isset($pair[1]) ? $pair[1] : (is_array($v2) ? 'ex' : FALSE));
+ $vx[$k2][] = $this->formatValue($v2, isset($pair[1]) ? $pair[1] : (is_array($v2) ? 'ex' : false));
}
}
foreach ($vx as $k => $v) {
@@ -313,7 +313,7 @@ final class Translator
// with modifier procession
if ($modifier) {
- if ($value !== NULL && !is_scalar($value)) { // array is already processed
+ if ($value !== null && !is_scalar($value)) { // array is already processed
if ($value instanceof Literal && ($modifier === 'sql' || $modifier === 'SQL')) {
$modifier = 'SQL';
} elseif (($value instanceof \DateTime || $value instanceof \DateTimeInterface) && ($modifier === 'd' || $modifier === 't')) {
@@ -326,15 +326,15 @@ final class Translator
switch ($modifier) {
case 's': // string
- return $value === NULL ? 'NULL' : $this->driver->escapeText((string) $value);
+ return $value === null ? 'NULL' : $this->driver->escapeText((string) $value);
case 'bin':// binary
- return $value === NULL ? 'NULL' : $this->driver->escapeBinary($value);
+ return $value === null ? 'NULL' : $this->driver->escapeBinary($value);
case 'b': // boolean
- return $value === NULL ? 'NULL' : $this->driver->escapeBool($value);
+ return $value === null ? 'NULL' : $this->driver->escapeBool($value);
- case 'sN': // string or NULL
+ case 'sN': // string or null
case 'sn':
return $value == '' ? 'NULL' : $this->driver->escapeText((string) $value); // notice two equal signs
@@ -342,15 +342,15 @@ final class Translator
trigger_error('Modifier %in is deprecated, use %iN.', E_USER_DEPRECATED);
// intentionally break omitted
- case 'iN': // signed int or NULL
+ case 'iN': // signed int or null
if ($value == '') {
- $value = NULL;
+ $value = null;
}
// intentionally break omitted
case 'i': // signed int
case 'u': // unsigned int, ignored
- if ($value === NULL) {
+ if ($value === null) {
return 'NULL';
} elseif (is_string($value) && preg_match('#[+-]?\d++(?:e\d+)?\z#A', $value)) {
return $value; // support for long numbers - keep them unchanged
@@ -362,7 +362,7 @@ final class Translator
}
case 'f': // float
- if ($value === NULL) {
+ if ($value === null) {
return 'NULL';
} elseif (is_string($value) && is_numeric($value) && substr($value, 1, 1) !== 'x') {
return $value; // support for extreme numbers - keep them unchanged
@@ -373,7 +373,7 @@ final class Translator
case 'd': // date
case 't': // datetime
case 'dt': // datetime
- if ($value === NULL) {
+ if ($value === null) {
return 'NULL';
} else {
return $modifier === 'd' ? $this->driver->escapeDate($value) : $this->driver->escapeDateTime($value);
@@ -443,7 +443,7 @@ final class Translator
} elseif (is_bool($value)) {
return $this->driver->escapeBool($value);
- } elseif ($value === NULL) {
+ } elseif ($value === null) {
return 'NULL';
} elseif ($value instanceof \DateTime || $value instanceof \DateTimeInterface) {
@@ -487,7 +487,7 @@ final class Translator
}
$cursor++;
- return $this->formatValue($this->args[$cursor - 1], FALSE);
+ return $this->formatValue($this->args[$cursor - 1], false);
}
if (!empty($matches[10])) { // modifier
@@ -504,7 +504,7 @@ final class Translator
if (!$this->comment && !$this->args[$cursor - 1]) {
// open comment
$this->ifLevelStart = $this->ifLevel;
- $this->comment = TRUE;
+ $this->comment = true;
return '/*';
}
return '';
@@ -512,11 +512,11 @@ final class Translator
} elseif ($mod === 'else') {
if ($this->ifLevelStart === $this->ifLevel) {
$this->ifLevelStart = 0;
- $this->comment = FALSE;
+ $this->comment = false;
return '*/';
} elseif (!$this->comment) {
$this->ifLevelStart = $this->ifLevel;
- $this->comment = TRUE;
+ $this->comment = true;
return '/*';
}
@@ -525,7 +525,7 @@ final class Translator
if ($this->ifLevelStart === $this->ifLevel + 1) {
// close comment
$this->ifLevelStart = 0;
- $this->comment = FALSE;
+ $this->comment = false;
return '*/';
}
return '';
@@ -536,7 +536,7 @@ final class Translator
} elseif ($mod === 'lmt') { // apply limit
$arg = $this->args[$cursor++];
- if ($arg === NULL) {
+ if ($arg === null) {
} elseif ($this->comment) {
return "(limit $arg)";
} else {
@@ -546,7 +546,7 @@ final class Translator
} elseif ($mod === 'ofs') { // apply offset
$arg = $this->args[$cursor++];
- if ($arg === NULL) {
+ if ($arg === null) {
} elseif ($this->comment) {
return "(offset $arg)";
} else {
@@ -583,7 +583,7 @@ final class Translator
if ($matches[8]) { // SQL identifier substitution
$m = substr($matches[8], 0, -1);
$m = $this->connection->getSubstitutes()->$m;
- return $matches[9] == '' ? $this->formatValue($m, FALSE) : $m . $matches[9]; // value or identifier
+ return $matches[9] == '' ? $this->formatValue($m, false) : $m . $matches[9]; // value or identifier
}
throw new \Exception('this should be never executed');
diff --git a/src/Dibi/dibi.php b/src/Dibi/dibi.php
index 31b8e796..4ec93a55 100644
--- a/src/Dibi/dibi.php
+++ b/src/Dibi/dibi.php
@@ -107,12 +107,12 @@ class dibi
/**
- * Returns TRUE when connection was established.
+ * Returns true when connection was established.
* @return bool
*/
public static function isConnected()
{
- return (self::$connection !== NULL) && self::$connection->isConnected();
+ return (self::$connection !== null) && self::$connection->isConnected();
}
@@ -122,10 +122,10 @@ class dibi
* @return Dibi\Connection
* @throws Dibi\Exception
*/
- public static function getConnection($name = NULL)
+ public static function getConnection($name = null)
{
- if ($name === NULL) {
- if (self::$connection === NULL) {
+ if ($name === null) {
+ if (self::$connection === null) {
throw new Dibi\Exception('Dibi is not connected to database.');
}
@@ -294,7 +294,7 @@ class dibi
* @return int
* @throws Dibi\Exception
*/
- public static function getInsertId($sequence = NULL)
+ public static function getInsertId($sequence = null)
{
return self::getConnection()->getInsertId($sequence);
}
@@ -306,7 +306,7 @@ class dibi
* @return int
* @throws Dibi\Exception
*/
- public static function insertId($sequence = NULL)
+ public static function insertId($sequence = null)
{
return self::getConnection()->getInsertId($sequence);
}
@@ -318,19 +318,19 @@ class dibi
* @return void
* @throws Dibi\Exception
*/
- public static function begin($savepoint = NULL)
+ public static function begin($savepoint = null)
{
self::getConnection()->begin($savepoint);
}
/**
- * Commits statements in a transaction - Monostate for Dibi\Connection::commit($savepoint = NULL).
+ * Commits statements in a transaction - Monostate for Dibi\Connection::commit($savepoint = null).
* @param string optional savepoint name
* @return void
* @throws Dibi\Exception
*/
- public static function commit($savepoint = NULL)
+ public static function commit($savepoint = null)
{
self::getConnection()->commit($savepoint);
}
@@ -342,7 +342,7 @@ class dibi
* @return void
* @throws Dibi\Exception
*/
- public static function rollback($savepoint = NULL)
+ public static function rollback($savepoint = null)
{
self::getConnection()->rollback($savepoint);
}
@@ -446,7 +446,7 @@ class dibi
* @param bool return output instead of printing it?
* @return string
*/
- public static function dump($sql = NULL, $return = FALSE)
+ public static function dump($sql = null, $return = false)
{
return Dibi\Helpers::dump($sql, $return);
}
diff --git a/src/Dibi/exceptions.php b/src/Dibi/exceptions.php
index 1702b313..fddf3344 100644
--- a/src/Dibi/exceptions.php
+++ b/src/Dibi/exceptions.php
@@ -13,7 +13,7 @@ namespace Dibi;
*/
class Exception extends \Exception
{
- /** @var string|NULL */
+ /** @var string|null */
private $sql;
@@ -23,7 +23,7 @@ class Exception extends \Exception
* @param mixed
* @param string SQL command
*/
- public function __construct($message = '', $code = 0, $sql = NULL)
+ public function __construct($message = '', $code = 0, $sql = null)
{
parent::__construct($message);
$this->code = $code;
@@ -103,7 +103,7 @@ class ProcedureException extends Exception
* @param int Some code
* @param string SQL command
*/
- public function __construct($message = NULL, $code = 0, $severity = NULL, $sql = NULL)
+ public function __construct($message = null, $code = 0, $severity = null, $sql = null)
{
parent::__construct($message, (int) $code, $sql);
$this->severity = $severity;
diff --git a/src/Dibi/interfaces.php b/src/Dibi/interfaces.php
index 5603c690..dd676949 100644
--- a/src/Dibi/interfaces.php
+++ b/src/Dibi/interfaces.php
@@ -42,20 +42,20 @@ interface Driver
/**
* Internal: Executes the SQL query.
* @param string SQL statement.
- * @return ResultDriver|NULL
+ * @return ResultDriver|null
* @throws DriverException
*/
function query($sql);
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
- * @return int|FALSE number of rows or FALSE on error
+ * @return int|false number of rows or false on error
*/
function getAffectedRows();
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
- * @return int|FALSE int on success or FALSE on failure
+ * @return int|false int on success or false on failure
*/
function getInsertId($sequence);
@@ -65,7 +65,7 @@ interface Driver
* @return void
* @throws DriverException
*/
- function begin($savepoint = NULL);
+ function begin($savepoint = null);
/**
* Commits statements in a transaction.
@@ -73,7 +73,7 @@ interface Driver
* @return void
* @throws DriverException
*/
- function commit($savepoint = NULL);
+ function commit($savepoint = null);
/**
* Rollback changes in a transaction.
@@ -81,7 +81,7 @@ interface Driver
* @return void
* @throws DriverException
*/
- function rollback($savepoint = NULL);
+ function rollback($savepoint = null);
/**
* Returns the connection resource.
@@ -143,8 +143,8 @@ interface Driver
/**
* Injects LIMIT/OFFSET to the SQL query.
* @param string
- * @param int|NULL
- * @param int|NULL
+ * @param int|null
+ * @param int|null
* @return void
*/
function applyLimit(&$sql, $limit, $offset);
@@ -166,14 +166,14 @@ interface ResultDriver
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
- * @return boolean TRUE on success, FALSE if unable to seek to specified record
+ * @return boolean true on success, false if unable to seek to specified record
* @throws Exception
*/
function seek($row);
/**
* Fetches the row at current position and moves the internal cursor to the next position.
- * @param bool TRUE for associative array, FALSE for numeric
+ * @param bool true for associative array, false for numeric
* @return array array on success, nonarray if no next record
* @internal
*/
diff --git a/tests/dibi/Connection.connect.phpt b/tests/dibi/Connection.connect.phpt
index cf872ca7..1814e46b 100644
--- a/tests/dibi/Connection.connect.phpt
+++ b/tests/dibi/Connection.connect.phpt
@@ -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');
diff --git a/tests/dibi/Fluent.delete.phpt b/tests/dibi/Fluent.delete.phpt
index 199d4c51..f3d9077d 100644
--- a/tests/dibi/Fluent.delete.phpt
+++ b/tests/dibi/Fluent.delete.phpt
@@ -30,7 +30,7 @@ Assert::same(
(string) $fluent
);
-$fluent->setFlag('IGNORE', FALSE);
+$fluent->setFlag('IGNORE', false);
Assert::same(
reformat('DELETE FROM [anotherTable] USING [thirdTable]'),
diff --git a/tests/dibi/Fluent.fetch.limit.mssql.phpt b/tests/dibi/Fluent.fetch.limit.mssql.phpt
index 0adfff44..e29786ca 100644
--- a/tests/dibi/Fluent.fetch.limit.mssql.phpt
+++ b/tests/dibi/Fluent.fetch.limit.mssql.phpt
@@ -25,7 +25,7 @@ class MockDriver extends Dibi\Drivers\SqlsrvDriver
function fetch($assoc)
{
- return FALSE;
+ return false;
}
}
diff --git a/tests/dibi/Fluent.insert.phpt b/tests/dibi/Fluent.insert.phpt
index db0226db..f8b3d065 100644
--- a/tests/dibi/Fluent.insert.phpt
+++ b/tests/dibi/Fluent.insert.phpt
@@ -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)'),
diff --git a/tests/dibi/Fluent.update.phpt b/tests/dibi/Fluent.update.phpt
index ea7ada32..4461559c 100644
--- a/tests/dibi/Fluent.update.phpt
+++ b/tests/dibi/Fluent.update.phpt
@@ -11,7 +11,7 @@ $conn = new Dibi\Connection($config);
$arr = [
'title' => 'Super Product',
'price' => 12,
- 'brand' => NULL,
+ 'brand' => null,
];
$fluent = $conn->update('table', $arr)
diff --git a/tests/dibi/Helpers.getSuggestion().phpt b/tests/dibi/Helpers.getSuggestion().phpt
index 29ca4a02..7cd39ac9 100644
--- a/tests/dibi/Helpers.getSuggestion().phpt
+++ b/tests/dibi/Helpers.getSuggestion().phpt
@@ -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'));
/*
diff --git a/tests/dibi/Result.meta.phpt b/tests/dibi/Result.meta.phpt
index 96b863c9..e79e4a30 100644
--- a/tests/dibi/Result.meta.phpt
+++ b/tests/dibi/Result.meta.phpt
@@ -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)
);
}
diff --git a/tests/dibi/Result.normalize.phpt b/tests/dibi/Result.normalize.phpt
index cdcc51b3..0fede4a9 100644
--- a/tests/dibi/Result.normalize.phpt
+++ b/tests/dibi/Result.normalize.phpt
@@ -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']));
});
diff --git a/tests/dibi/Translator.DateTimeInterface.phpt b/tests/dibi/Translator.DateTimeInterface.phpt
index 1d61cbd3..2aa8b84e 100644
--- a/tests/dibi/Translator.DateTimeInterface.phpt
+++ b/tests/dibi/Translator.DateTimeInterface.phpt
@@ -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));
diff --git a/tests/dibi/Translator.conditions.phpt b/tests/dibi/Translator.conditions.phpt
index 99198212..409e5448 100644
--- a/tests/dibi/Translator.conditions.phpt
+++ b/tests/dibi/Translator.conditions.phpt
@@ -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'
diff --git a/tests/dibi/Translator.phpt b/tests/dibi/Translator.phpt
index 9c970cb9..92a0f7a5 100644
--- a/tests/dibi/Translator.phpt
+++ b/tests/dibi/Translator.phpt
@@ -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(
diff --git a/tests/dibi/bootstrap.php b/tests/dibi/bootstrap.php
index 7c7840d3..c879afb4 100644
--- a/tests/dibi/bootstrap.php
+++ b/tests/dibi/bootstrap.php
@@ -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);
}
diff --git a/tests/dibi/exceptions.sqlite.phpt b/tests/dibi/exceptions.sqlite.phpt
index e0fc3d54..6954bfb7 100644
--- a/tests/dibi/exceptions.sqlite.phpt
+++ b/tests/dibi/exceptions.sqlite.phpt
@@ -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());
|