Skip to content

Commit

Permalink
1.0.3
Browse files Browse the repository at this point in the history
Removed PDO and PDOStatement type declarations
  • Loading branch information
KarelWintersky committed Nov 30, 2022
1 parent c210e92 commit a675051
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 55 deletions.
5 changes: 3 additions & 2 deletions src/Literal.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*/
class Literal
{

/** @var string */
/**
* @var string
*/
protected $value = '';

/**
Expand Down
62 changes: 42 additions & 20 deletions src/Queries/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace AJUR\FluentPDO\Queries;

use DateTime, IteratorAggregate, PDO, PDOStatement;
use DateTime, IteratorAggregate, \PDO, \PDOStatement;
use AJUR\FluentPDO\{Exception, Literal, Query, Regex, Structure, Utilities};

/**
Expand All @@ -11,37 +11,59 @@
abstract class Base implements IteratorAggregate
{

/** @var float */
/**
* @var float
*/
private $totalTime;

/** @var float */
/**
* @var float
*/
private $executionTime;

/** @var bool */
/**
* @var bool
*/
private $object = false;

/** @var Query */
/**
* @var Query
*/
protected $fluent;

/** @var PDOStatement|null|bool */
/**
* @var PDOStatement|null|bool
*/
protected $result;

/** @var array - definition clauses */
/**
* @var array - definition clauses
*/
protected $clauses = [];

/** @var array */
/**
* @var array
*/
protected $statements = [];

/** @var array */
/**
* @var array
*/
protected $parameters = [];

/** @var Regex */
/**
* @var Regex
*/
protected $regex;

/** @var string */
/**
* @var string
*/
protected $message = '';

/** @var int */
/**
* @var int
*/
protected $currentFetchMode;

/**
Expand Down Expand Up @@ -170,7 +192,7 @@ protected function resetClause($clause)
/**
* Implements method from IteratorAggregate
*
* @return PDOStatement
* @return \PDOStatement
*
* @throws Exception
*/
Expand All @@ -182,7 +204,7 @@ public function getIterator()
/**
* Execute query with earlier added parameters
*
* @return PDOStatement
* @return \PDOStatement
*
* @throws Exception
*/
Expand Down Expand Up @@ -218,7 +240,7 @@ protected function getStructure(): Structure
/**
* Get PDOStatement result
*
* @return PDOStatement|null|bool
* @return \PDOStatement|null|bool
*/
public function getResult()
{
Expand Down Expand Up @@ -525,18 +547,18 @@ private function executeQuery(array $parameters, float $startTime = 0, float $ex
/**
* @param PDOStatement $result
*/
private function setObjectFetchMode(PDOStatement $result): void
private function setObjectFetchMode($result): void
{
if ($this->object !== false) {
if (class_exists( $this->object )) {
$this->currentFetchMode = PDO::FETCH_CLASS;
$this->currentFetchMode = \PDO::FETCH_CLASS;
$result->setFetchMode( $this->currentFetchMode, $this->object );
} else {
$this->currentFetchMode = PDO::FETCH_OBJ;
$this->currentFetchMode = \PDO::FETCH_OBJ;
$result->setFetchMode( $this->currentFetchMode );
}
} elseif ($this->fluent->getPdo()->getAttribute( PDO::ATTR_DEFAULT_FETCH_MODE ) === PDO::FETCH_BOTH) {
$this->currentFetchMode = PDO::FETCH_ASSOC;
} elseif ($this->fluent->getPdo()->getAttribute( \PDO::ATTR_DEFAULT_FETCH_MODE ) === \PDO::FETCH_BOTH) {
$this->currentFetchMode = \PDO::FETCH_ASSOC;
$result->setFetchMode( $this->currentFetchMode );
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/Queries/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
abstract class Common extends Base
{

/** @var array - methods which are allowed to be called by the magic method __call() */
/**
* @var array - methods which are allowed to be called by the magic method __call()
*/
private $validMethods = [
'comment',
'from',
Expand All @@ -45,10 +47,14 @@ abstract class Common extends Base
'rightJoin',
];

/** @var array - Query tables (also include table from clause FROM) */
/**
* @var array - Query tables (also include table from clause FROM)
*/
protected $joins = [];

/** @var bool - Disable adding undefined joins to query? */
/**
* @var bool - Disable adding undefined joins to query?
*/
protected $isSmartJoinEnabled = true;

/**
Expand Down
16 changes: 12 additions & 4 deletions src/Queries/Insert.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,24 @@
class Insert extends Base
{

/** @var array */
/**
* @var array
*/
private $columns = [];

/** @var array */
/**
* @var array
*/
private $firstValue = [];

/** @var bool */
/**
* @var bool
*/
private $ignore = false;

/** @var bool */
/**
* @var bool
*/
private $delayed = false;

/**
Expand Down
12 changes: 9 additions & 3 deletions src/Queries/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@
class Json extends Common
{

/** @var mixed */
/**
* @var mixed
*/
protected $fromTable;

/** @var mixed */
/**
* @var mixed
*/
protected $fromAlias;

/** @var boolean */
/**
* @var boolean
*/
protected $convertTypes = false;

/**
Expand Down
12 changes: 9 additions & 3 deletions src/Queries/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@
class Select extends Common implements \Countable
{

/** @var mixed */
/**
* @var mixed
*/
private $fromTable;
/** @var mixed */

/**
* @var mixed
*/
private $fromAlias;

/**
* SelectQuery constructor.
*
* @param Query $fluent
* @param $from
* @param bool $includeTableAliasColumns
*/
public function __construct(Query $fluent, $from, $includeTableAliasColumns = true)
{
Expand Down
48 changes: 33 additions & 15 deletions src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace AJUR\FluentPDO;

use PDO;
use \PDO;
use AJUR\FluentPDO\Queries\{Insert, Select, Update, Delete};

/**
Expand All @@ -22,31 +22,49 @@
*/
class Query
{
/** @var PDO */
/**
* @var
*/
protected $pdo;

/** @var Structure */
/**
* @var * Structure
*/
protected $structure;

/** @var bool|callable */
/**
* @var bool|callable
*/
public $debug = false;

/** @var bool - Determines whether to convert types when fetching rows from Select */
/**
* @var bool - Determines whether to convert types when fetching rows from Select
*/
public $convertRead = false;

/** @var bool - Determines whether to convert types within Base::buildParameters() */
/**
* @var bool - Determines whether to convert types within Base::buildParameters()
*/
public $convertWrite = false;

/** @var bool - If a query errors, this determines how to handle it */
/**
* @var bool - If a query errors, this determines how to handle it
*/
public $exceptionOnError = false;

/** @var string */
/**
* @var string
*/
protected $table;

/** @var string */
/**
* @var string
*/
protected $prefix;

/** @var string */
/**
* @var string
*/
protected $separator;

/**
Expand All @@ -57,16 +75,16 @@ class Query
/**
* Query constructor
*
* @param PDO $pdo
* @param $pdo
* @param ?Structure $structure
* @param bool $includeTableAliasColumns
*/
public function __construct(PDO $pdo, ?Structure $structure = null, $includeTableAliasColumns = true)
public function __construct($pdo, ?Structure $structure = null, $includeTableAliasColumns = true)
{
$this->pdo = $pdo;

// if exceptions are already activated in PDO, activate them in Fluent as well
if ($this->pdo->getAttribute( PDO::ATTR_ERRMODE ) === PDO::ERRMODE_EXCEPTION) {
if ($this->pdo->getAttribute( \PDO::ATTR_ERRMODE ) === \PDO::ERRMODE_EXCEPTION) {
$this->throwExceptionOnError( true );
}

Expand Down Expand Up @@ -187,9 +205,9 @@ public function deleteFrom(?string $table = null, ?int $primaryKey = null): Dele
}

/**
* @return PDO
* @return
*/
public function getPdo(): PDO
public function getPdo()
{
return $this->pdo;
}
Expand Down
14 changes: 11 additions & 3 deletions src/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@
*/
class Regex
{
/** @var string - All UTF-8 letter characters */
/**
* @var string - All UTF-8 letter characters
*/
public const ALPHA = '\p{L}';
/** @var string - All UTF-8 letter and number characters */

/**
* @var string - All UTF-8 letter and number characters
*/
public const ALNUM = '\p{L}\p{N}';
/** @var string - All valid SQL characters except the UTF-8 groupings with quotes and wildcards */

/**
* @var string - All valid SQL characters except the UTF-8 groupings with quotes and wildcards
*/
public const SQLCHARS = '\p{L}\p{N}\p{Pc}\p{Pd}\p{Pf}\p{Pi}';

/**
Expand Down
9 changes: 7 additions & 2 deletions src/Structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
class Structure
{

/** @var string */
/**
* @var string
*/
private $primaryKey;
/** @var string */

/**
* @var string
*/
private $foreignKey;

/**
Expand Down

0 comments on commit a675051

Please sign in to comment.