Skip to content

Commit

Permalink
Merge pull request #1743 from alcaeus/phpcs
Browse files Browse the repository at this point in the history
Add phpcs to build and apply automatic fixes
  • Loading branch information
malarzm committed Mar 8, 2018
2 parents 35344aa + 35a4f2e commit 04938ee
Show file tree
Hide file tree
Showing 564 changed files with 7,348 additions and 5,521 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ tests/PersistentCollections/*
phpunit.xml
composer.lock
vendor/
.phpcs-cache
phpcs.xml
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,17 @@ jobs:
- composer update --prefer-lowest

- stage: Code Quality
php: 7.2
env: SERVER_VERSION="3.6" KEY_ID="2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5"
php: 7.1
env: STATIC_ANALYSIS SERVER_VERSION="3.6" KEY_ID="2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5"
script:
- vendor/bin/phpstan analyse -l 1 lib

- stage: Code Quality
php: 7.1
env: CODING_STANDARDS SERVER_VERSION="3.6" KEY_ID="2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5"
script:
- vendor/bin/phpcs

before_install:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
- sudo apt-key adv --keyserver ${KEY_SERVER} --recv ${KEY_ID}
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"require-dev": {
"phpunit/phpunit": "^7.0",
"jmikola/geojson": "^1.0",
"phpstan/phpstan": "^0.9.2"
"phpstan/phpstan": "^0.9.2",
"doctrine/coding-standard": "^4.0"
},
"autoload": {
"psr-0": { "Doctrine\\ODM\\MongoDB": "lib/" }
Expand Down
39 changes: 20 additions & 19 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
<?php

declare(strict_types=1);

namespace Doctrine\ODM\MongoDB\Aggregation;

use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Iterator\CachingIterator;
use Doctrine\ODM\MongoDB\Iterator\HydratingIterator;
use Doctrine\ODM\MongoDB\Iterator\Iterator;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
use Doctrine\ODM\MongoDB\Persisters\DocumentPersister;
use Doctrine\ODM\MongoDB\Query\Expr as QueryExpr;
use GeoJson\Geometry\Point;
use MongoDB\Collection;
use MongoDB\Driver\Cursor;
use function array_map;
use function array_merge;
use function array_unshift;
use function is_array;

/**
* Fluent interface for building aggregation pipelines.
Expand All @@ -26,7 +34,7 @@ class Builder
/**
* The ClassMetadata instance.
*
* @var \Doctrine\ODM\MongoDB\Mapping\ClassMetadata
* @var ClassMetadata
*/
private $class;

Expand All @@ -50,7 +58,6 @@ class Builder
/**
* Create a new aggregation builder.
*
* @param DocumentManager $dm
* @param string $documentName
*/
public function __construct(DocumentManager $dm, $documentName)
Expand Down Expand Up @@ -127,8 +134,6 @@ public function bucketAuto()
* the pipeline returns an error.
*
* @see http://docs.mongodb.org/manual/reference/operator/aggregation/collStats/
* @since 1.5
*
* @return Stage\CollStats
*/
public function collStats()
Expand Down Expand Up @@ -200,7 +205,7 @@ public function facet()
* @see http://docs.mongodb.org/manual/reference/operator/aggregation/geoNear/
*
* @param float|array|Point $x
* @param float $y
* @param float $y
* @return Stage\GeoNear
*/
public function geoNear($x, $y = null)
Expand All @@ -221,7 +226,9 @@ public function geoNear($x, $y = null)
public function getPipeline()
{
$pipeline = array_map(
function (Stage $stage) { return $stage->getExpression(); },
function (Stage $stage) {
return $stage->getExpression();
},
$this->stages
);

Expand All @@ -240,12 +247,12 @@ function (Stage $stage) { return $stage->getExpression(); },
/**
* Returns a certain stage from the pipeline
*
* @param integer $index
* @param int $index
* @return Stage
*/
public function getStage($index)
{
if ( ! isset($this->stages[$index])) {
if (! isset($this->stages[$index])) {
throw new \OutOfRangeException("Could not find stage with index {$index}.");
}

Expand Down Expand Up @@ -311,7 +318,7 @@ public function indexStats()
*
* @see http://docs.mongodb.org/manual/reference/operator/aggregation/limit/
*
* @param integer $limit
* @param int $limit
* @return Stage\Limit
*/
public function limit($limit)
Expand Down Expand Up @@ -424,7 +431,7 @@ public function replaceRoot($expression = null)
*
* @see https://docs.mongodb.org/manual/reference/operator/aggregation/sample/
*
* @param integer $size
* @param int $size
* @return Stage\Sample
*/
public function sample($size)
Expand All @@ -438,7 +445,7 @@ public function sample($size)
*
* @see http://docs.mongodb.org/manual/reference/operator/aggregation/skip/
*
* @param integer $skip
* @param int $skip
* @return Stage\Skip
*/
public function skip($skip)
Expand All @@ -456,7 +463,7 @@ public function skip($skip)
* @see http://docs.mongodb.org/manual/reference/operator/aggregation/sort/
*
* @param array|string $fieldName Field name or array of field/order pairs
* @param integer|string $order Field order (if one field is specified)
* @param int|string $order Field order (if one field is specified)
* @return Stage\Sort
*/
public function sort($fieldName, $order = null)
Expand Down Expand Up @@ -497,7 +504,6 @@ public function unwind($fieldName)
}

/**
* @param Stage $stage
* @return Stage
*/
protected function addStage(Stage $stage)
Expand All @@ -524,18 +530,13 @@ private function applyFilters(array $query)
}

/**
* @return \Doctrine\ODM\MongoDB\Persisters\DocumentPersister
* @return DocumentPersister
*/
private function getDocumentPersister()
{
return $this->dm->getUnitOfWork()->getDocumentPersister($this->class->name);
}

/**
* @param Cursor $cursor
*
* @return Iterator
*/
private function prepareIterator(Cursor $cursor): Iterator
{
$class = null;
Expand Down

0 comments on commit 04938ee

Please sign in to comment.