Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed coding standard violations in the codebase #3306

Merged
merged 7 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ after_script:
jobs:
allow_failures:
- php: nightly
- stage: Coding standard
- env: DB=pgsql POSTGRESQL_VERSION=11.0

exclude:
Expand Down Expand Up @@ -431,22 +430,7 @@ jobs:
install: travis_retry composer update --prefer-dist
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
if: NOT type = pull_request
php: 7.1
install: travis_retry composer install --prefer-dist
script:
Expand Down
16 changes: 8 additions & 8 deletions bin/doctrine-dbal.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
* <http://www.doctrine-project.org>.
*/

use Symfony\Component\Console\Helper\HelperSet;
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;
$cwd = getcwd();
$directories = array($cwd, $cwd . DIRECTORY_SEPARATOR . 'config');
$directories = [$cwd, $cwd . DIRECTORY_SEPARATOR . 'config'];
$configFile = null;

foreach ($files as $file) {
Expand All @@ -34,7 +34,7 @@
}
}

if ( ! $loader) {
if (! $loader) {
throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?');
}

Expand All @@ -46,22 +46,22 @@
}
}

if ( ! file_exists($configFile)) {
if (! file_exists($configFile)) {
ConsoleRunner::printCliConfigTemplate();

exit(1);
}

if ( ! is_readable($configFile)) {
if (! is_readable($configFile)) {
echo 'Configuration file [' . $configFile . '] does not have read permission.' . PHP_EOL;

exit(1);
}

$commands = array();
$commands = [];
$helperSet = require $configFile;

if ( ! $helperSet instanceof HelperSet) {
if (! $helperSet instanceof HelperSet) {
foreach ($GLOBALS as $helperSetCandidate) {
if ($helperSetCandidate instanceof HelperSet) {
$helperSet = $helperSetCandidate;
Expand Down
57 changes: 19 additions & 38 deletions lib/Doctrine/DBAL/Cache/ArrayStatement.php
Original file line number Diff line number Diff line change
@@ -1,70 +1,51 @@
<?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;

use ArrayIterator;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\FetchMode;
use InvalidArgumentException;
use IteratorAggregate;
use PDO;
use function array_merge;
use function array_values;
use function count;
use function reset;

class ArrayStatement implements \IteratorAggregate, ResultStatement
class ArrayStatement implements IteratorAggregate, ResultStatement
{
/**
* @var array
*/
/** @var mixed[] */
private $data;

/**
* @var int
*/
/** @var int */
private $columnCount = 0;

/**
* @var int
*/
/** @var int */
private $num = 0;

/**
* @var int
*/
/** @var int */
private $defaultFetchMode = FetchMode::MIXED;

/**
* @param array $data
* @param mixed[] $data
*/
public function __construct(array $data)
{
$this->data = $data;
if (count($data)) {
$this->columnCount = count($data[0]);
if (! count($data)) {
return;
}

$this->columnCount = count($data[0]);
}

/**
* {@inheritdoc}
*/
public function closeCursor()
{
unset ($this->data);
unset($this->data);
}

/**
Expand All @@ -81,7 +62,7 @@ public function columnCount()
public function setFetchMode($fetchMode, $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;
Expand All @@ -96,13 +77,13 @@ public function getIterator()
{
$data = $this->fetchAll();

return new \ArrayIterator($data);
return new ArrayIterator($data);
}

/**
* {@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])) {
return false;
Expand All @@ -127,7 +108,7 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
return reset($row);
}

throw new \InvalidArgumentException('Invalid fetch-style given for fetching result.');
throw new InvalidArgumentException('Invalid fetch-style given for fetching result.');
}

/**
Expand Down
29 changes: 5 additions & 24 deletions lib/Doctrine/DBAL/Cache/CacheException.php
Original file line number Diff line number Diff line change
@@ -1,43 +1,24 @@
<?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;

/**
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @since 2.2
*/
class CacheException extends \Doctrine\DBAL\DBALException
use Doctrine\DBAL\DBALException;

class CacheException extends DBALException
{
/**
* @return \Doctrine\DBAL\Cache\CacheException
*/
public static function noCacheKey()
{
return new self("No cache key was set.");
return new self('No cache key was set.');
}

/**
* @return \Doctrine\DBAL\Cache\CacheException
*/
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.');
}
}
40 changes: 8 additions & 32 deletions lib/Doctrine/DBAL/Cache/QueryCacheProfile.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
<?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;

Expand All @@ -31,19 +14,13 @@
*/
class QueryCacheProfile
{
/**
* @var Cache|null
*/
/** @var Cache|null */
private $resultCacheDriver;

/**
* @var int
*/
/** @var int */
private $lifetime = 0;

/**
* @var string|null
*/
/** @var string|null */
private $cacheKey;

/**
Expand Down Expand Up @@ -90,12 +67,12 @@ public function getCacheKey()
/**
* Generates the real cache key from query, params, types and connection parameters.
*
* @param string $query
* @param array $params
* @param array $types
* @param array $connectionParams
* @param string $query
* @param mixed[] $params
* @param int[]|string[] $types
* @param mixed[] $connectionParams
*
* @return array
* @return string[]
*/
public function generateCacheKeys($query, $params, $types, array $connectionParams = [])
{
Expand All @@ -115,7 +92,6 @@ public function generateCacheKeys($query, $params, $types, array $connectionPara
}

/**
*
* @return \Doctrine\DBAL\Cache\QueryCacheProfile
*/
public function setResultCacheDriver(Cache $cache)
Expand Down
Loading