Unverified Commit b45ed5e1 authored by Marco Pivetta's avatar Marco Pivetta Committed by GitHub

Merge pull request #3306 from morozov/doctrine-coding-standard-5-lib

Fixed coding standard violations in the codebase
parents 37908510 4d509109
...@@ -53,7 +53,6 @@ after_script: ...@@ -53,7 +53,6 @@ after_script:
jobs: jobs:
allow_failures: allow_failures:
- php: nightly - php: nightly
- stage: Coding standard
- env: DB=pgsql POSTGRESQL_VERSION=11.0 - env: DB=pgsql POSTGRESQL_VERSION=11.0
exclude: exclude:
...@@ -431,22 +430,7 @@ jobs: ...@@ -431,22 +430,7 @@ jobs:
install: travis_retry composer update --prefer-dist install: travis_retry composer update --prefer-dist
script: vendor/bin/phpstan analyse script: vendor/bin/phpstan analyse
- stage: Pull request coding standard
if: type = pull_request
php: 7.1
install: travis_retry composer install --prefer-dist
script:
- |
if [ $TRAVIS_BRANCH != "master" ]; then
git remote set-branches --add origin $TRAVIS_BRANCH;
git fetch origin $TRAVIS_BRANCH;
fi
- git merge-base origin/$TRAVIS_BRANCH $TRAVIS_PULL_REQUEST_SHA || git fetch origin +refs/pull/$TRAVIS_PULL_REQUEST/merge --unshallow
- wget https://github.com/diff-sniffer/git/releases/download/0.2.0/git-phpcs.phar
- php git-phpcs.phar origin/$TRAVIS_BRANCH...$TRAVIS_PULL_REQUEST_SHA
- stage: Coding standard - stage: Coding standard
if: NOT type = pull_request
php: 7.1 php: 7.1
install: travis_retry composer install --prefer-dist install: travis_retry composer install --prefer-dist
script: script:
......
...@@ -17,13 +17,13 @@ ...@@ -17,13 +17,13 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
use Symfony\Component\Console\Helper\HelperSet;
use Doctrine\DBAL\Tools\Console\ConsoleRunner; use Doctrine\DBAL\Tools\Console\ConsoleRunner;
use Symfony\Component\Console\Helper\HelperSet;
$files = array(__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php'); $files = [__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php'];
$loader = null; $loader = null;
$cwd = getcwd(); $cwd = getcwd();
$directories = array($cwd, $cwd . DIRECTORY_SEPARATOR . 'config'); $directories = [$cwd, $cwd . DIRECTORY_SEPARATOR . 'config'];
$configFile = null; $configFile = null;
foreach ($files as $file) { foreach ($files as $file) {
...@@ -34,7 +34,7 @@ foreach ($files as $file) { ...@@ -34,7 +34,7 @@ foreach ($files as $file) {
} }
} }
if ( ! $loader) { if (! $loader) {
throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?'); throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?');
} }
...@@ -46,22 +46,22 @@ foreach ($directories as $directory) { ...@@ -46,22 +46,22 @@ foreach ($directories as $directory) {
} }
} }
if ( ! file_exists($configFile)) { if (! file_exists($configFile)) {
ConsoleRunner::printCliConfigTemplate(); ConsoleRunner::printCliConfigTemplate();
exit(1); exit(1);
} }
if ( ! is_readable($configFile)) { if (! is_readable($configFile)) {
echo 'Configuration file [' . $configFile . '] does not have read permission.' . PHP_EOL; echo 'Configuration file [' . $configFile . '] does not have read permission.' . PHP_EOL;
exit(1); exit(1);
} }
$commands = array(); $commands = [];
$helperSet = require $configFile; $helperSet = require $configFile;
if ( ! $helperSet instanceof HelperSet) { if (! $helperSet instanceof HelperSet) {
foreach ($GLOBALS as $helperSetCandidate) { foreach ($GLOBALS as $helperSetCandidate) {
if ($helperSetCandidate instanceof HelperSet) { if ($helperSetCandidate instanceof HelperSet) {
$helperSet = $helperSetCandidate; $helperSet = $helperSetCandidate;
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Cache; namespace Doctrine\DBAL\Cache;
use ArrayIterator;
use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\FetchMode;
use InvalidArgumentException;
use IteratorAggregate;
use PDO;
use function array_merge; use function array_merge;
use function array_values; use function array_values;
use function count; use function count;
use function reset; use function reset;
class ArrayStatement implements \IteratorAggregate, ResultStatement class ArrayStatement implements IteratorAggregate, ResultStatement
{ {
/** /** @var mixed[] */
* @var array
*/
private $data; private $data;
/** /** @var int */
* @var int
*/
private $columnCount = 0; private $columnCount = 0;
/** /** @var int */
* @var int
*/
private $num = 0; private $num = 0;
/** /** @var int */
* @var int
*/
private $defaultFetchMode = FetchMode::MIXED; private $defaultFetchMode = FetchMode::MIXED;
/** /**
* @param array $data * @param mixed[] $data
*/ */
public function __construct(array $data) public function __construct(array $data)
{ {
$this->data = $data; $this->data = $data;
if (count($data)) { if (! count($data)) {
$this->columnCount = count($data[0]); return;
} }
$this->columnCount = count($data[0]);
} }
/** /**
...@@ -64,7 +45,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement ...@@ -64,7 +45,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
*/ */
public function closeCursor() public function closeCursor()
{ {
unset ($this->data); unset($this->data);
} }
/** /**
...@@ -81,7 +62,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement ...@@ -81,7 +62,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{ {
if ($arg2 !== null || $arg3 !== null) { if ($arg2 !== null || $arg3 !== null) {
throw new \InvalidArgumentException("Caching layer does not support 2nd/3rd argument to setFetchMode()"); throw new InvalidArgumentException('Caching layer does not support 2nd/3rd argument to setFetchMode()');
} }
$this->defaultFetchMode = $fetchMode; $this->defaultFetchMode = $fetchMode;
...@@ -96,13 +77,13 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement ...@@ -96,13 +77,13 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
{ {
$data = $this->fetchAll(); $data = $this->fetchAll();
return new \ArrayIterator($data); return new ArrayIterator($data);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0) public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
{ {
if (! isset($this->data[$this->num])) { if (! isset($this->data[$this->num])) {
return false; return false;
...@@ -127,7 +108,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement ...@@ -127,7 +108,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
return reset($row); return reset($row);
} }
throw new \InvalidArgumentException('Invalid fetch-style given for fetching result.'); throw new InvalidArgumentException('Invalid fetch-style given for fetching result.');
} }
/** /**
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Cache; namespace Doctrine\DBAL\Cache;
/** use Doctrine\DBAL\DBALException;
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @since 2.2 class CacheException extends DBALException
*/
class CacheException extends \Doctrine\DBAL\DBALException
{ {
/** /**
* @return \Doctrine\DBAL\Cache\CacheException * @return \Doctrine\DBAL\Cache\CacheException
*/ */
public static function noCacheKey() public static function noCacheKey()
{ {
return new self("No cache key was set."); return new self('No cache key was set.');
} }
/** /**
...@@ -38,6 +19,6 @@ class CacheException extends \Doctrine\DBAL\DBALException ...@@ -38,6 +19,6 @@ class CacheException extends \Doctrine\DBAL\DBALException
*/ */
public static function noResultDriverConfigured() public static function noResultDriverConfigured()
{ {
return new self("Trying to cache a query but no result driver is configured."); return new self('Trying to cache a query but no result driver is configured.');
} }
} }
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Cache; namespace Doctrine\DBAL\Cache;
...@@ -31,19 +14,13 @@ use function sha1; ...@@ -31,19 +14,13 @@ use function sha1;
*/ */
class QueryCacheProfile class QueryCacheProfile
{ {
/** /** @var Cache|null */
* @var Cache|null
*/
private $resultCacheDriver; private $resultCacheDriver;
/** /** @var int */
* @var int
*/
private $lifetime = 0; private $lifetime = 0;
/** /** @var string|null */
* @var string|null
*/
private $cacheKey; private $cacheKey;
/** /**
...@@ -91,11 +68,11 @@ class QueryCacheProfile ...@@ -91,11 +68,11 @@ class QueryCacheProfile
* Generates the real cache key from query, params, types and connection parameters. * Generates the real cache key from query, params, types and connection parameters.
* *
* @param string $query * @param string $query
* @param array $params * @param mixed[] $params
* @param array $types * @param int[]|string[] $types
* @param array $connectionParams * @param mixed[] $connectionParams
* *
* @return array * @return string[]
*/ */
public function generateCacheKeys($query, $params, $types, array $connectionParams = []) public function generateCacheKeys($query, $params, $types, array $connectionParams = [])
{ {
...@@ -115,7 +92,6 @@ class QueryCacheProfile ...@@ -115,7 +92,6 @@ class QueryCacheProfile
} }
/** /**
*
* @return \Doctrine\DBAL\Cache\QueryCacheProfile * @return \Doctrine\DBAL\Cache\QueryCacheProfile
*/ */
public function setResultCacheDriver(Cache $cache) public function setResultCacheDriver(Cache $cache)
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Cache; namespace Doctrine\DBAL\Cache;
use Doctrine\DBAL\Driver\Statement; use ArrayIterator;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\Common\Cache\Cache; use Doctrine\Common\Cache\Cache;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\FetchMode;
use InvalidArgumentException;
use IteratorAggregate;
use PDO;
use function array_merge; use function array_merge;
use function array_values; use function array_values;
use function reset; use function reset;
...@@ -40,32 +27,21 @@ use function reset; ...@@ -40,32 +27,21 @@ use function reset;
* Also you have to realize that the cache will load the whole result into memory at once to ensure 2. * Also you have to realize that the cache will load the whole result into memory at once to ensure 2.
* This means that the memory usage for cached results might increase by using this feature. * This means that the memory usage for cached results might increase by using this feature.
*/ */
class ResultCacheStatement implements \IteratorAggregate, ResultStatement class ResultCacheStatement implements IteratorAggregate, ResultStatement
{ {
/** /** @var Cache */
* @var \Doctrine\Common\Cache\Cache
*/
private $resultCache; private $resultCache;
/** /** @var string */
*
* @var string
*/
private $cacheKey; private $cacheKey;
/** /** @var string */
* @var string
*/
private $realKey; private $realKey;
/** /** @var int */
* @var int
*/
private $lifetime; private $lifetime;
/** /** @var Statement */
* @var \Doctrine\DBAL\Driver\Statement
*/
private $statement; private $statement;
/** /**
...@@ -75,19 +51,13 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement ...@@ -75,19 +51,13 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
*/ */
private $emptied = false; private $emptied = false;
/** /** @var mixed[] */
* @var array
*/
private $data; private $data;
/** /** @var int */
* @var int
*/
private $defaultFetchMode = FetchMode::MIXED; private $defaultFetchMode = FetchMode::MIXED;
/** /**
* @param \Doctrine\DBAL\Driver\Statement $stmt
* @param \Doctrine\Common\Cache\Cache $resultCache
* @param string $cacheKey * @param string $cacheKey
* @param string $realKey * @param string $realKey
* @param int $lifetime * @param int $lifetime
...@@ -107,16 +77,20 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement ...@@ -107,16 +77,20 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
public function closeCursor() public function closeCursor()
{ {
$this->statement->closeCursor(); $this->statement->closeCursor();
if ($this->emptied && $this->data !== null) { if (! $this->emptied || $this->data === null) {
return true;
}
$data = $this->resultCache->fetch($this->cacheKey); $data = $this->resultCache->fetch($this->cacheKey);
if ( ! $data) { if (! $data) {
$data = []; $data = [];
} }
$data[$this->realKey] = $this->data; $data[$this->realKey] = $this->data;
$this->resultCache->save($this->cacheKey, $data, $this->lifetime); $this->resultCache->save($this->cacheKey, $data, $this->lifetime);
unset($this->data); unset($this->data);
}
return true;
} }
/** /**
...@@ -144,13 +118,13 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement ...@@ -144,13 +118,13 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
{ {
$data = $this->fetchAll(); $data = $this->fetchAll();
return new \ArrayIterator($data); return new ArrayIterator($data);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0) public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
{ {
if ($this->data === null) { if ($this->data === null) {
$this->data = []; $this->data = [];
...@@ -179,7 +153,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement ...@@ -179,7 +153,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
return reset($row); return reset($row);
} }
throw new \InvalidArgumentException('Invalid fetch-style given for caching result.'); throw new InvalidArgumentException('Invalid fetch-style given for caching result.');
} }
$this->emptied = true; $this->emptied = true;
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace Doctrine\DBAL; namespace Doctrine\DBAL;
use PDO;
/** /**
* Contains portable column case conversions. * Contains portable column case conversions.
*/ */
...@@ -12,14 +14,14 @@ final class ColumnCase ...@@ -12,14 +14,14 @@ final class ColumnCase
* *
* @see \PDO::CASE_UPPER * @see \PDO::CASE_UPPER
*/ */
public const UPPER = \PDO::CASE_UPPER; public const UPPER = PDO::CASE_UPPER;
/** /**
* Convert column names to lower case. * Convert column names to lower case.
* *
* @see \PDO::CASE_LOWER * @see \PDO::CASE_LOWER
*/ */
public const LOWER = \PDO::CASE_LOWER; public const LOWER = PDO::CASE_LOWER;
/** /**
* This class cannot be instantiated. * This class cannot be instantiated.
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL; namespace Doctrine\DBAL;
use Doctrine\DBAL\Logging\SQLLogger;
use Doctrine\Common\Cache\Cache; use Doctrine\Common\Cache\Cache;
use Doctrine\DBAL\Logging\SQLLogger;
/** /**
* Configuration container for the Doctrine DBAL. * Configuration container for the Doctrine DBAL.
* *
* @since 2.0
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @internal When adding a new configuration option just write a getter/setter * @internal When adding a new configuration option just write a getter/setter
* pair and add the option to the _attributes array with a proper default value. * pair and add the option to the _attributes array with a proper default value.
*/ */
...@@ -38,18 +17,16 @@ class Configuration ...@@ -38,18 +17,16 @@ class Configuration
* The attributes that are contained in the configuration. * The attributes that are contained in the configuration.
* Values are default values. * Values are default values.
* *
* @var array * @var mixed[]
*/ */
protected $_attributes = []; protected $_attributes = [];
/** /**
* Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled. * Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled.
* *
* @param \Doctrine\DBAL\Logging\SQLLogger|null $logger
*
* @return void * @return void
*/ */
public function setSQLLogger(SQLLogger $logger = null) public function setSQLLogger(?SQLLogger $logger = null)
{ {
$this->_attributes['sqlLogger'] = $logger; $this->_attributes['sqlLogger'] = $logger;
} }
...@@ -57,7 +34,7 @@ class Configuration ...@@ -57,7 +34,7 @@ class Configuration
/** /**
* Gets the SQL logger that is used. * Gets the SQL logger that is used.
* *
* @return \Doctrine\DBAL\Logging\SQLLogger|null * @return SQLLogger|null
*/ */
public function getSQLLogger() public function getSQLLogger()
{ {
...@@ -67,7 +44,7 @@ class Configuration ...@@ -67,7 +44,7 @@ class Configuration
/** /**
* Gets the cache driver implementation that is used for query result caching. * Gets the cache driver implementation that is used for query result caching.
* *
* @return \Doctrine\Common\Cache\Cache|null * @return Cache|null
*/ */
public function getResultCacheImpl() public function getResultCacheImpl()
{ {
...@@ -77,8 +54,6 @@ class Configuration ...@@ -77,8 +54,6 @@ class Configuration
/** /**
* Sets the cache driver implementation that is used for query result caching. * Sets the cache driver implementation that is used for query result caching.
* *
* @param \Doctrine\Common\Cache\Cache $cacheImpl
*
* @return void * @return void
*/ */
public function setResultCacheImpl(Cache $cacheImpl) public function setResultCacheImpl(Cache $cacheImpl)
...@@ -119,21 +94,21 @@ class Configuration ...@@ -119,21 +94,21 @@ class Configuration
* transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either * transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either
* the method commit or the method rollback. By default, new connections are in auto-commit mode. * the method commit or the method rollback. By default, new connections are in auto-commit mode.
* *
* @param bool $autoCommit True to enable auto-commit mode; false to disable it.
*
* @see getAutoCommit * @see getAutoCommit
*
* @param bool $autoCommit True to enable auto-commit mode; false to disable it.
*/ */
public function setAutoCommit($autoCommit) public function setAutoCommit($autoCommit)
{ {
$this->_attributes['autoCommit'] = (boolean) $autoCommit; $this->_attributes['autoCommit'] = (bool) $autoCommit;
} }
/** /**
* Returns the default auto-commit mode for connections. * Returns the default auto-commit mode for connections.
* *
* @return bool True if auto-commit mode is enabled by default for connections, false otherwise.
*
* @see setAutoCommit * @see setAutoCommit
*
* @return bool True if auto-commit mode is enabled by default for connections, false otherwise.
*/ */
public function getAutoCommit() public function getAutoCommit()
{ {
......
This diff is collapsed.
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL; namespace Doctrine\DBAL;
/** /**
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.0
* @author Jonathan H. Wage <jonwage@gmail.com
*/ */
class ConnectionException extends DBALException class ConnectionException extends DBALException
{ {
...@@ -31,7 +12,7 @@ class ConnectionException extends DBALException ...@@ -31,7 +12,7 @@ class ConnectionException extends DBALException
*/ */
public static function commitFailedRollbackOnly() public static function commitFailedRollbackOnly()
{ {
return new self("Transaction commit failed because the transaction has been marked for rollback only."); return new self('Transaction commit failed because the transaction has been marked for rollback only.');
} }
/** /**
...@@ -39,7 +20,7 @@ class ConnectionException extends DBALException ...@@ -39,7 +20,7 @@ class ConnectionException extends DBALException
*/ */
public static function noActiveTransaction() public static function noActiveTransaction()
{ {
return new self("There is no active transaction."); return new self('There is no active transaction.');
} }
/** /**
...@@ -47,7 +28,7 @@ class ConnectionException extends DBALException ...@@ -47,7 +28,7 @@ class ConnectionException extends DBALException
*/ */
public static function savepointsNotSupported() public static function savepointsNotSupported()
{ {
return new self("Savepoints are not supported by this driver."); return new self('Savepoints are not supported by this driver.');
} }
/** /**
...@@ -55,6 +36,6 @@ class ConnectionException extends DBALException ...@@ -55,6 +36,6 @@ class ConnectionException extends DBALException
*/ */
public static function mayNotAlterNestedTransactionWithSavepointsInTransaction() public static function mayNotAlterNestedTransactionWithSavepointsInTransaction()
{ {
return new self("May not alter the nested transaction with savepoints behavior while a transaction is open."); return new self('May not alter the nested transaction with savepoints behavior while a transaction is open.');
} }
} }
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Connections; namespace Doctrine\DBAL\Connections;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Configuration;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Event\ConnectionEventArgs; use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Events; use Doctrine\DBAL\Events;
use InvalidArgumentException;
use function array_rand; use function array_rand;
use function count; use function count;
use function func_get_args; use function func_get_args;
...@@ -80,9 +64,6 @@ use function func_get_args; ...@@ -80,9 +64,6 @@ use function func_get_args;
* )); * ));
* *
* You can also pass 'driverOptions' and any other documented option to each of this drivers to pass additional information. * You can also pass 'driverOptions' and any other documented option to each of this drivers to pass additional information.
*
* @author Lars Strojny <lstrojny@php.net>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/ */
class MasterSlaveConnection extends Connection class MasterSlaveConnection extends Connection
{ {
...@@ -104,20 +85,17 @@ class MasterSlaveConnection extends Connection ...@@ -104,20 +85,17 @@ class MasterSlaveConnection extends Connection
/** /**
* Creates Master Slave Connection. * Creates Master Slave Connection.
* *
* @param array $params * @param mixed[] $params
* @param \Doctrine\DBAL\Driver $driver
* @param \Doctrine\DBAL\Configuration|null $config
* @param \Doctrine\Common\EventManager|null $eventManager
* *
* @throws \InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null) public function __construct(array $params, Driver $driver, ?Configuration $config = null, ?EventManager $eventManager = null)
{ {
if (! isset($params['slaves'], $params['master'])) { if (! isset($params['slaves'], $params['master'])) {
throw new \InvalidArgumentException('master or slaves configuration missing'); throw new InvalidArgumentException('master or slaves configuration missing');
} }
if (count($params['slaves']) == 0) { if (count($params['slaves']) === 0) {
throw new \InvalidArgumentException('You have to configure at least one slaves.'); throw new InvalidArgumentException('You have to configure at least one slaves.');
} }
$params['master']['driver'] = $params['driver']; $params['master']['driver'] = $params['driver'];
...@@ -149,13 +127,13 @@ class MasterSlaveConnection extends Connection ...@@ -149,13 +127,13 @@ class MasterSlaveConnection extends Connection
$connectionName = $connectionName ?: 'slave'; $connectionName = $connectionName ?: 'slave';
if ($connectionName !== 'slave' && $connectionName !== 'master') { if ($connectionName !== 'slave' && $connectionName !== 'master') {
throw new \InvalidArgumentException("Invalid option to connect(), only master or slave allowed."); throw new InvalidArgumentException('Invalid option to connect(), only master or slave allowed.');
} }
// If we have a connection open, and this is not an explicit connection // If we have a connection open, and this is not an explicit connection
// change request, then abort right here, because we are already done. // change request, then abort right here, because we are already done.
// This prevents writes to the slave in case of "keepSlave" option enabled. // This prevents writes to the slave in case of "keepSlave" option enabled.
if (isset($this->_conn) && $this->_conn && !$requestedConnectionChange) { if (isset($this->_conn) && $this->_conn && ! $requestedConnectionChange) {
return false; return false;
} }
...@@ -180,7 +158,7 @@ class MasterSlaveConnection extends Connection ...@@ -180,7 +158,7 @@ class MasterSlaveConnection extends Connection
$this->connections['master'] = $this->_conn = $this->connectTo($connectionName); $this->connections['master'] = $this->_conn = $this->connectTo($connectionName);
// Set slave connection to master to avoid invalid reads // Set slave connection to master to avoid invalid reads
if ( ! $this->keepSlave) { if (! $this->keepSlave) {
$this->connections['slave'] = $this->connections['master']; $this->connections['slave'] = $this->connections['master'];
} }
} else { } else {
...@@ -218,7 +196,7 @@ class MasterSlaveConnection extends Connection ...@@ -218,7 +196,7 @@ class MasterSlaveConnection extends Connection
/** /**
* @param string $connectionName * @param string $connectionName
* @param array $params * @param mixed[] $params
* *
* @return mixed * @return mixed
*/ */
...@@ -230,7 +208,7 @@ class MasterSlaveConnection extends Connection ...@@ -230,7 +208,7 @@ class MasterSlaveConnection extends Connection
$config = $params['slaves'][array_rand($params['slaves'])]; $config = $params['slaves'][array_rand($params['slaves'])];
if ( ! isset($config['charset']) && isset($params['master']['charset'])) { if (! isset($config['charset']) && isset($params['master']['charset'])) {
$config['charset'] = $params['master']['charset']; $config['charset'] = $params['master']['charset'];
} }
......
This diff is collapsed.
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL; namespace Doctrine\DBAL;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
/** /**
* Driver interface. * Driver interface.
* Interface that all DBAL drivers must implement. * Interface that all DBAL drivers must implement.
*
* @since 2.0
*/ */
interface Driver interface Driver
{ {
/** /**
* Attempts to create a connection with the database. * Attempts to create a connection with the database.
* *
* @param array $params All connection parameters passed by the user. * @param mixed[] $params All connection parameters passed by the user.
* @param string|null $username The username to use when connecting. * @param string|null $username The username to use when connecting.
* @param string|null $password The password to use when connecting. * @param string|null $password The password to use when connecting.
* @param array $driverOptions The driver options to use when connecting. * @param mixed[] $driverOptions The driver options to use when connecting.
* *
* @return \Doctrine\DBAL\Driver\Connection The database connection. * @return \Doctrine\DBAL\Driver\Connection The database connection.
*/ */
...@@ -43,7 +27,7 @@ interface Driver ...@@ -43,7 +27,7 @@ interface Driver
* Gets the DatabasePlatform instance that provides all the metadata about * Gets the DatabasePlatform instance that provides all the metadata about
* the platform this driver connects to. * the platform this driver connects to.
* *
* @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform. * @return AbstractPlatform The database platform.
*/ */
public function getDatabasePlatform(); public function getDatabasePlatform();
...@@ -51,9 +35,7 @@ interface Driver ...@@ -51,9 +35,7 @@ interface Driver
* Gets the SchemaManager that can be used to inspect and change the underlying * Gets the SchemaManager that can be used to inspect and change the underlying
* database schema of the platform this driver connects to. * database schema of the platform this driver connects to.
* *
* @param \Doctrine\DBAL\Connection $conn * @return AbstractSchemaManager
*
* @return \Doctrine\DBAL\Schema\AbstractSchemaManager
*/ */
public function getSchemaManager(Connection $conn); public function getSchemaManager(Connection $conn);
...@@ -67,8 +49,6 @@ interface Driver ...@@ -67,8 +49,6 @@ interface Driver
/** /**
* Gets the name of the database connected to for this driver. * Gets the name of the database connected to for this driver.
* *
* @param \Doctrine\DBAL\Connection $conn
*
* @return string The name of the database. * @return string The name of the database.
*/ */
public function getDatabase(Connection $conn); public function getDatabase(Connection $conn);
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver; namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Platforms\DB2Platform; use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Schema\DB2SchemaManager; use Doctrine\DBAL\Schema\DB2SchemaManager;
...@@ -26,16 +10,14 @@ use Doctrine\DBAL\Schema\DB2SchemaManager; ...@@ -26,16 +10,14 @@ use Doctrine\DBAL\Schema\DB2SchemaManager;
/** /**
* Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for IBM DB2 based drivers. * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for IBM DB2 based drivers.
* *
* @author Steve Müller <st.mueller@dzh-online.de>
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.5
*/ */
abstract class AbstractDB2Driver implements Driver abstract class AbstractDB2Driver implements Driver
{ {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getDatabase(\Doctrine\DBAL\Connection $conn) public function getDatabase(Connection $conn)
{ {
$params = $conn->getParams(); $params = $conn->getParams();
...@@ -53,7 +35,7 @@ abstract class AbstractDB2Driver implements Driver ...@@ -53,7 +35,7 @@ abstract class AbstractDB2Driver implements Driver
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getSchemaManager(\Doctrine\DBAL\Connection $conn) public function getSchemaManager(Connection $conn)
{ {
return new DB2SchemaManager($conn); return new DB2SchemaManager($conn);
} }
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver; namespace Doctrine\DBAL\Driver;
use Exception;
/** /**
* Abstract base implementation of the {@link DriverException} interface. * Abstract base implementation of the {@link DriverException} interface.
* *
* @author Steve Müller <st.mueller@dzh-online.de>
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.5
*/ */
abstract class AbstractDriverException extends \Exception implements DriverException abstract class AbstractDriverException extends Exception implements DriverException
{ {
/** /**
* The driver specific error code. * The driver specific error code.
...@@ -43,8 +26,6 @@ abstract class AbstractDriverException extends \Exception implements DriverExcep ...@@ -43,8 +26,6 @@ abstract class AbstractDriverException extends \Exception implements DriverExcep
private $sqlState; private $sqlState;
/** /**
* Constructor.
*
* @param string $message The driver error message. * @param string $message The driver error message.
* @param string|null $sqlState The SQLSTATE the driver is in at the time the error occurred, if any. * @param string|null $sqlState The SQLSTATE the driver is in at the time the error occurred, if any.
* @param int|string|null $errorCode The driver specific error code if any. * @param int|string|null $errorCode The driver specific error code if any.
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver; namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception;
...@@ -35,9 +19,7 @@ use function version_compare; ...@@ -35,9 +19,7 @@ use function version_compare;
/** /**
* Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for MySQL based drivers. * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for MySQL based drivers.
* *
* @author Steve Müller <st.mueller@dzh-online.de>
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.5
*/ */
abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, VersionAwarePlatformDriver abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, VersionAwarePlatformDriver
{ {
...@@ -133,7 +115,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, ...@@ -133,7 +115,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
*/ */
public function createDatabasePlatformForVersion($version) public function createDatabasePlatformForVersion($version)
{ {
$mariadb = false !== stripos($version, 'mariadb'); $mariadb = stripos($version, 'mariadb') !== false;
if ($mariadb && version_compare($this->getMariaDbMysqlVersionNumber($version), '10.2.7', '>=')) { if ($mariadb && version_compare($this->getMariaDbMysqlVersionNumber($version), '10.2.7', '>=')) {
return new MariaDb1027Platform(); return new MariaDb1027Platform();
} }
...@@ -156,11 +138,12 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, ...@@ -156,11 +138,12 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
* returned by Oracle MySQL servers. * returned by Oracle MySQL servers.
* *
* @param string $versionString Version string returned by the driver, i.e. '5.7.10' * @param string $versionString Version string returned by the driver, i.e. '5.7.10'
*
* @throws DBALException * @throws DBALException
*/ */
private function getOracleMysqlVersionNumber(string $versionString) : string private function getOracleMysqlVersionNumber(string $versionString) : string
{ {
if ( ! preg_match( if (! preg_match(
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/', '/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/',
$versionString, $versionString,
$versionParts $versionParts
...@@ -174,7 +157,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, ...@@ -174,7 +157,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
$minorVersion = $versionParts['minor'] ?? 0; $minorVersion = $versionParts['minor'] ?? 0;
$patchVersion = $versionParts['patch'] ?? null; $patchVersion = $versionParts['patch'] ?? null;
if ('5' === $majorVersion && '7' === $minorVersion && null === $patchVersion) { if ($majorVersion === '5' && $minorVersion === '7' && $patchVersion === null) {
$patchVersion = '9'; $patchVersion = '9';
} }
...@@ -186,11 +169,12 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, ...@@ -186,11 +169,12 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
* that starts with the prefix '5.5.5-' * that starts with the prefix '5.5.5-'
* *
* @param string $versionString Version string as returned by mariadb server, i.e. '5.5.5-Mariadb-10.0.8-xenial' * @param string $versionString Version string as returned by mariadb server, i.e. '5.5.5-Mariadb-10.0.8-xenial'
*
* @throws DBALException * @throws DBALException
*/ */
private function getMariaDbMysqlVersionNumber(string $versionString) : string private function getMariaDbMysqlVersionNumber(string $versionString) : string
{ {
if ( ! preg_match( if (! preg_match(
'/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i', '/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i',
$versionString, $versionString,
$versionParts $versionParts
...@@ -207,7 +191,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, ...@@ -207,7 +191,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getDatabase(\Doctrine\DBAL\Connection $conn) public function getDatabase(Connection $conn)
{ {
$params = $conn->getParams(); $params = $conn->getParams();
...@@ -216,6 +200,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, ...@@ -216,6 +200,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @return MySqlPlatform * @return MySqlPlatform
*/ */
public function getDatabasePlatform() public function getDatabasePlatform()
...@@ -225,9 +210,10 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, ...@@ -225,9 +210,10 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @return MySqlSchemaManager * @return MySqlSchemaManager
*/ */
public function getSchemaManager(\Doctrine\DBAL\Connection $conn) public function getSchemaManager(Connection $conn)
{ {
return new MySqlSchemaManager($conn); return new MySqlSchemaManager($conn);
} }
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver; namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString; use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString;
use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception;
...@@ -28,9 +12,7 @@ use Doctrine\DBAL\Schema\OracleSchemaManager; ...@@ -28,9 +12,7 @@ use Doctrine\DBAL\Schema\OracleSchemaManager;
/** /**
* Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for Oracle based drivers. * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for Oracle based drivers.
* *
* @author Steve Müller <st.mueller@dzh-online.de>
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.5
*/ */
abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
{ {
...@@ -80,7 +62,7 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver ...@@ -80,7 +62,7 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getDatabase(\Doctrine\DBAL\Connection $conn) public function getDatabase(Connection $conn)
{ {
$params = $conn->getParams(); $params = $conn->getParams();
...@@ -98,7 +80,7 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver ...@@ -98,7 +80,7 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getSchemaManager(\Doctrine\DBAL\Connection $conn) public function getSchemaManager(Connection $conn)
{ {
return new OracleSchemaManager($conn); return new OracleSchemaManager($conn);
} }
...@@ -106,7 +88,7 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver ...@@ -106,7 +88,7 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
/** /**
* Returns an appropriate Easy Connect String for the given parameters. * Returns an appropriate Easy Connect String for the given parameters.
* *
* @param array $params The connection parameters to return the Easy Connect STring for. * @param mixed[] $params The connection parameters to return the Easy Connect String for.
* *
* @return string * @return string
*/ */
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver; namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception;
...@@ -36,9 +20,7 @@ use function version_compare; ...@@ -36,9 +20,7 @@ use function version_compare;
/** /**
* Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for PostgreSQL based drivers. * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for PostgreSQL based drivers.
* *
* @author Steve Müller <st.mueller@dzh-online.de>
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.5
*/ */
abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDriver, VersionAwarePlatformDriver abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDriver, VersionAwarePlatformDriver
{ {
...@@ -104,7 +86,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri ...@@ -104,7 +86,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri
*/ */
public function createDatabasePlatformForVersion($version) public function createDatabasePlatformForVersion($version)
{ {
if ( ! preg_match('/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/', $version, $versionParts)) { if (! preg_match('/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/', $version, $versionParts)) {
throw DBALException::invalidPlatformVersionSpecified( throw DBALException::invalidPlatformVersionSpecified(
$version, $version,
'<major_version>.<minor_version>.<patch_version>' '<major_version>.<minor_version>.<patch_version>'
...@@ -116,7 +98,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri ...@@ -116,7 +98,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri
$patchVersion = $versionParts['patch'] ?? 0; $patchVersion = $versionParts['patch'] ?? 0;
$version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion; $version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
switch(true) { switch (true) {
case version_compare($version, '10.0', '>='): case version_compare($version, '10.0', '>='):
return new PostgreSQL100Platform(); return new PostgreSQL100Platform();
case version_compare($version, '9.4', '>='): case version_compare($version, '9.4', '>='):
...@@ -133,7 +115,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri ...@@ -133,7 +115,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getDatabase(\Doctrine\DBAL\Connection $conn) public function getDatabase(Connection $conn)
{ {
$params = $conn->getParams(); $params = $conn->getParams();
...@@ -151,7 +133,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri ...@@ -151,7 +133,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getSchemaManager(\Doctrine\DBAL\Connection $conn) public function getSchemaManager(Connection $conn)
{ {
return new PostgreSqlSchemaManager($conn); return new PostgreSqlSchemaManager($conn);
} }
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver; namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception;
...@@ -34,9 +18,7 @@ use function version_compare; ...@@ -34,9 +18,7 @@ use function version_compare;
/** /**
* Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for SAP Sybase SQL Anywhere based drivers. * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for SAP Sybase SQL Anywhere based drivers.
* *
* @author Steve Müller <st.mueller@dzh-online.de>
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.5
*/ */
abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDriver, VersionAwarePlatformDriver abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDriver, VersionAwarePlatformDriver
{ {
...@@ -90,7 +72,7 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr ...@@ -90,7 +72,7 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr
*/ */
public function createDatabasePlatformForVersion($version) public function createDatabasePlatformForVersion($version)
{ {
if ( ! preg_match( if (! preg_match(
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+)(?:\.(?P<build>\d+))?)?)?/', '/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+)(?:\.(?P<build>\d+))?)?)?/',
$version, $version,
$versionParts $versionParts
...@@ -107,7 +89,7 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr ...@@ -107,7 +89,7 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr
$buildVersion = $versionParts['build'] ?? 0; $buildVersion = $versionParts['build'] ?? 0;
$version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion . '.' . $buildVersion; $version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion . '.' . $buildVersion;
switch(true) { switch (true) {
case version_compare($version, '16', '>='): case version_compare($version, '16', '>='):
return new SQLAnywhere16Platform(); return new SQLAnywhere16Platform();
case version_compare($version, '12', '>='): case version_compare($version, '12', '>='):
...@@ -122,7 +104,7 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr ...@@ -122,7 +104,7 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getDatabase(\Doctrine\DBAL\Connection $conn) public function getDatabase(Connection $conn)
{ {
$params = $conn->getParams(); $params = $conn->getParams();
...@@ -140,7 +122,7 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr ...@@ -140,7 +122,7 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getSchemaManager(\Doctrine\DBAL\Connection $conn) public function getSchemaManager(Connection $conn)
{ {
return new SQLAnywhereSchemaManager($conn); return new SQLAnywhereSchemaManager($conn);
} }
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver; namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Platforms\SQLServer2005Platform; use Doctrine\DBAL\Platforms\SQLServer2005Platform;
...@@ -33,9 +17,7 @@ use function version_compare; ...@@ -33,9 +17,7 @@ use function version_compare;
/** /**
* Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for Microsoft SQL Server based drivers. * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for Microsoft SQL Server based drivers.
* *
* @author Steve Müller <st.mueller@dzh-online.de>
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.5
*/ */
abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDriver abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDriver
{ {
...@@ -44,7 +26,7 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr ...@@ -44,7 +26,7 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr
*/ */
public function createDatabasePlatformForVersion($version) public function createDatabasePlatformForVersion($version)
{ {
if ( ! preg_match( if (! preg_match(
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+)(?:\.(?P<build>\d+))?)?)?/', '/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+)(?:\.(?P<build>\d+))?)?)?/',
$version, $version,
$versionParts $versionParts
...@@ -61,7 +43,7 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr ...@@ -61,7 +43,7 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr
$buildVersion = $versionParts['build'] ?? 0; $buildVersion = $versionParts['build'] ?? 0;
$version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion . '.' . $buildVersion; $version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion . '.' . $buildVersion;
switch(true) { switch (true) {
case version_compare($version, '11.00.2100', '>='): case version_compare($version, '11.00.2100', '>='):
return new SQLServer2012Platform(); return new SQLServer2012Platform();
case version_compare($version, '10.00.1600', '>='): case version_compare($version, '10.00.1600', '>='):
...@@ -76,7 +58,7 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr ...@@ -76,7 +58,7 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getDatabase(\Doctrine\DBAL\Connection $conn) public function getDatabase(Connection $conn)
{ {
$params = $conn->getParams(); $params = $conn->getParams();
...@@ -94,8 +76,7 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr ...@@ -94,8 +76,7 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getSchemaManager(Connection $conn)
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
{ {
return new SQLServerSchemaManager($conn); return new SQLServerSchemaManager($conn);
} }
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver; namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Platforms\SqlitePlatform;
...@@ -28,9 +12,7 @@ use function strpos; ...@@ -28,9 +12,7 @@ use function strpos;
/** /**
* Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for SQLite based drivers. * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for SQLite based drivers.
* *
* @author Steve Müller <st.mueller@dzh-online.de>
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.5
*/ */
abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver
{ {
...@@ -93,7 +75,7 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver ...@@ -93,7 +75,7 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getDatabase(\Doctrine\DBAL\Connection $conn) public function getDatabase(Connection $conn)
{ {
$params = $conn->getParams(); $params = $conn->getParams();
...@@ -111,7 +93,7 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver ...@@ -111,7 +93,7 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getSchemaManager(\Doctrine\DBAL\Connection $conn) public function getSchemaManager(Connection $conn)
{ {
return new SqliteSchemaManager($conn); return new SqliteSchemaManager($conn);
} }
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver; namespace Doctrine\DBAL\Driver;
...@@ -26,8 +9,6 @@ use Doctrine\DBAL\ParameterType; ...@@ -26,8 +9,6 @@ use Doctrine\DBAL\ParameterType;
* Driver connections must implement this interface. * Driver connections must implement this interface.
* *
* This resembles (a subset of) the PDO interface. * This resembles (a subset of) the PDO interface.
*
* @since 2.0
*/ */
interface Connection interface Connection
{ {
...@@ -43,7 +24,7 @@ interface Connection ...@@ -43,7 +24,7 @@ interface Connection
/** /**
* Executes an SQL statement, returning a result set as a Statement object. * Executes an SQL statement, returning a result set as a Statement object.
* *
* @return \Doctrine\DBAL\Driver\Statement * @return Statement
*/ */
public function query(); public function query();
...@@ -106,7 +87,7 @@ interface Connection ...@@ -106,7 +87,7 @@ interface Connection
/** /**
* Returns extended error information associated with the last operation on the database handle. * Returns extended error information associated with the last operation on the database handle.
* *
* @return array * @return mixed[]
*/ */
public function errorInfo(); public function errorInfo();
} }
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver; namespace Doctrine\DBAL\Driver;
use Throwable;
/** /**
* Contract for a driver exception. * Contract for a driver exception.
* *
* Driver exceptions provide the SQLSTATE of the driver * Driver exceptions provide the SQLSTATE of the driver
* and the driver specific error code at the time the error occurred. * and the driver specific error code at the time the error occurred.
* *
* @author Steve Müller <st.mueller@dzh-online.de>
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.5
*/ */
interface DriverException extends \Throwable interface DriverException extends Throwable
{ {
/** /**
* Returns the driver specific error code if available. * Returns the driver specific error code if available.
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\DrizzlePDOMySql; namespace Doctrine\DBAL\Driver\DrizzlePDOMySql;
use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
/** class Connection extends PDOConnection
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
*/
class Connection extends \Doctrine\DBAL\Driver\PDOConnection
{ {
/** /**
* {@inheritdoc} * {@inheritdoc}
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\DrizzlePDOMySql; namespace Doctrine\DBAL\Driver\DrizzlePDOMySql;
...@@ -24,8 +7,6 @@ use Doctrine\DBAL\Schema\DrizzleSchemaManager; ...@@ -24,8 +7,6 @@ use Doctrine\DBAL\Schema\DrizzleSchemaManager;
/** /**
* Drizzle driver using PDO MySql. * Drizzle driver using PDO MySql.
*
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
*/ */
class Driver extends \Doctrine\DBAL\Driver\PDOMySql\Driver class Driver extends \Doctrine\DBAL\Driver\PDOMySql\Driver
{ {
...@@ -34,14 +15,12 @@ class Driver extends \Doctrine\DBAL\Driver\PDOMySql\Driver ...@@ -34,14 +15,12 @@ class Driver extends \Doctrine\DBAL\Driver\PDOMySql\Driver
*/ */
public function connect(array $params, $username = null, $password = null, array $driverOptions = []) public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{ {
$conn = new Connection( return new Connection(
$this->constructPdoDsn($params), $this->constructPdoDsn($params),
$username, $username,
$password, $password,
$driverOptions $driverOptions
); );
return $conn;
} }
/** /**
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver; namespace Doctrine\DBAL\Driver;
/** /**
* Contract for a driver that is capable of converting DBAL driver exceptions into standardized DBAL driver exceptions. * Contract for a driver that is capable of converting DBAL driver exceptions into standardized DBAL driver exceptions.
* *
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Steve Müller <st.mueller@dzh-online.de>
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.5
*/ */
interface ExceptionConverterDriver interface ExceptionConverterDriver
{ {
...@@ -36,7 +16,7 @@ interface ExceptionConverterDriver ...@@ -36,7 +16,7 @@ interface ExceptionConverterDriver
* it into a unified {@link Doctrine\DBAL\Exception\DriverException} subclass. * it into a unified {@link Doctrine\DBAL\Exception\DriverException} subclass.
* *
* @param string $message The DBAL exception message to use. * @param string $message The DBAL exception message to use.
* @param \Doctrine\DBAL\Driver\DriverException $exception The DBAL driver exception to convert. * @param DriverException $exception The DBAL driver exception to convert.
* *
* @return \Doctrine\DBAL\Exception\DriverException An instance of one of the DriverException subclasses. * @return \Doctrine\DBAL\Exception\DriverException An instance of one of the DriverException subclasses.
*/ */
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\IBMDB2; namespace Doctrine\DBAL\Driver\IBMDB2;
...@@ -43,29 +26,27 @@ use function func_get_args; ...@@ -43,29 +26,27 @@ use function func_get_args;
class DB2Connection implements Connection, ServerInfoAwareConnection class DB2Connection implements Connection, ServerInfoAwareConnection
{ {
/** /** @var resource */
* @var resource private $conn = null;
*/
private $_conn = null;
/** /**
* @param array $params * @param mixed[] $params
* @param string $username * @param string $username
* @param string $password * @param string $password
* @param array $driverOptions * @param mixed[] $driverOptions
* *
* @throws \Doctrine\DBAL\Driver\IBMDB2\DB2Exception * @throws DB2Exception
*/ */
public function __construct(array $params, $username, $password, $driverOptions = []) public function __construct(array $params, $username, $password, $driverOptions = [])
{ {
$isPersistent = (isset($params['persistent']) && $params['persistent'] == true); $isPersistent = (isset($params['persistent']) && $params['persistent'] === true);
if ($isPersistent) { if ($isPersistent) {
$this->_conn = db2_pconnect($params['dbname'], $username, $password, $driverOptions); $this->conn = db2_pconnect($params['dbname'], $username, $password, $driverOptions);
} else { } else {
$this->_conn = db2_connect($params['dbname'], $username, $password, $driverOptions); $this->conn = db2_connect($params['dbname'], $username, $password, $driverOptions);
} }
if ( ! $this->_conn) { if (! $this->conn) {
throw new DB2Exception(db2_conn_errormsg()); throw new DB2Exception(db2_conn_errormsg());
} }
} }
...@@ -76,7 +57,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection ...@@ -76,7 +57,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
public function getServerVersion() public function getServerVersion()
{ {
/** @var stdClass $serverInfo */ /** @var stdClass $serverInfo */
$serverInfo = db2_server_info($this->_conn); $serverInfo = db2_server_info($this->conn);
return $serverInfo->DBMS_VER; return $serverInfo->DBMS_VER;
} }
...@@ -94,8 +75,8 @@ class DB2Connection implements Connection, ServerInfoAwareConnection ...@@ -94,8 +75,8 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
*/ */
public function prepare($sql) public function prepare($sql)
{ {
$stmt = @db2_prepare($this->_conn, $sql); $stmt = @db2_prepare($this->conn, $sql);
if ( ! $stmt) { if (! $stmt) {
throw new DB2Exception(db2_stmt_errormsg()); throw new DB2Exception(db2_stmt_errormsg());
} }
...@@ -126,7 +107,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection ...@@ -126,7 +107,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
return $input; return $input;
} }
return "'".$input."'"; return "'" . $input . "'";
} }
/** /**
...@@ -134,9 +115,9 @@ class DB2Connection implements Connection, ServerInfoAwareConnection ...@@ -134,9 +115,9 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
*/ */
public function exec($statement) public function exec($statement)
{ {
$stmt = @db2_exec($this->_conn, $statement); $stmt = @db2_exec($this->conn, $statement);
if (false === $stmt) { if ($stmt === false) {
throw new DB2Exception(db2_stmt_errormsg()); throw new DB2Exception(db2_stmt_errormsg());
} }
...@@ -148,7 +129,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection ...@@ -148,7 +129,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
*/ */
public function lastInsertId($name = null) public function lastInsertId($name = null)
{ {
return db2_last_insert_id($this->_conn); return db2_last_insert_id($this->conn);
} }
/** /**
...@@ -156,7 +137,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection ...@@ -156,7 +137,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
*/ */
public function beginTransaction() public function beginTransaction()
{ {
db2_autocommit($this->_conn, DB2_AUTOCOMMIT_OFF); db2_autocommit($this->conn, DB2_AUTOCOMMIT_OFF);
} }
/** /**
...@@ -164,10 +145,10 @@ class DB2Connection implements Connection, ServerInfoAwareConnection ...@@ -164,10 +145,10 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
*/ */
public function commit() public function commit()
{ {
if (!db2_commit($this->_conn)) { if (! db2_commit($this->conn)) {
throw new DB2Exception(db2_conn_errormsg($this->_conn)); throw new DB2Exception(db2_conn_errormsg($this->conn));
} }
db2_autocommit($this->_conn, DB2_AUTOCOMMIT_ON); db2_autocommit($this->conn, DB2_AUTOCOMMIT_ON);
} }
/** /**
...@@ -175,10 +156,10 @@ class DB2Connection implements Connection, ServerInfoAwareConnection ...@@ -175,10 +156,10 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
*/ */
public function rollBack() public function rollBack()
{ {
if (!db2_rollback($this->_conn)) { if (! db2_rollback($this->conn)) {
throw new DB2Exception(db2_conn_errormsg($this->_conn)); throw new DB2Exception(db2_conn_errormsg($this->conn));
} }
db2_autocommit($this->_conn, DB2_AUTOCOMMIT_ON); db2_autocommit($this->conn, DB2_AUTOCOMMIT_ON);
} }
/** /**
...@@ -186,7 +167,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection ...@@ -186,7 +167,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
*/ */
public function errorCode() public function errorCode()
{ {
return db2_conn_error($this->_conn); return db2_conn_error($this->conn);
} }
/** /**
...@@ -195,7 +176,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection ...@@ -195,7 +176,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
public function errorInfo() public function errorInfo()
{ {
return [ return [
0 => db2_conn_errormsg($this->_conn), 0 => db2_conn_errormsg($this->conn),
1 => $this->errorCode(), 1 => $this->errorCode(),
]; ];
} }
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\IBMDB2; namespace Doctrine\DBAL\Driver\IBMDB2;
...@@ -23,9 +6,6 @@ use Doctrine\DBAL\Driver\AbstractDB2Driver; ...@@ -23,9 +6,6 @@ use Doctrine\DBAL\Driver\AbstractDB2Driver;
/** /**
* IBM DB2 Driver. * IBM DB2 Driver.
*
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/ */
class DB2Driver extends AbstractDB2Driver class DB2Driver extends AbstractDB2Driver
{ {
...@@ -34,18 +14,18 @@ class DB2Driver extends AbstractDB2Driver ...@@ -34,18 +14,18 @@ class DB2Driver extends AbstractDB2Driver
*/ */
public function connect(array $params, $username = null, $password = null, array $driverOptions = []) public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{ {
if ( ! isset($params['protocol'])) { if (! isset($params['protocol'])) {
$params['protocol'] = 'TCPIP'; $params['protocol'] = 'TCPIP';
} }
if ($params['host'] !== 'localhost' && $params['host'] != '127.0.0.1') { if ($params['host'] !== 'localhost' && $params['host'] !== '127.0.0.1') {
// if the host isn't localhost, use extended connection params // if the host isn't localhost, use extended connection params
$params['dbname'] = 'DRIVER={IBM DB2 ODBC DRIVER}' . $params['dbname'] = 'DRIVER={IBM DB2 ODBC DRIVER}' .
';DATABASE=' . $params['dbname'] . ';DATABASE=' . $params['dbname'] .
';HOSTNAME=' . $params['host'] . ';HOSTNAME=' . $params['host'] .
';PROTOCOL=' . $params['protocol'] . ';PROTOCOL=' . $params['protocol'] .
';UID=' . $username . ';UID=' . $username .
';PWD=' . $password .';'; ';PWD=' . $password . ';';
if (isset($params['port'])) { if (isset($params['port'])) {
$params['dbname'] .= 'PORT=' . $params['port']; $params['dbname'] .= 'PORT=' . $params['port'];
} }
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\IBMDB2; namespace Doctrine\DBAL\Driver\IBMDB2;
class DB2Exception extends \Exception use Exception;
class DB2Exception extends Exception
{ {
} }
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\Mysqli; namespace Doctrine\DBAL\Driver\Mysqli;
use Doctrine\DBAL\Driver\AbstractMySQLDriver;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\AbstractMySQLDriver;
/**
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
*/
class Driver extends AbstractMySQLDriver class Driver extends AbstractMySQLDriver
{ {
/** /**
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\Mysqli; namespace Doctrine\DBAL\Driver\Mysqli;
...@@ -23,9 +6,6 @@ use Doctrine\DBAL\Driver\AbstractDriverException; ...@@ -23,9 +6,6 @@ use Doctrine\DBAL\Driver\AbstractDriverException;
/** /**
* Exception thrown in case the mysqli driver errors. * Exception thrown in case the mysqli driver errors.
*
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
* @author Steve Müller <st.mueller@dzh-online.de>
*/ */
class MysqliException extends AbstractDriverException class MysqliException extends AbstractDriverException
{ {
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\OCI8; namespace Doctrine\DBAL\Driver\OCI8;
...@@ -25,9 +8,6 @@ use const OCI_DEFAULT; ...@@ -25,9 +8,6 @@ use const OCI_DEFAULT;
/** /**
* A Doctrine DBAL driver for the Oracle OCI8 PHP extensions. * A Doctrine DBAL driver for the Oracle OCI8 PHP extensions.
*
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
*/ */
class Driver extends AbstractOracleDriver class Driver extends AbstractOracleDriver
{ {
...@@ -53,7 +33,7 @@ class Driver extends AbstractOracleDriver ...@@ -53,7 +33,7 @@ class Driver extends AbstractOracleDriver
/** /**
* Constructs the Oracle DSN. * Constructs the Oracle DSN.
* *
* @param array $params * @param mixed[] $params
* *
* @return string The DSN. * @return string The DSN.
*/ */
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\OCI8; namespace Doctrine\DBAL\Driver\OCI8;
use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use UnexpectedValueException;
use const OCI_COMMIT_ON_SUCCESS; use const OCI_COMMIT_ON_SUCCESS;
use const OCI_DEFAULT; use const OCI_DEFAULT;
use const OCI_NO_AUTO_COMMIT; use const OCI_NO_AUTO_COMMIT;
...@@ -43,19 +27,13 @@ use function str_replace; ...@@ -43,19 +27,13 @@ use function str_replace;
/** /**
* OCI8 implementation of the Connection interface. * OCI8 implementation of the Connection interface.
*
* @since 2.0
*/ */
class OCI8Connection implements Connection, ServerInfoAwareConnection class OCI8Connection implements Connection, ServerInfoAwareConnection
{ {
/** /** @var resource */
* @var resource
*/
protected $dbh; protected $dbh;
/** /** @var int */
* @var int
*/
protected $executeMode = OCI_COMMIT_ON_SUCCESS; protected $executeMode = OCI_COMMIT_ON_SUCCESS;
/** /**
...@@ -72,7 +50,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection ...@@ -72,7 +50,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
*/ */
public function __construct($username, $password, $db, $charset = null, $sessionMode = OCI_DEFAULT, $persistent = false) public function __construct($username, $password, $db, $charset = null, $sessionMode = OCI_DEFAULT, $persistent = false)
{ {
if (!defined('OCI_NO_AUTO_COMMIT')) { if (! defined('OCI_NO_AUTO_COMMIT')) {
define('OCI_NO_AUTO_COMMIT', 0); define('OCI_NO_AUTO_COMMIT', 0);
} }
...@@ -80,7 +58,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection ...@@ -80,7 +58,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
? @oci_pconnect($username, $password, $db, $charset, $sessionMode) ? @oci_pconnect($username, $password, $db, $charset, $sessionMode)
: @oci_connect($username, $password, $db, $charset, $sessionMode); : @oci_connect($username, $password, $db, $charset, $sessionMode);
if ( ! $this->dbh) { if (! $this->dbh) {
throw OCI8Exception::fromErrorInfo(oci_error()); throw OCI8Exception::fromErrorInfo(oci_error());
} }
} }
...@@ -88,13 +66,13 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection ...@@ -88,13 +66,13 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
* @throws \UnexpectedValueException if the version string returned by the database server * @throws UnexpectedValueException If the version string returned by the database server
* does not contain a parsable version number. * does not contain a parsable version number.
*/ */
public function getServerVersion() public function getServerVersion()
{ {
if ( ! preg_match('/\s+(\d+\.\d+\.\d+\.\d+\.\d+)\s+/', oci_server_version($this->dbh), $version)) { if (! preg_match('/\s+(\d+\.\d+\.\d+\.\d+\.\d+)\s+/', oci_server_version($this->dbh), $version)) {
throw new \UnexpectedValueException( throw new UnexpectedValueException(
sprintf( sprintf(
'Unexpected database version string "%s". Cannot parse an appropriate version number from it. ' . 'Unexpected database version string "%s". Cannot parse an appropriate version number from it. ' .
'Please report this database version string to the Doctrine team.', 'Please report this database version string to the Doctrine team.',
...@@ -174,7 +152,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection ...@@ -174,7 +152,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
$result = $stmt->fetchColumn(); $result = $stmt->fetchColumn();
if ($result === false) { if ($result === false) {
throw new OCI8Exception("lastInsertId failed: Query was executed but no result was returned."); throw new OCI8Exception('lastInsertId failed: Query was executed but no result was returned.');
} }
return (int) $result; return (int) $result;
...@@ -205,7 +183,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection ...@@ -205,7 +183,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
*/ */
public function commit() public function commit()
{ {
if (!oci_commit($this->dbh)) { if (! oci_commit($this->dbh)) {
throw OCI8Exception::fromErrorInfo($this->errorInfo()); throw OCI8Exception::fromErrorInfo($this->errorInfo());
} }
$this->executeMode = OCI_COMMIT_ON_SUCCESS; $this->executeMode = OCI_COMMIT_ON_SUCCESS;
...@@ -218,7 +196,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection ...@@ -218,7 +196,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
*/ */
public function rollBack() public function rollBack()
{ {
if (!oci_rollback($this->dbh)) { if (! oci_rollback($this->dbh)) {
throw OCI8Exception::fromErrorInfo($this->errorInfo()); throw OCI8Exception::fromErrorInfo($this->errorInfo());
} }
$this->executeMode = OCI_COMMIT_ON_SUCCESS; $this->executeMode = OCI_COMMIT_ON_SUCCESS;
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\OCI8; namespace Doctrine\DBAL\Driver\OCI8;
...@@ -24,7 +7,7 @@ use Doctrine\DBAL\Driver\AbstractDriverException; ...@@ -24,7 +7,7 @@ use Doctrine\DBAL\Driver\AbstractDriverException;
class OCI8Exception extends AbstractDriverException class OCI8Exception extends AbstractDriverException
{ {
/** /**
* @param array $error * @param mixed[] $error
* *
* @return \Doctrine\DBAL\Driver\OCI8\OCI8Exception * @return \Doctrine\DBAL\Driver\OCI8\OCI8Exception
*/ */
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver; namespace Doctrine\DBAL\Driver;
...@@ -27,8 +10,6 @@ use function func_get_args; ...@@ -27,8 +10,6 @@ use function func_get_args;
/** /**
* PDO implementation of the Connection interface. * PDO implementation of the Connection interface.
* Used by all PDO-based drivers. * Used by all PDO-based drivers.
*
* @since 2.0
*/ */
class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection
{ {
...@@ -36,15 +17,15 @@ class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection ...@@ -36,15 +17,15 @@ class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection
* @param string $dsn * @param string $dsn
* @param string|null $user * @param string|null $user
* @param string|null $password * @param string|null $password
* @param array|null $options * @param mixed[]|null $options
* *
* @throws PDOException in case of an error. * @throws PDOException In case of an error.
*/ */
public function __construct($dsn, $user = null, $password = null, array $options = null) public function __construct($dsn, $user = null, $password = null, ?array $options = null)
{ {
try { try {
parent::__construct($dsn, $user, $password, $options); parent::__construct($dsn, $user, $password, $options);
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, ['Doctrine\DBAL\Driver\PDOStatement', []]); $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, [PDOStatement::class, []]);
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (\PDOException $exception) { } catch (\PDOException $exception) {
throw new PDOException($exception); throw new PDOException($exception);
...@@ -92,15 +73,15 @@ class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection ...@@ -92,15 +73,15 @@ class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection
$argsCount = count($args); $argsCount = count($args);
try { try {
if ($argsCount == 4) { if ($argsCount === 4) {
return parent::query($args[0], $args[1], $args[2], $args[3]); return parent::query($args[0], $args[1], $args[2], $args[3]);
} }
if ($argsCount == 3) { if ($argsCount === 3) {
return parent::query($args[0], $args[1], $args[2]); return parent::query($args[0], $args[1], $args[2]);
} }
if ($argsCount == 2) { if ($argsCount === 2) {
return parent::query($args[0], $args[1]); return parent::query($args[0], $args[1]);
} }
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver; namespace Doctrine\DBAL\Driver;
/** /**
* Tiny wrapper for PDOException instances to implement the {@link DriverException} interface. * Tiny wrapper for PDOException instances to implement the {@link DriverException} interface.
* *
* @author Steve Müller <st.mueller@dzh-online.de>
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.5
*/ */
class PDOException extends \PDOException implements DriverException class PDOException extends \PDOException implements DriverException
{ {
...@@ -43,8 +24,6 @@ class PDOException extends \PDOException implements DriverException ...@@ -43,8 +24,6 @@ class PDOException extends \PDOException implements DriverException
private $sqlState; private $sqlState;
/** /**
* Constructor.
*
* @param \PDOException $exception The PDO exception to wrap. * @param \PDOException $exception The PDO exception to wrap.
*/ */
public function __construct(\PDOException $exception) public function __construct(\PDOException $exception)
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\PDOIbm; namespace Doctrine\DBAL\Driver\PDOIbm;
...@@ -26,11 +9,6 @@ use Doctrine\DBAL\Driver\PDOConnection; ...@@ -26,11 +9,6 @@ use Doctrine\DBAL\Driver\PDOConnection;
* Driver for the PDO IBM extension. * Driver for the PDO IBM extension.
* *
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 1.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/ */
class Driver extends AbstractDB2Driver class Driver extends AbstractDB2Driver
{ {
...@@ -39,20 +17,18 @@ class Driver extends AbstractDB2Driver ...@@ -39,20 +17,18 @@ class Driver extends AbstractDB2Driver
*/ */
public function connect(array $params, $username = null, $password = null, array $driverOptions = []) public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{ {
$conn = new PDOConnection( return new PDOConnection(
$this->_constructPdoDsn($params), $this->_constructPdoDsn($params),
$username, $username,
$password, $password,
$driverOptions $driverOptions
); );
return $conn;
} }
/** /**
* Constructs the IBM PDO DSN. * Constructs the IBM PDO DSN.
* *
* @param array $params * @param mixed[] $params
* *
* @return string The DSN. * @return string The DSN.
*/ */
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\PDOMySql; namespace Doctrine\DBAL\Driver\PDOMySql;
...@@ -26,8 +9,6 @@ use PDOException; ...@@ -26,8 +9,6 @@ use PDOException;
/** /**
* PDO MySql driver. * PDO MySql driver.
*
* @since 2.0
*/ */
class Driver extends AbstractMySQLDriver class Driver extends AbstractMySQLDriver
{ {
...@@ -53,14 +34,14 @@ class Driver extends AbstractMySQLDriver ...@@ -53,14 +34,14 @@ class Driver extends AbstractMySQLDriver
/** /**
* Constructs the MySql PDO DSN. * Constructs the MySql PDO DSN.
* *
* @param array $params * @param mixed[] $params
* *
* @return string The DSN. * @return string The DSN.
*/ */
protected function constructPdoDsn(array $params) protected function constructPdoDsn(array $params)
{ {
$dsn = 'mysql:'; $dsn = 'mysql:';
if (isset($params['host']) && $params['host'] != '') { if (isset($params['host']) && $params['host'] !== '') {
$dsn .= 'host=' . $params['host'] . ';'; $dsn .= 'host=' . $params['host'] . ';';
} }
if (isset($params['port'])) { if (isset($params['port'])) {
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\PDOOracle; namespace Doctrine\DBAL\Driver\PDOOracle;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\AbstractOracleDriver; use Doctrine\DBAL\Driver\AbstractOracleDriver;
use Doctrine\DBAL\Driver\PDOConnection; use Doctrine\DBAL\Driver\PDOConnection;
use PDOException;
/** /**
* PDO Oracle driver. * PDO Oracle driver.
...@@ -45,7 +29,7 @@ class Driver extends AbstractOracleDriver ...@@ -45,7 +29,7 @@ class Driver extends AbstractOracleDriver
$password, $password,
$driverOptions $driverOptions
); );
} catch (\PDOException $e) { } catch (PDOException $e) {
throw DBALException::driverException($this, $e); throw DBALException::driverException($this, $e);
} }
} }
...@@ -53,7 +37,7 @@ class Driver extends AbstractOracleDriver ...@@ -53,7 +37,7 @@ class Driver extends AbstractOracleDriver
/** /**
* Constructs the Oracle PDO DSN. * Constructs the Oracle PDO DSN.
* *
* @param array $params * @param mixed[] $params
* *
* @return string The DSN. * @return string The DSN.
*/ */
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\PDOPgSql; namespace Doctrine\DBAL\Driver\PDOPgSql;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver; use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
use Doctrine\DBAL\Driver\PDOConnection; use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\DBAL\DBALException;
use PDOException;
use PDO; use PDO;
use PDOException;
use function defined; use function defined;
/** /**
* Driver that connects through pdo_pgsql. * Driver that connects through pdo_pgsql.
*
* @since 2.0
*/ */
class Driver extends AbstractPostgreSQLDriver class Driver extends AbstractPostgreSQLDriver
{ {
...@@ -48,7 +29,7 @@ class Driver extends AbstractPostgreSQLDriver ...@@ -48,7 +29,7 @@ class Driver extends AbstractPostgreSQLDriver
if (defined('PDO::PGSQL_ATTR_DISABLE_PREPARES') if (defined('PDO::PGSQL_ATTR_DISABLE_PREPARES')
&& (! isset($driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES]) && (! isset($driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES])
|| true === $driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES] || $driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES] === true
) )
) { ) {
$pdo->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES, true); $pdo->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES, true);
...@@ -71,7 +52,7 @@ class Driver extends AbstractPostgreSQLDriver ...@@ -71,7 +52,7 @@ class Driver extends AbstractPostgreSQLDriver
/** /**
* Constructs the Postgres PDO DSN. * Constructs the Postgres PDO DSN.
* *
* @param array $params * @param mixed[] $params
* *
* @return string The DSN. * @return string The DSN.
*/ */
...@@ -79,11 +60,11 @@ class Driver extends AbstractPostgreSQLDriver ...@@ -79,11 +60,11 @@ class Driver extends AbstractPostgreSQLDriver
{ {
$dsn = 'pgsql:'; $dsn = 'pgsql:';
if (isset($params['host']) && $params['host'] != '') { if (isset($params['host']) && $params['host'] !== '') {
$dsn .= 'host=' . $params['host'] . ';'; $dsn .= 'host=' . $params['host'] . ';';
} }
if (isset($params['port']) && $params['port'] != '') { if (isset($params['port']) && $params['port'] !== '') {
$dsn .= 'port=' . $params['port'] . ';'; $dsn .= 'port=' . $params['port'] . ';';
} }
...@@ -95,7 +76,7 @@ class Driver extends AbstractPostgreSQLDriver ...@@ -95,7 +76,7 @@ class Driver extends AbstractPostgreSQLDriver
// Used for temporary connections to allow operations like dropping the database currently connected to. // Used for temporary connections to allow operations like dropping the database currently connected to.
// Connecting without an explicit database does not work, therefore "postgres" database is used // Connecting without an explicit database does not work, therefore "postgres" database is used
// as it is mostly present in every server setup. // as it is mostly present in every server setup.
$dsn .= 'dbname=postgres' . ';'; $dsn .= 'dbname=postgres;';
} }
if (isset($params['sslmode'])) { if (isset($params['sslmode'])) {
......
<?php <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\PDOSqlsrv; namespace Doctrine\DBAL\Driver\PDOSqlsrv;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment