Skip to content

Commit

Permalink
make relevant classes strict
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed May 7, 2020
1 parent 5f03f3b commit efa389a
Show file tree
Hide file tree
Showing 22 changed files with 90 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Nextras\Dbal\QueryBuilder\QueryBuilder;
use Nextras\Dbal\Result\Result;
use Nextras\Dbal\Utils\LoggerHelper;
use Nextras\Dbal\Utils\StrictObjectTrait;
use function array_unshift;
use function assert;
use function call_user_func_array;
Expand All @@ -23,6 +24,9 @@

class Connection implements IConnection
{
use StrictObjectTrait;


/**
* @var array
* @phpstan-var array<string, mixed>
Expand Down
4 changes: 4 additions & 0 deletions src/Drivers/Mysqli/MysqliDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@
use Nextras\Dbal\Result\Result;
use Nextras\Dbal\UniqueConstraintViolationException;
use Nextras\Dbal\Utils\LoggerHelper;
use Nextras\Dbal\Utils\StrictObjectTrait;


class MysqliDriver implements IDriver
{
use StrictObjectTrait;


/** @var mysqli|null */
private $connection;

Expand Down
4 changes: 4 additions & 0 deletions src/Drivers/Mysqli/MysqliEmptyResultAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@

use Nextras\Dbal\Drivers\IResultAdapter;
use Nextras\Dbal\InvalidStateException;
use Nextras\Dbal\Utils\StrictObjectTrait;


class MysqliEmptyResultAdapter implements IResultAdapter
{
use StrictObjectTrait;


public function seek(int $index): void
{
throw new InvalidStateException("Unable to seek in row set to {$index} index.");
Expand Down
4 changes: 4 additions & 0 deletions src/Drivers/Mysqli/MysqliResultAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
use mysqli_result;
use Nextras\Dbal\Drivers\IResultAdapter;
use Nextras\Dbal\InvalidStateException;
use Nextras\Dbal\Utils\StrictObjectTrait;


class MysqliResultAdapter implements IResultAdapter
{
use StrictObjectTrait;


/** @var array<int, int> */
protected static $types = [
MYSQLI_TYPE_TIME => self::TYPE_DRIVER_SPECIFIC,
Expand Down
4 changes: 4 additions & 0 deletions src/Drivers/Pgsql/PgsqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@
use Nextras\Dbal\Result\Result;
use Nextras\Dbal\UniqueConstraintViolationException;
use Nextras\Dbal\Utils\LoggerHelper;
use Nextras\Dbal\Utils\StrictObjectTrait;
use Tester\Assert;


class PgsqlDriver implements IDriver
{
use StrictObjectTrait;


/** @var resource|null */
private $connection;

Expand Down
4 changes: 4 additions & 0 deletions src/Drivers/Pgsql/PgsqlResultAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@

use Nextras\Dbal\Drivers\IResultAdapter;
use Nextras\Dbal\InvalidStateException;
use Nextras\Dbal\Utils\StrictObjectTrait;


class PgsqlResultAdapter implements IResultAdapter
{
use StrictObjectTrait;


/** @var resource */
private $result;

Expand Down
4 changes: 4 additions & 0 deletions src/Drivers/Sqlsrv/SqlsrvDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@
use Nextras\Dbal\UniqueConstraintViolationException;
use Nextras\Dbal\Utils\DateTimeImmutable;
use Nextras\Dbal\Utils\LoggerHelper;
use Nextras\Dbal\Utils\StrictObjectTrait;


class SqlsrvDriver implements IDriver
{
use StrictObjectTrait;


/** @var resource|null */
private $connection;

Expand Down
4 changes: 4 additions & 0 deletions src/Drivers/Sqlsrv/SqlsrvResultAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@

use Nextras\Dbal\Drivers\IResultAdapter;
use Nextras\Dbal\InvalidStateException;
use Nextras\Dbal\Utils\StrictObjectTrait;


class SqlsrvResultAdapter implements IResultAdapter
{
use StrictObjectTrait;


/**
* @var array
* @phpstan-var array<int, int>
Expand Down
4 changes: 4 additions & 0 deletions src/MultiLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
namespace Nextras\Dbal;

use Nextras\Dbal\Result\Result;
use Nextras\Dbal\Utils\StrictObjectTrait;


class MultiLogger implements ILogger
{
use StrictObjectTrait;


/**
* @var ILogger[]
* @phpstan-var array<string, ILogger>
Expand Down
6 changes: 6 additions & 0 deletions src/Platforms/Data/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
namespace Nextras\Dbal\Platforms\Data;


use Nextras\Dbal\Utils\StrictObjectTrait;


class Column
{
use StrictObjectTrait;


/** @var string */
public $name;

Expand Down
6 changes: 6 additions & 0 deletions src/Platforms/Data/ForeignKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
namespace Nextras\Dbal\Platforms\Data;


use Nextras\Dbal\Utils\StrictObjectTrait;


class ForeignKey
{
use StrictObjectTrait;


/** @var string */
public $name;

Expand Down
6 changes: 6 additions & 0 deletions src/Platforms/Data/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
namespace Nextras\Dbal\Platforms\Data;


use Nextras\Dbal\Utils\StrictObjectTrait;


class Table
{
use StrictObjectTrait;


/** @var string */
public $name;

Expand Down
4 changes: 4 additions & 0 deletions src/Platforms/MySqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
use Nextras\Dbal\Platforms\Data\Column;
use Nextras\Dbal\Platforms\Data\ForeignKey;
use Nextras\Dbal\Platforms\Data\Table;
use Nextras\Dbal\Utils\StrictObjectTrait;


class MySqlPlatform implements IPlatform
{
use StrictObjectTrait;


public const NAME = 'mysql';

/** @var Connection */
Expand Down
4 changes: 4 additions & 0 deletions src/Platforms/PostgreSqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
use Nextras\Dbal\Platforms\Data\Column;
use Nextras\Dbal\Platforms\Data\ForeignKey;
use Nextras\Dbal\Platforms\Data\Table;
use Nextras\Dbal\Utils\StrictObjectTrait;


class PostgreSqlPlatform implements IPlatform
{
use StrictObjectTrait;


public const NAME = 'pgsql';

/** @var Connection */
Expand Down
4 changes: 4 additions & 0 deletions src/Platforms/SqlServerPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
use Nextras\Dbal\Platforms\Data\Column;
use Nextras\Dbal\Platforms\Data\ForeignKey;
use Nextras\Dbal\Platforms\Data\Table;
use Nextras\Dbal\Utils\StrictObjectTrait;
use function count;
use function explode;


class SqlServerPlatform implements IPlatform
{
use StrictObjectTrait;


public const NAME = 'mssql';

/** @var Connection */
Expand Down
4 changes: 4 additions & 0 deletions src/QueryBuilder/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
use Nextras\Dbal\Drivers\IDriver;
use Nextras\Dbal\InvalidArgumentException;
use Nextras\Dbal\InvalidStateException;
use Nextras\Dbal\Utils\StrictObjectTrait;


class QueryBuilder
{
use StrictObjectTrait;


/** @const */
const TYPE_SELECT = 1;
const TYPE_INSERT = 2;
Expand Down
4 changes: 4 additions & 0 deletions src/Result/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Nextras\Dbal\Drivers\IResultAdapter;
use Nextras\Dbal\InvalidArgumentException;
use Nextras\Dbal\Utils\DateTimeImmutable;
use Nextras\Dbal\Utils\StrictObjectTrait;
use SeekableIterator;
use function assert;
use function date_default_timezone_get;
Expand All @@ -25,6 +26,9 @@
*/
class Result implements SeekableIterator, Countable
{
use StrictObjectTrait;


/** @var IResultAdapter */
private $adapter;

Expand Down
4 changes: 4 additions & 0 deletions src/SqlProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@

use Nextras\Dbal\Drivers\IDriver;
use Nextras\Dbal\Platforms\IPlatform;
use Nextras\Dbal\Utils\StrictObjectTrait;


class SqlProcessor
{
use StrictObjectTrait;


/**
* @var array (name => [supports ?, supports [], expected type])
* @phpstan-var array<string, array{bool, bool, string}>
Expand Down
3 changes: 3 additions & 0 deletions src/Utils/FileImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

class FileImporter
{
use StrictObjectTrait;


/**
* Imports & executes queries from sql file.
* Code taken from Adminer (http://www.adminer.org) & modified,
Expand Down
3 changes: 3 additions & 0 deletions src/Utils/LoggerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
*/
class LoggerHelper
{
use StrictObjectTrait;


/**
* @throws DriverException
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Utils/SqlHighlighter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
*/
class SqlHighlighter
{
use StrictObjectTrait;


public static function highlight(string $sql): string
{
static $keywords1 = 'SELECT|(?:ON\s+DUPLICATE\s+KEY)?UPDATE|INSERT(?:\s+INTO)?|REPLACE(?:\s+INTO)?|SHOW|DELETE|CALL|UNION|FROM|WHERE|HAVING|GROUP\s+BY|ORDER\s+BY|LIMIT|OFFSET|SET|VALUES|LEFT\s+JOIN|INNER\s+JOIN|TRUNCATE|START\s+TRANSACTION|COMMIT|ROLLBACK|(?:RELEASE\s+|ROLLBACK\s+TO\s+)?SAVEPOINT';
Expand Down
3 changes: 3 additions & 0 deletions src/Utils/Typos.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

class Typos
{
use StrictObjectTrait;


/**
* Returns the closest word to the $current word or NULL if such word does not exist.
* @param string[] $words
Expand Down

0 comments on commit efa389a

Please sign in to comment.