Skip to content

Commit

Permalink
- Fix PHP 5.3 compatibility.
Browse files Browse the repository at this point in the history
* Typehint array parameters.
  • Loading branch information
AnrDaemon committed Sep 29, 2017
1 parent 4f4a2dc commit caa7044
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
------------------------------------------------------------------------
r683 | anrdaemon | 2017-09-29 04:06:21 +0300 (Пт, 29 сен 2017) | 3 lines

- Fix PHP 5.3 compatibility.
* Typehint array parameters.

------------------------------------------------------------------------
r682 | anrdaemon | 2017-09-29 03:42:27 +0300 (Пт, 29 сен 2017) | 2 lines

Expand Down
4 changes: 2 additions & 2 deletions Wrappers/PDOMysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/** PDOWrapper for MySQL with extensions.
*
* @package Wrappers
* @version SVN: $Id: PDOMysql.php 653 2017-06-05 23:02:17Z anrdaemon $
* @version SVN: $Id: PDOMysql.php 683 2017-09-29 01:06:21Z anrdaemon $
*/

namespace AnrDaemon\Wrappers;
Expand All @@ -25,7 +25,7 @@ class PDOMysql extends PDOWrapper
*
* @see PDO::__construct()
*/
public function __construct($dsn, $username = null, $password = null, $options = array())
public function __construct($dsn, $username = null, $password = null, array $options = array())
{
// Hack for PHP < 5.3.6 not honoring charset= in DSN.
// Keep in mind this is NOT entirely safe for ethereal character sets.
Expand Down
4 changes: 2 additions & 2 deletions Wrappers/PDOSqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/** PDO SQLite enhancement wrapper
*
* @package Wrappers
* @version SVN: $Id: PDOSqlite.php 620 2016-12-12 22:23:54Z anrdaemon $
* @version SVN: $Id: PDOSqlite.php 683 2017-09-29 01:06:21Z anrdaemon $
*/

namespace AnrDaemon\Wrappers;
Expand All @@ -22,7 +22,7 @@ class PDOSqlite extends PDOWrapper
* @see PDO::__construct()
* @see AnrDaemon\Wrappers\PDO::__construct()
*/
public function __construct($dsn, $username = null, $password = null, $options = array())
public function __construct($dsn, $username = null, $password = null, array $options = array())
{
parent::__construct($dsn, $username, $password, $options);

Expand Down
16 changes: 8 additions & 8 deletions Wrappers/PDOWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/** PDO chaining wrapper and syntactic sugar.
*
* @package Wrappers
* @version SVN: $Id: PDOWrapper.php 682 2017-09-29 00:42:27Z anrdaemon $
* @version SVN: $Id: PDOWrapper.php 683 2017-09-29 01:06:21Z anrdaemon $
*/

namespace AnrDaemon\Wrappers;
Expand All @@ -25,7 +25,7 @@ class PDOWrapper extends PDO
*
* @see PDO::__construct()
*/
public function __construct($dsn, $username = null, $password = null, $options = array())
public function __construct($dsn, $username = null, $password = null, array $options = array())
{
// Force exceptions over return codes.
$options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
Expand Down Expand Up @@ -74,7 +74,7 @@ public function setAttribute($attribute, $value)
* @see PDO::prepare()
* @see PDOStatement::execute()
*/
public function run($query, $arguments = array())
public function run($query, array $arguments = array())
{
$stmt = $this->prepare($query);
$stmt->execute($arguments);
Expand All @@ -91,13 +91,13 @@ public function run($query, $arguments = array())
* @see PDOStatement::execute()
* @see PDOStatement::fetch()
*/
public function get($query, $arguments = array())
public function get($query, array $arguments = array())
{
$args = func_get_args();
array_shift($args);
array_shift($args);

return call_user_func_array([$this->run($query, $arguments), 'fetch'], $args);
return call_user_func_array(array($this->run($query, $arguments), 'fetch'), $args);
}

/** PDO::prepare()::execute()::fetchColumn() chaining wrapper.
Expand All @@ -111,7 +111,7 @@ public function get($query, $arguments = array())
* @see PDOStatement::execute()
* @see PDOStatement::fetchColumn()
*/
public function getColumn($query, $arguments = array(), $column_number = 0)
public function getColumn($query, array $arguments = array(), $column_number = 0)
{
return $this->run($query, $arguments)->fetchColumn($column_number);
}
Expand All @@ -126,12 +126,12 @@ public function getColumn($query, $arguments = array(), $column_number = 0)
* @see PDOStatement::execute()
* @see PDOStatement::fetchAll()
*/
public function getAll($query, $arguments = array())
public function getAll($query, array $arguments = array())
{
$args = func_get_args();
array_shift($args);
array_shift($args);

return call_user_func_array([$this->run($query, $arguments), 'fetchAll'], $args);
return call_user_func_array(array($this->run($query, $arguments), 'fetchAll'), $args);
}
}

0 comments on commit caa7044

Please sign in to comment.