Skip to content

Commit

Permalink
Missing type hints in $query, $params, $types sets
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod committed Mar 24, 2018
1 parent 274e5ec commit 145cd8b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Cache/QueryCacheProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function getCacheKey()
*
* @return array
*/
public function generateCacheKeys($query, $params, $types, array $connectionParams = [])
public function generateCacheKeys(string $query, array $params = [], array $types = [], array $connectionParams = []) : array
{
$realCacheKey = 'query=' . $query .
'&params=' . serialize($params) .
Expand Down
12 changes: 7 additions & 5 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Doctrine\DBAL;

use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use Closure;
use Exception;
Expand Down Expand Up @@ -879,11 +881,11 @@ public function prepare($statement)
* @param array $types The types the previous parameters are in.
* @param \Doctrine\DBAL\Cache\QueryCacheProfile|null $qcp The query cache profile, optional.
*
* @return \Doctrine\DBAL\Driver\Statement The executed statement.
* @return Statement The executed statement.
*
* @throws \Doctrine\DBAL\DBALException
*/
public function executeQuery($query, array $params = [], $types = [], QueryCacheProfile $qcp = null)
public function executeQuery(string $query, array $params = [], array $types = [], ?QueryCacheProfile $qcp = null) : Statement
{
if ($qcp !== null) {
return $this->executeCacheQuery($query, $params, $types, $qcp);
Expand Down Expand Up @@ -931,7 +933,7 @@ public function executeQuery($query, array $params = [], $types = [], QueryCache
*
* @throws \Doctrine\DBAL\Cache\CacheException
*/
public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qcp)
public function executeCacheQuery(string $query, array $params = [], array $types = [], QueryCacheProfile $qcp) : ResultStatement
{
$resultCache = $qcp->getResultCacheDriver() ?: $this->_config->getResultCacheImpl();
if ( ! $resultCache) {
Expand Down Expand Up @@ -988,7 +990,7 @@ public function project($query, array $params, Closure $function)
/**
* Executes an SQL statement, returning a result set as a Statement object.
*
* @return \Doctrine\DBAL\Driver\Statement
* @return Statement
*
* @throws \Doctrine\DBAL\DBALException
*/
Expand Down Expand Up @@ -1472,7 +1474,7 @@ public function convertToPHPValue($value, $type)
* Binds a set of parameters, some or all of which are typed with a PDO binding type
* or DBAL mapping type, to a given statement.
*
* @param \Doctrine\DBAL\Driver\Statement $stmt The statement to bind the values to.
* @param Statement $stmt The statement to bind the values to.
* @param array $params The map/list of named/positional parameters.
* @param array $types The parameter types (PDO binding types or DBAL mapping types).
*
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/SQLParserUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static function getPlaceholderPositions($statement, $isPositional = true)
*
* @throws SQLParserUtilsException
*/
public static function expandListParameters($query, $params, $types)
public static function expandListParameters(string $query, array $params = [], array $types = []) : array
{
$isPositional = is_int(key($params));
$arrayPositions = [];
Expand Down
4 changes: 3 additions & 1 deletion tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,10 @@ public function dataQueryWithMissingParameters()

/**
* @dataProvider dataQueryWithMissingParameters
* @param mixed[] $params
* @param mixed[] $types
*/
public function testExceptionIsThrownForMissingParam($query, $params, $types = array())
public function testExceptionIsThrownForMissingParam(string $query, array $params = [], array $types = []) : array
{
$this->expectException(
'Doctrine\DBAL\SQLParserUtilsException',
Expand Down

0 comments on commit 145cd8b

Please sign in to comment.