mirror of
https://github.com/dg/dibi.git
synced 2025-08-07 14:46:50 +02:00
removed Dibi\Strict
This commit is contained in:
@@ -20,8 +20,6 @@ use Tracy;
|
|||||||
*/
|
*/
|
||||||
class Panel implements Tracy\IBarPanel
|
class Panel implements Tracy\IBarPanel
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var int maximum SQL length */
|
/** @var int maximum SQL length */
|
||||||
public static $maxLength = 1000;
|
public static $maxLength = 1000;
|
||||||
|
|
||||||
|
@@ -20,8 +20,6 @@ use Traversable;
|
|||||||
*/
|
*/
|
||||||
class Connection implements IConnection
|
class Connection implements IConnection
|
||||||
{
|
{
|
||||||
use Strict;
|
|
||||||
|
|
||||||
/** @var array of function (Event $event); Occurs after query is executed */
|
/** @var array of function (Event $event); Occurs after query is executed */
|
||||||
public $onEvent = [];
|
public $onEvent = [];
|
||||||
|
|
||||||
|
@@ -15,8 +15,6 @@ namespace Dibi;
|
|||||||
*/
|
*/
|
||||||
class DataSource implements IDataSource
|
class DataSource implements IDataSource
|
||||||
{
|
{
|
||||||
use Strict;
|
|
||||||
|
|
||||||
/** @var Connection */
|
/** @var Connection */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
|
@@ -15,8 +15,6 @@ namespace Dibi;
|
|||||||
*/
|
*/
|
||||||
class DateTime extends \DateTimeImmutable
|
class DateTime extends \DateTimeImmutable
|
||||||
{
|
{
|
||||||
use Strict;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|int $time
|
* @param string|int $time
|
||||||
*/
|
*/
|
||||||
|
@@ -17,8 +17,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class DummyDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
class DummyDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
public function disconnect(): void
|
public function disconnect(): void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@@ -26,8 +26,6 @@ use Dibi\Helpers;
|
|||||||
*/
|
*/
|
||||||
class FirebirdDriver implements Dibi\Driver
|
class FirebirdDriver implements Dibi\Driver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
public const ERROR_EXCEPTION_THROWN = -836;
|
public const ERROR_EXCEPTION_THROWN = -836;
|
||||||
|
|
||||||
/** @var resource */
|
/** @var resource */
|
||||||
|
@@ -17,8 +17,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class FirebirdReflector implements Dibi\Reflector
|
class FirebirdReflector implements Dibi\Reflector
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var Dibi\Driver */
|
/** @var Dibi\Driver */
|
||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
|
@@ -18,8 +18,6 @@ use Dibi\Helpers;
|
|||||||
*/
|
*/
|
||||||
class FirebirdResult implements Dibi\ResultDriver
|
class FirebirdResult implements Dibi\ResultDriver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var resource */
|
/** @var resource */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
|
@@ -18,8 +18,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class MySqlReflector implements Dibi\Reflector
|
class MySqlReflector implements Dibi\Reflector
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var Dibi\Driver */
|
/** @var Dibi\Driver */
|
||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
|
@@ -32,8 +32,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class MySqliDriver implements Dibi\Driver
|
class MySqliDriver implements Dibi\Driver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
public const ERROR_ACCESS_DENIED = 1045;
|
public const ERROR_ACCESS_DENIED = 1045;
|
||||||
|
|
||||||
public const ERROR_DUPLICATE_ENTRY = 1062;
|
public const ERROR_DUPLICATE_ENTRY = 1062;
|
||||||
|
@@ -17,8 +17,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class MySqliResult implements Dibi\ResultDriver
|
class MySqliResult implements Dibi\ResultDriver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var \mysqli_result */
|
/** @var \mysqli_result */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
|
@@ -17,8 +17,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class NoDataResult implements Dibi\ResultDriver
|
class NoDataResult implements Dibi\ResultDriver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
private $rows;
|
private $rows;
|
||||||
|
|
||||||
|
@@ -25,8 +25,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class OdbcDriver implements Dibi\Driver
|
class OdbcDriver implements Dibi\Driver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var resource */
|
/** @var resource */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
|
@@ -17,8 +17,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class OdbcReflector implements Dibi\Reflector
|
class OdbcReflector implements Dibi\Reflector
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var Dibi\Driver */
|
/** @var Dibi\Driver */
|
||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
|
@@ -17,8 +17,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class OdbcResult implements Dibi\ResultDriver
|
class OdbcResult implements Dibi\ResultDriver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var resource */
|
/** @var resource */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
|
@@ -27,8 +27,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class OracleDriver implements Dibi\Driver
|
class OracleDriver implements Dibi\Driver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var resource */
|
/** @var resource */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
|
@@ -17,8 +17,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class OracleReflector implements Dibi\Reflector
|
class OracleReflector implements Dibi\Reflector
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var Dibi\Driver */
|
/** @var Dibi\Driver */
|
||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
|
@@ -17,8 +17,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class OracleResult implements Dibi\ResultDriver
|
class OracleResult implements Dibi\ResultDriver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var resource */
|
/** @var resource */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
|
@@ -27,8 +27,6 @@ use PDO;
|
|||||||
*/
|
*/
|
||||||
class PdoDriver implements Dibi\Driver
|
class PdoDriver implements Dibi\Driver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var PDO|null Connection resource */
|
/** @var PDO|null Connection resource */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
|
@@ -19,8 +19,6 @@ use PDO;
|
|||||||
*/
|
*/
|
||||||
class PdoResult implements Dibi\ResultDriver
|
class PdoResult implements Dibi\ResultDriver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var \PDOStatement|null */
|
/** @var \PDOStatement|null */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
|
@@ -28,8 +28,6 @@ use PgSql;
|
|||||||
*/
|
*/
|
||||||
class PostgreDriver implements Dibi\Driver
|
class PostgreDriver implements Dibi\Driver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var resource|PgSql\Connection */
|
/** @var resource|PgSql\Connection */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
|
@@ -17,8 +17,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class PostgreReflector implements Dibi\Reflector
|
class PostgreReflector implements Dibi\Reflector
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var Dibi\Driver */
|
/** @var Dibi\Driver */
|
||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
|
@@ -19,8 +19,6 @@ use PgSql;
|
|||||||
*/
|
*/
|
||||||
class PostgreResult implements Dibi\ResultDriver
|
class PostgreResult implements Dibi\ResultDriver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var resource|PgSql\Result */
|
/** @var resource|PgSql\Result */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
|
@@ -25,8 +25,6 @@ use SQLite3;
|
|||||||
*/
|
*/
|
||||||
class SqliteDriver implements Dibi\Driver
|
class SqliteDriver implements Dibi\Driver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var SQLite3 */
|
/** @var SQLite3 */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
|
@@ -17,8 +17,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class SqliteReflector implements Dibi\Reflector
|
class SqliteReflector implements Dibi\Reflector
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var Dibi\Driver */
|
/** @var Dibi\Driver */
|
||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
|
@@ -18,8 +18,6 @@ use Dibi\Helpers;
|
|||||||
*/
|
*/
|
||||||
class SqliteResult implements Dibi\ResultDriver
|
class SqliteResult implements Dibi\ResultDriver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var \SQLite3Result */
|
/** @var \SQLite3Result */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
|
@@ -27,8 +27,6 @@ use Dibi\Helpers;
|
|||||||
*/
|
*/
|
||||||
class SqlsrvDriver implements Dibi\Driver
|
class SqlsrvDriver implements Dibi\Driver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var resource */
|
/** @var resource */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
|
@@ -17,8 +17,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class SqlsrvReflector implements Dibi\Reflector
|
class SqlsrvReflector implements Dibi\Reflector
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var Dibi\Driver */
|
/** @var Dibi\Driver */
|
||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
|
@@ -17,8 +17,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class SqlsrvResult implements Dibi\ResultDriver
|
class SqlsrvResult implements Dibi\ResultDriver
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var resource */
|
/** @var resource */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
|
@@ -15,8 +15,6 @@ namespace Dibi;
|
|||||||
*/
|
*/
|
||||||
class Event
|
class Event
|
||||||
{
|
{
|
||||||
use Strict;
|
|
||||||
|
|
||||||
/** event type */
|
/** event type */
|
||||||
public const
|
public const
|
||||||
CONNECT = 1,
|
CONNECT = 1,
|
||||||
|
@@ -15,8 +15,6 @@ namespace Dibi;
|
|||||||
*/
|
*/
|
||||||
class Expression
|
class Expression
|
||||||
{
|
{
|
||||||
use Strict;
|
|
||||||
|
|
||||||
/** @var array */
|
/** @var array */
|
||||||
private $values;
|
private $values;
|
||||||
|
|
||||||
|
@@ -45,8 +45,6 @@ namespace Dibi;
|
|||||||
*/
|
*/
|
||||||
class Fluent implements IDataSource
|
class Fluent implements IDataSource
|
||||||
{
|
{
|
||||||
use Strict;
|
|
||||||
|
|
||||||
public const REMOVE = false;
|
public const REMOVE = false;
|
||||||
|
|
||||||
/** @var array */
|
/** @var array */
|
||||||
|
@@ -12,8 +12,6 @@ namespace Dibi;
|
|||||||
|
|
||||||
class Helpers
|
class Helpers
|
||||||
{
|
{
|
||||||
use Strict;
|
|
||||||
|
|
||||||
/** @var HashMap */
|
/** @var HashMap */
|
||||||
private static $types;
|
private static $types;
|
||||||
|
|
||||||
|
@@ -15,8 +15,6 @@ namespace Dibi;
|
|||||||
*/
|
*/
|
||||||
class Literal
|
class Literal
|
||||||
{
|
{
|
||||||
use Strict;
|
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $value;
|
private $value;
|
||||||
|
|
||||||
|
@@ -17,8 +17,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class FileLogger
|
class FileLogger
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var string Name of the file where SQL errors should be logged */
|
/** @var string Name of the file where SQL errors should be logged */
|
||||||
public $file;
|
public $file;
|
||||||
|
|
||||||
|
@@ -27,8 +27,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class Column
|
class Column
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var Dibi\Reflector|null when created by Result */
|
/** @var Dibi\Reflector|null when created by Result */
|
||||||
private $reflector;
|
private $reflector;
|
||||||
|
|
||||||
|
@@ -21,8 +21,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class Database
|
class Database
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var Dibi\Reflector */
|
/** @var Dibi\Reflector */
|
||||||
private $reflector;
|
private $reflector;
|
||||||
|
|
||||||
|
@@ -9,7 +9,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Dibi\Reflection;
|
namespace Dibi\Reflection;
|
||||||
|
|
||||||
use Dibi;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,8 +19,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class ForeignKey
|
class ForeignKey
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
|
@@ -9,7 +9,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Dibi\Reflection;
|
namespace Dibi\Reflection;
|
||||||
|
|
||||||
use Dibi;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,8 +21,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class Index
|
class Index
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var array (name, columns, [unique], [primary]) */
|
/** @var array (name, columns, [unique], [primary]) */
|
||||||
private $info;
|
private $info;
|
||||||
|
|
||||||
|
@@ -20,8 +20,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class Result
|
class Result
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var Dibi\ResultDriver */
|
/** @var Dibi\ResultDriver */
|
||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
|
@@ -25,8 +25,6 @@ use Dibi;
|
|||||||
*/
|
*/
|
||||||
class Table
|
class Table
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
/** @var Dibi\Reflector */
|
/** @var Dibi\Reflector */
|
||||||
private $reflector;
|
private $reflector;
|
||||||
|
|
||||||
|
@@ -17,8 +17,6 @@ namespace Dibi;
|
|||||||
*/
|
*/
|
||||||
class Result implements IDataSource
|
class Result implements IDataSource
|
||||||
{
|
{
|
||||||
use Strict;
|
|
||||||
|
|
||||||
/** @var ResultDriver|null */
|
/** @var ResultDriver|null */
|
||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
|
@@ -15,8 +15,6 @@ namespace Dibi;
|
|||||||
*/
|
*/
|
||||||
class ResultIterator implements \Iterator, \Countable
|
class ResultIterator implements \Iterator, \Countable
|
||||||
{
|
{
|
||||||
use Strict;
|
|
||||||
|
|
||||||
/** @var Result */
|
/** @var Result */
|
||||||
private $result;
|
private $result;
|
||||||
|
|
||||||
|
@@ -1,112 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This file is part of the Dibi, smart database abstraction layer (https://dibiphp.com)
|
|
||||||
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Dibi;
|
|
||||||
|
|
||||||
use ReflectionClass;
|
|
||||||
use ReflectionMethod;
|
|
||||||
use ReflectionProperty;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Better OOP experience.
|
|
||||||
*/
|
|
||||||
trait Strict
|
|
||||||
{
|
|
||||||
/** @var array [method => [type => callback]] */
|
|
||||||
private static $extMethods;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call to undefined method.
|
|
||||||
* @throws \LogicException
|
|
||||||
*/
|
|
||||||
public function __call(string $name, array $args)
|
|
||||||
{
|
|
||||||
$class = method_exists($this, $name) ? 'parent' : static::class;
|
|
||||||
$items = (new ReflectionClass($this))->getMethods(ReflectionMethod::IS_PUBLIC);
|
|
||||||
$items = array_map(fn($item) => $item->getName(), $items);
|
|
||||||
$hint = ($t = Helpers::getSuggestion($items, $name))
|
|
||||||
? ", did you mean $t()?"
|
|
||||||
: '.';
|
|
||||||
throw new \LogicException("Call to undefined method $class::$name()$hint");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call to undefined static method.
|
|
||||||
* @throws \LogicException
|
|
||||||
*/
|
|
||||||
public static function __callStatic(string $name, array $args)
|
|
||||||
{
|
|
||||||
$rc = new ReflectionClass(static::class);
|
|
||||||
$items = array_filter($rc->getMethods(\ReflectionMethod::IS_STATIC), fn($m) => $m->isPublic());
|
|
||||||
$items = array_map(fn($item) => $item->getName(), $items);
|
|
||||||
$hint = ($t = Helpers::getSuggestion($items, $name))
|
|
||||||
? ", did you mean $t()?"
|
|
||||||
: '.';
|
|
||||||
throw new \LogicException("Call to undefined static method {$rc->getName()}::$name()$hint");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access to undeclared property.
|
|
||||||
* @throws \LogicException
|
|
||||||
*/
|
|
||||||
public function &__get(string $name)
|
|
||||||
{
|
|
||||||
if ((method_exists($this, $m = 'get' . $name) || method_exists($this, $m = 'is' . $name))
|
|
||||||
&& (new ReflectionMethod($this, $m))->isPublic()
|
|
||||||
) { // back compatiblity
|
|
||||||
$ret = $this->$m();
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
$rc = new ReflectionClass($this);
|
|
||||||
$items = array_filter($rc->getProperties(ReflectionProperty::IS_PUBLIC), fn($p) => !$p->isStatic());
|
|
||||||
$items = array_map(fn($item) => $item->getName(), $items);
|
|
||||||
$hint = ($t = Helpers::getSuggestion($items, $name))
|
|
||||||
? ", did you mean $$t?"
|
|
||||||
: '.';
|
|
||||||
throw new \LogicException("Attempt to read undeclared property {$rc->getName()}::$$name$hint");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access to undeclared property.
|
|
||||||
* @throws \LogicException
|
|
||||||
*/
|
|
||||||
public function __set(string $name, $value)
|
|
||||||
{
|
|
||||||
$rc = new ReflectionClass($this);
|
|
||||||
$items = array_filter($rc->getProperties(ReflectionProperty::IS_PUBLIC), fn($p) => !$p->isStatic());
|
|
||||||
$items = array_map(fn($item) => $item->getName(), $items);
|
|
||||||
$hint = ($t = Helpers::getSuggestion($items, $name))
|
|
||||||
? ", did you mean $$t?"
|
|
||||||
: '.';
|
|
||||||
throw new \LogicException("Attempt to write to undeclared property {$rc->getName()}::$$name$hint");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function __isset(string $name): bool
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access to undeclared property.
|
|
||||||
* @throws \LogicException
|
|
||||||
*/
|
|
||||||
public function __unset(string $name)
|
|
||||||
{
|
|
||||||
$class = static::class;
|
|
||||||
throw new \LogicException("Attempt to unset undeclared property $class::$$name.");
|
|
||||||
}
|
|
||||||
}
|
|
@@ -15,8 +15,6 @@ namespace Dibi;
|
|||||||
*/
|
*/
|
||||||
final class Translator
|
final class Translator
|
||||||
{
|
{
|
||||||
use Strict;
|
|
||||||
|
|
||||||
/** @var Connection */
|
/** @var Connection */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
|
@@ -37,8 +37,6 @@ declare(strict_types=1);
|
|||||||
*/
|
*/
|
||||||
class dibi
|
class dibi
|
||||||
{
|
{
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
public const
|
public const
|
||||||
AFFECTED_ROWS = 'a',
|
AFFECTED_ROWS = 'a',
|
||||||
IDENTIFIER = 'n';
|
IDENTIFIER = 'n';
|
||||||
|
@@ -1,151 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Tester\Assert;
|
|
||||||
|
|
||||||
require __DIR__ . '/bootstrap.php';
|
|
||||||
|
|
||||||
|
|
||||||
class TestClass
|
|
||||||
{
|
|
||||||
use Dibi\Strict;
|
|
||||||
|
|
||||||
public $public;
|
|
||||||
|
|
||||||
public static $publicStatic;
|
|
||||||
|
|
||||||
protected $protected;
|
|
||||||
|
|
||||||
|
|
||||||
public function publicMethod()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static function publicMethodStatic()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected function protectedMethod()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected static function protectedMethodS()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function getBar()
|
|
||||||
{
|
|
||||||
return 123;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function isFoo()
|
|
||||||
{
|
|
||||||
return 456;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestChild extends TestClass
|
|
||||||
{
|
|
||||||
public function callParent()
|
|
||||||
{
|
|
||||||
parent::callParent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// calling
|
|
||||||
Assert::exception(function () {
|
|
||||||
$obj = new TestClass;
|
|
||||||
$obj->undeclared();
|
|
||||||
}, LogicException::class, 'Call to undefined method TestClass::undeclared().');
|
|
||||||
|
|
||||||
Assert::exception(function () {
|
|
||||||
TestClass::undeclared();
|
|
||||||
}, LogicException::class, 'Call to undefined static method TestClass::undeclared().');
|
|
||||||
|
|
||||||
Assert::exception(function () {
|
|
||||||
$obj = new TestChild;
|
|
||||||
$obj->callParent();
|
|
||||||
}, LogicException::class, 'Call to undefined method parent::callParent().');
|
|
||||||
|
|
||||||
Assert::exception(function () {
|
|
||||||
$obj = new TestClass;
|
|
||||||
$obj->publicMethodX();
|
|
||||||
}, LogicException::class, 'Call to undefined method TestClass::publicMethodX(), did you mean publicMethod()?');
|
|
||||||
|
|
||||||
Assert::exception(function () { // suggest static method
|
|
||||||
$obj = new TestClass;
|
|
||||||
$obj->publicMethodStaticX();
|
|
||||||
}, LogicException::class, 'Call to undefined method TestClass::publicMethodStaticX(), did you mean publicMethodStatic()?');
|
|
||||||
|
|
||||||
Assert::exception(function () { // suggest only public method
|
|
||||||
$obj = new TestClass;
|
|
||||||
$obj->protectedMethodX();
|
|
||||||
}, LogicException::class, 'Call to undefined method TestClass::protectedMethodX().');
|
|
||||||
|
|
||||||
|
|
||||||
// writing
|
|
||||||
Assert::exception(function () {
|
|
||||||
$obj = new TestClass;
|
|
||||||
$obj->undeclared = 'value';
|
|
||||||
}, LogicException::class, 'Attempt to write to undeclared property TestClass::$undeclared.');
|
|
||||||
|
|
||||||
Assert::exception(function () {
|
|
||||||
$obj = new TestClass;
|
|
||||||
$obj->publicX = 'value';
|
|
||||||
}, LogicException::class, 'Attempt to write to undeclared property TestClass::$publicX, did you mean $public?');
|
|
||||||
|
|
||||||
Assert::exception(function () { // suggest only non-static property
|
|
||||||
$obj = new TestClass;
|
|
||||||
$obj->publicStaticX = 'value';
|
|
||||||
}, LogicException::class, 'Attempt to write to undeclared property TestClass::$publicStaticX.');
|
|
||||||
|
|
||||||
Assert::exception(function () { // suggest only public property
|
|
||||||
$obj = new TestClass;
|
|
||||||
$obj->protectedX = 'value';
|
|
||||||
}, LogicException::class, 'Attempt to write to undeclared property TestClass::$protectedX.');
|
|
||||||
|
|
||||||
|
|
||||||
// property getter
|
|
||||||
$obj = new TestClass;
|
|
||||||
Assert::false(isset($obj->bar));
|
|
||||||
Assert::same(123, $obj->bar);
|
|
||||||
Assert::false(isset($obj->foo));
|
|
||||||
Assert::same(456, $obj->foo);
|
|
||||||
|
|
||||||
|
|
||||||
// reading
|
|
||||||
Assert::exception(function () {
|
|
||||||
$obj = new TestClass;
|
|
||||||
$val = $obj->undeclared;
|
|
||||||
}, LogicException::class, 'Attempt to read undeclared property TestClass::$undeclared.');
|
|
||||||
|
|
||||||
Assert::exception(function () {
|
|
||||||
$obj = new TestClass;
|
|
||||||
$val = $obj->publicX;
|
|
||||||
}, LogicException::class, 'Attempt to read undeclared property TestClass::$publicX, did you mean $public?');
|
|
||||||
|
|
||||||
Assert::exception(function () { // suggest only non-static property
|
|
||||||
$obj = new TestClass;
|
|
||||||
$val = $obj->publicStaticX;
|
|
||||||
}, LogicException::class, 'Attempt to read undeclared property TestClass::$publicStaticX.');
|
|
||||||
|
|
||||||
Assert::exception(function () { // suggest only public property
|
|
||||||
$obj = new TestClass;
|
|
||||||
$val = $obj->protectedX;
|
|
||||||
}, LogicException::class, 'Attempt to read undeclared property TestClass::$protectedX.');
|
|
||||||
|
|
||||||
|
|
||||||
// unset/isset
|
|
||||||
Assert::exception(function () {
|
|
||||||
$obj = new TestClass;
|
|
||||||
unset($obj->undeclared);
|
|
||||||
}, LogicException::class, 'Attempt to unset undeclared property TestClass::$undeclared.');
|
|
||||||
|
|
||||||
Assert::false(isset($obj->undeclared));
|
|
Reference in New Issue
Block a user