diff --git a/.travis.yml b/.travis.yml index 36a6dcd3d..e782cb4b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,11 @@ language: php sudo: false php: - - 7.0 - 7.1 - nightly matrix: fast_finish: true - allow_failures: - - nightly before_install: - if [[ $TRAVIS_PHP_VERSION = '7.1' ]]; then PHPUNIT_FLAGS="--coverage-clover clover.xml"; fi diff --git a/lib/Doctrine/Common/Collections/ArrayCollection.php b/lib/Doctrine/Common/Collections/ArrayCollection.php index 67336e0a1..0bebce200 100644 --- a/lib/Doctrine/Common/Collections/ArrayCollection.php +++ b/lib/Doctrine/Common/Collections/ArrayCollection.php @@ -50,7 +50,7 @@ class ArrayCollection implements Collection, Selectable * * @param array $elements */ - public function __construct(array $elements = array()) + public function __construct(array $elements = []) { $this->elements = $elements; } @@ -177,7 +177,8 @@ public function offsetGet($offset) public function offsetSet($offset, $value) { if ( ! isset($offset)) { - return $this->add($value); + $this->add($value); + return; } $this->set($offset, $value); @@ -190,7 +191,7 @@ public function offsetSet($offset, $value) */ public function offsetUnset($offset) { - return $this->remove($offset); + $this->remove($offset); } /** @@ -236,7 +237,7 @@ public function indexOf($element) */ public function get($key) { - return isset($this->elements[$key]) ? $this->elements[$key] : null; + return $this->elements[$key] ?? null; } /** @@ -338,7 +339,7 @@ public function forAll(Closure $p) */ public function partition(Closure $p) { - $matches = $noMatches = array(); + $matches = $noMatches = []; foreach ($this->elements as $key => $element) { if ($p($key, $element)) { @@ -348,7 +349,7 @@ public function partition(Closure $p) } } - return array($this->createFrom($matches), $this->createFrom($noMatches)); + return [$this->createFrom($matches), $this->createFrom($noMatches)]; } /** @@ -366,7 +367,7 @@ public function __toString() */ public function clear() { - $this->elements = array(); + $this->elements = []; } /** diff --git a/lib/Doctrine/Common/Collections/Criteria.php b/lib/Doctrine/Common/Collections/Criteria.php index 3f9d43a82..748a08474 100644 --- a/lib/Doctrine/Common/Collections/Criteria.php +++ b/lib/Doctrine/Common/Collections/Criteria.php @@ -53,7 +53,7 @@ class Criteria /** * @var string[] */ - private $orderings = array(); + private $orderings = []; /** * @var int|null @@ -137,9 +137,10 @@ public function andWhere(Expression $expression) return $this->where($expression); } - $this->expression = new CompositeExpression(CompositeExpression::TYPE_AND, array( - $this->expression, $expression - )); + $this->expression = new CompositeExpression( + CompositeExpression::TYPE_AND, + [$this->expression, $expression] + ); return $this; } @@ -158,9 +159,10 @@ public function orWhere(Expression $expression) return $this->where($expression); } - $this->expression = new CompositeExpression(CompositeExpression::TYPE_OR, array( - $this->expression, $expression - )); + $this->expression = new CompositeExpression( + CompositeExpression::TYPE_OR, + [$this->expression, $expression] + ); return $this; } @@ -200,7 +202,7 @@ public function getOrderings() public function orderBy(array $orderings) { $this->orderings = array_map( - function ($ordering) { + function (string $ordering) : string { return strtoupper($ordering) === Criteria::ASC ? Criteria::ASC : Criteria::DESC; }, $orderings diff --git a/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php b/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php index 1239aa393..2d2610149 100644 --- a/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php +++ b/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php @@ -35,7 +35,7 @@ class ClosureExpressionVisitor extends ExpressionVisitor * directly or indirectly (through an accessor get*, is*, or a magic * method, __get, __call). * - * @param object $object + * @param object|array $object * @param string $field * * @return mixed @@ -46,7 +46,7 @@ public static function getObjectFieldValue($object, $field) return $object[$field]; } - $accessors = array('get', 'is'); + $accessors = ['get', 'is']; foreach ($accessors as $accessor) { $accessor .= $field; @@ -102,12 +102,12 @@ public static function getObjectFieldValue($object, $field) public static function sortByField($name, $orientation = 1, \Closure $next = null) { if ( ! $next) { - $next = function() { + $next = function() : int { return 0; }; } - return function ($a, $b) use ($name, $next, $orientation) { + return function ($a, $b) use ($name, $next, $orientation) : int { $aValue = ClosureExpressionVisitor::getObjectFieldValue($a, $name); $bValue = ClosureExpressionVisitor::getObjectFieldValue($b, $name); @@ -129,42 +129,42 @@ public function walkComparison(Comparison $comparison) switch ($comparison->getOperator()) { case Comparison::EQ: - return function ($object) use ($field, $value) { + return function ($object) use ($field, $value) : bool { return ClosureExpressionVisitor::getObjectFieldValue($object, $field) === $value; }; case Comparison::NEQ: - return function ($object) use ($field, $value) { + return function ($object) use ($field, $value) : bool { return ClosureExpressionVisitor::getObjectFieldValue($object, $field) !== $value; }; case Comparison::LT: - return function ($object) use ($field, $value) { + return function ($object) use ($field, $value) : bool { return ClosureExpressionVisitor::getObjectFieldValue($object, $field) < $value; }; case Comparison::LTE: - return function ($object) use ($field, $value) { + return function ($object) use ($field, $value) : bool { return ClosureExpressionVisitor::getObjectFieldValue($object, $field) <= $value; }; case Comparison::GT: - return function ($object) use ($field, $value) { + return function ($object) use ($field, $value) : bool { return ClosureExpressionVisitor::getObjectFieldValue($object, $field) > $value; }; case Comparison::GTE: - return function ($object) use ($field, $value) { + return function ($object) use ($field, $value) : bool { return ClosureExpressionVisitor::getObjectFieldValue($object, $field) >= $value; }; case Comparison::IN: - return function ($object) use ($field, $value) { + return function ($object) use ($field, $value) : bool { return in_array(ClosureExpressionVisitor::getObjectFieldValue($object, $field), $value); }; case Comparison::NIN: - return function ($object) use ($field, $value) { + return function ($object) use ($field, $value) : bool { return ! in_array(ClosureExpressionVisitor::getObjectFieldValue($object, $field), $value); }; @@ -174,7 +174,7 @@ public function walkComparison(Comparison $comparison) }; case Comparison::MEMBER_OF: - return function ($object) use ($field, $value) { + return function ($object) use ($field, $value) : bool { $fieldValues = ClosureExpressionVisitor::getObjectFieldValue($object, $field); if (!is_array($fieldValues)) { $fieldValues = iterator_to_array($fieldValues); @@ -183,12 +183,12 @@ public function walkComparison(Comparison $comparison) }; case Comparison::STARTS_WITH: - return function ($object) use ($field, $value) { + return function ($object) use ($field, $value) : bool { return 0 === strpos(ClosureExpressionVisitor::getObjectFieldValue($object, $field), $value); }; case Comparison::ENDS_WITH: - return function ($object) use ($field, $value) { + return function ($object) use ($field, $value) : bool { return $value === substr(ClosureExpressionVisitor::getObjectFieldValue($object, $field), -strlen($value)); }; @@ -211,7 +211,7 @@ public function walkValue(Value $value) */ public function walkCompositeExpression(CompositeExpression $expr) { - $expressionList = array(); + $expressionList = []; foreach ($expr->getExpressionList() as $child) { $expressionList[] = $this->dispatch($child); @@ -234,14 +234,15 @@ public function walkCompositeExpression(CompositeExpression $expr) * * @return callable */ - private function andExpressions($expressions) + private function andExpressions(array $expressions) : callable { - return function ($object) use ($expressions) { + return function ($object) use ($expressions) : bool { foreach ($expressions as $expression) { if ( ! $expression($object)) { return false; } } + return true; }; } @@ -251,14 +252,15 @@ private function andExpressions($expressions) * * @return callable */ - private function orExpressions($expressions) + private function orExpressions(array $expressions) : callable { - return function ($object) use ($expressions) { + return function ($object) use ($expressions) : bool { foreach ($expressions as $expression) { if ($expression($object)) { return true; } } + return false; }; } diff --git a/lib/Doctrine/Common/Collections/Expr/Comparison.php b/lib/Doctrine/Common/Collections/Expr/Comparison.php index ec9a9f48a..72fa5eb75 100644 --- a/lib/Doctrine/Common/Collections/Expr/Comparison.php +++ b/lib/Doctrine/Common/Collections/Expr/Comparison.php @@ -27,19 +27,20 @@ */ class Comparison implements Expression { - const EQ = '='; - const NEQ = '<>'; - const LT = '<'; - const LTE = '<='; - const GT = '>'; - const GTE = '>='; - const IS = '='; // no difference with EQ - const IN = 'IN'; - const NIN = 'NIN'; - const CONTAINS = 'CONTAINS'; - const MEMBER_OF = 'MEMBER_OF'; + const EQ = '='; + const NEQ = '<>'; + const LT = '<'; + const LTE = '<='; + const GT = '>'; + const GTE = '>='; + const IS = '='; // no difference with EQ + const IN = 'IN'; + const NIN = 'NIN'; + const CONTAINS = 'CONTAINS'; + const MEMBER_OF = 'MEMBER_OF'; const STARTS_WITH = 'STARTS_WITH'; - const ENDS_WITH = 'ENDS_WITH'; + const ENDS_WITH = 'ENDS_WITH'; + /** * @var string */ diff --git a/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php b/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php index 3613c0274..2879754ec 100644 --- a/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php +++ b/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php @@ -38,7 +38,7 @@ class CompositeExpression implements Expression /** * @var Expression[] */ - private $expressions = array(); + private $expressions = []; /** * @param string $type diff --git a/tests/Doctrine/Tests/Common/Collections/AbstractLazyArrayCollectionTest.php b/tests/Doctrine/Tests/Common/Collections/AbstractLazyArrayCollectionTest.php index 397771709..cadd73c1e 100644 --- a/tests/Doctrine/Tests/Common/Collections/AbstractLazyArrayCollectionTest.php +++ b/tests/Doctrine/Tests/Common/Collections/AbstractLazyArrayCollectionTest.php @@ -20,6 +20,7 @@ namespace Doctrine\Tests\Common\Collections; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\Tests\LazyArrayCollection; /** @@ -29,13 +30,14 @@ */ class AbstractLazyCollectionTest extends BaseArrayCollectionTest { - protected function buildCollection(array $elements = []) + protected function buildCollection(array $elements = []) : Collection { return new LazyArrayCollection(new ArrayCollection($elements)); } - public function testLazyCollection() + public function testLazyCollection() : void { + /** @var LazyArrayCollection $collection */ $collection = $this->buildCollection(['a', 'b', 'c']); $this->assertFalse($collection->isInitialized()); diff --git a/tests/Doctrine/Tests/Common/Collections/AbstractLazyCollectionTest.php b/tests/Doctrine/Tests/Common/Collections/AbstractLazyCollectionTest.php index 68d425437..645b049c6 100644 --- a/tests/Doctrine/Tests/Common/Collections/AbstractLazyCollectionTest.php +++ b/tests/Doctrine/Tests/Common/Collections/AbstractLazyCollectionTest.php @@ -12,7 +12,7 @@ */ class LazyCollectionTest extends BaseCollectionTest { - protected function setUp() + protected function setUp() : void { $this->collection = new LazyArrayCollection(new ArrayCollection()); } diff --git a/tests/Doctrine/Tests/Common/Collections/ArrayCollectionTest.php b/tests/Doctrine/Tests/Common/Collections/ArrayCollectionTest.php index 75d479eee..3f20c5eb9 100644 --- a/tests/Doctrine/Tests/Common/Collections/ArrayCollectionTest.php +++ b/tests/Doctrine/Tests/Common/Collections/ArrayCollectionTest.php @@ -20,6 +20,7 @@ namespace Doctrine\Tests\Common\Collections; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; /** * Tests for {@see \Doctrine\Common\Collections\ArrayCollection}. @@ -28,7 +29,7 @@ */ class ArrayCollectionTest extends BaseArrayCollectionTest { - protected function buildCollection(array $elements = []) + protected function buildCollection(array $elements = []) : Collection { return new ArrayCollection($elements); } diff --git a/tests/Doctrine/Tests/Common/Collections/BaseArrayCollectionTest.php b/tests/Doctrine/Tests/Common/Collections/BaseArrayCollectionTest.php index fb98155c6..9dbf33a1b 100644 --- a/tests/Doctrine/Tests/Common/Collections/BaseArrayCollectionTest.php +++ b/tests/Doctrine/Tests/Common/Collections/BaseArrayCollectionTest.php @@ -19,14 +19,15 @@ namespace Doctrine\Tests\Common\Collections; +use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Selectable; abstract class BaseArrayCollectionTest extends \PHPUnit_Framework_TestCase { - abstract protected function buildCollection(array $elements = []); + abstract protected function buildCollection(array $elements = []) : Collection; - protected function isSelectable($obj) + protected function isSelectable($obj) : bool { return $obj instanceof Selectable; } @@ -34,7 +35,7 @@ protected function isSelectable($obj) /** * @dataProvider provideDifferentElements */ - public function testToArray($elements) + public function testToArray($elements) : void { $collection = $this->buildCollection($elements); @@ -44,7 +45,7 @@ public function testToArray($elements) /** * @dataProvider provideDifferentElements */ - public function testFirst($elements) + public function testFirst($elements) : void { $collection = $this->buildCollection($elements); $this->assertSame(reset($elements), $collection->first()); @@ -53,7 +54,7 @@ public function testFirst($elements) /** * @dataProvider provideDifferentElements */ - public function testLast($elements) + public function testLast($elements) : void { $collection = $this->buildCollection($elements); $this->assertSame(end($elements), $collection->last()); @@ -62,7 +63,7 @@ public function testLast($elements) /** * @dataProvider provideDifferentElements */ - public function testKey($elements) + public function testKey($elements) : void { $collection = $this->buildCollection($elements); @@ -77,7 +78,7 @@ public function testKey($elements) /** * @dataProvider provideDifferentElements */ - public function testNext($elements) + public function testNext($elements) : void { $collection = $this->buildCollection($elements); @@ -98,7 +99,7 @@ public function testNext($elements) /** * @dataProvider provideDifferentElements */ - public function testCurrent($elements) + public function testCurrent($elements) : void { $collection = $this->buildCollection($elements); @@ -113,7 +114,7 @@ public function testCurrent($elements) /** * @dataProvider provideDifferentElements */ - public function testGetKeys($elements) + public function testGetKeys($elements) : void { $collection = $this->buildCollection($elements); @@ -123,7 +124,7 @@ public function testGetKeys($elements) /** * @dataProvider provideDifferentElements */ - public function testGetValues($elements) + public function testGetValues($elements) : void { $collection = $this->buildCollection($elements); @@ -133,7 +134,7 @@ public function testGetValues($elements) /** * @dataProvider provideDifferentElements */ - public function testCount($elements) + public function testCount($elements) : void { $collection = $this->buildCollection($elements); @@ -143,7 +144,7 @@ public function testCount($elements) /** * @dataProvider provideDifferentElements */ - public function testIterator($elements) + public function testIterator($elements) : void { $collection = $this->buildCollection($elements); @@ -156,10 +157,7 @@ public function testIterator($elements) $this->assertEquals(count($elements), $iterations, 'Number of iterations not match'); } - /** - * @return array - */ - public function provideDifferentElements() + public function provideDifferentElements() : array { return [ 'indexed' => [[1, 2, 3, 4, 5]], @@ -168,7 +166,7 @@ public function provideDifferentElements() ]; } - public function testRemove() + public function testRemove() : void { $elements = [1, 'A' => 'a', 2, 'B' => 'b', 3]; $collection = $this->buildCollection($elements); @@ -188,7 +186,7 @@ public function testRemove() $this->assertEquals($elements, $collection->toArray()); } - public function testRemoveElement() + public function testRemoveElement() : void { $elements = [1, 'A' => 'a', 2, 'B' => 'b', 3, 'A2' => 'a', 'B2' => 'b']; $collection = $this->buildCollection($elements); @@ -207,7 +205,7 @@ public function testRemoveElement() $this->assertEquals($elements, $collection->toArray()); } - public function testContainsKey() + public function testContainsKey() : void { $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'B2' => 'b']; $collection = $this->buildCollection($elements); @@ -218,7 +216,7 @@ public function testContainsKey() $this->assertFalse($collection->containsKey('non-existent'), "Doesn't contain key"); } - public function testEmpty() + public function testEmpty() : void { $collection = $this->buildCollection(); $this->assertTrue($collection->isEmpty(), 'Empty collection'); @@ -227,7 +225,7 @@ public function testEmpty() $this->assertFalse($collection->isEmpty(), 'Not empty collection'); } - public function testContains() + public function testContains() : void { $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'zero' => 0]; $collection = $this->buildCollection($elements); @@ -238,7 +236,7 @@ public function testContains() $this->assertFalse($collection->contains('non-existent'), "Doesn't contain an element"); } - public function testExists() + public function testExists() : void { $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'zero' => 0]; $collection = $this->buildCollection($elements); @@ -252,7 +250,7 @@ public function testExists() }), 'Element not exists'); } - public function testIndexOf() + public function testIndexOf() : void { $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'zero' => 0]; $collection = $this->buildCollection($elements); @@ -262,7 +260,7 @@ public function testIndexOf() $this->assertSame(array_search('non-existent', $elements, true), $collection->indexOf('non-existent'), 'Index of non existent'); } - public function testGet() + public function testGet() : void { $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'zero' => 0]; $collection = $this->buildCollection($elements); @@ -272,7 +270,7 @@ public function testGet() $this->assertSame(null, $collection->get('non-existent'), 'Get non existent element'); } - public function testMatchingWithSortingPreservesyKeys() + public function testMatchingWithSortingPreservesyKeys() : void { $object1 = new \stdClass(); $object2 = new \stdClass(); @@ -300,7 +298,7 @@ public function testMatchingWithSortingPreservesyKeys() ); } - public function testMultiColumnSortAppliesAllSorts() + public function testMultiColumnSortAppliesAllSorts() : void { $collection = $this->buildCollection([ ['foo' => 1, 'bar' => 2], diff --git a/tests/Doctrine/Tests/Common/Collections/BaseCollectionTest.php b/tests/Doctrine/Tests/Common/Collections/BaseCollectionTest.php index 527e314e7..409b0eec8 100644 --- a/tests/Doctrine/Tests/Common/Collections/BaseCollectionTest.php +++ b/tests/Doctrine/Tests/Common/Collections/BaseCollectionTest.php @@ -11,7 +11,7 @@ abstract class BaseCollectionTest extends \PHPUnit_Framework_TestCase */ protected $collection; - public function testIssetAndUnset() + public function testIssetAndUnset() : void { $this->assertFalse(isset($this->collection[0])); $this->collection->add('testing'); @@ -20,12 +20,12 @@ public function testIssetAndUnset() $this->assertFalse(isset($this->collection[0])); } - public function testRemovingNonExistentEntryReturnsNull() + public function testRemovingNonExistentEntryReturnsNull() : void { $this->assertEquals(null, $this->collection->remove('testing_does_not_exist')); } - public function testExists() + public function testExists() : void { $this->collection->add('one'); $this->collection->add('two'); @@ -39,7 +39,7 @@ public function testExists() $this->assertFalse($exists); } - public function testMap() + public function testMap() : void { $this->collection->add(1); $this->collection->add(2); @@ -49,7 +49,7 @@ public function testMap() $this->assertEquals([2, 4], $res->toArray()); } - public function testFilter() + public function testFilter() : void { $this->collection->add(1); $this->collection->add('foo'); @@ -60,7 +60,7 @@ public function testFilter() $this->assertEquals([0 => 1, 2 => 3], $res->toArray()); } - public function testFirstAndLast() + public function testFirstAndLast() : void { $this->collection->add('one'); $this->collection->add('two'); @@ -69,7 +69,7 @@ public function testFirstAndLast() $this->assertEquals($this->collection->last(), 'two'); } - public function testArrayAccess() + public function testArrayAccess() : void { $this->collection[] = 'one'; $this->collection[] = 'two'; @@ -81,45 +81,45 @@ public function testArrayAccess() $this->assertEquals($this->collection->count(), 1); } - public function testContainsKey() + public function testContainsKey() : void { $this->collection[5] = 'five'; $this->assertTrue($this->collection->containsKey(5)); } - public function testContains() + public function testContains() : void { $this->collection[0] = 'test'; $this->assertTrue($this->collection->contains('test')); } - public function testSearch() + public function testSearch() : void { $this->collection[0] = 'test'; $this->assertEquals(0, $this->collection->indexOf('test')); } - public function testGet() + public function testGet() : void { $this->collection[0] = 'test'; $this->assertEquals('test', $this->collection->get(0)); } - public function testGetKeys() + public function testGetKeys() : void { $this->collection[] = 'one'; $this->collection[] = 'two'; $this->assertEquals([0, 1], $this->collection->getKeys()); } - public function testGetValues() + public function testGetValues() : void { $this->collection[] = 'one'; $this->collection[] = 'two'; $this->assertEquals(['one', 'two'], $this->collection->getValues()); } - public function testCount() + public function testCount() : void { $this->collection[] = 'one'; $this->collection[] = 'two'; @@ -127,7 +127,7 @@ public function testCount() $this->assertEquals(count($this->collection), 2); } - public function testForAll() + public function testForAll() : void { $this->collection[] = 'one'; $this->collection[] = 'two'; @@ -139,7 +139,7 @@ public function testForAll() }), false); } - public function testPartition() + public function testPartition() : void { $this->collection[] = true; $this->collection[] = false; @@ -150,7 +150,7 @@ public function testPartition() $this->assertEquals($partition[1][0], false); } - public function testClear() + public function testClear() : void { $this->collection[] = 'one'; $this->collection[] = 'two'; @@ -158,7 +158,7 @@ public function testClear() $this->assertEquals($this->collection->isEmpty(), true); } - public function testRemove() + public function testRemove() : void { $this->collection[] = 'one'; $this->collection[] = 'two'; @@ -169,7 +169,7 @@ public function testRemove() $this->assertNull($this->collection->remove(0)); } - public function testRemoveElement() + public function testRemoveElement() : void { $this->collection[] = 'one'; $this->collection[] = 'two'; @@ -179,7 +179,7 @@ public function testRemoveElement() $this->assertFalse($this->collection->removeElement('two')); } - public function testSlice() + public function testSlice() : void { $this->collection[] = 'one'; $this->collection[] = 'two'; @@ -196,7 +196,7 @@ public function testSlice() $this->assertEquals([1 => 'two'], $slice); } - public function fillMatchingFixture() + protected function fillMatchingFixture() : void { $std1 = new \stdClass(); $std1->foo = 'bar'; @@ -207,14 +207,14 @@ public function fillMatchingFixture() $this->collection[] = $std2; } - public function testCanRemoveNullValuesByKey() + public function testCanRemoveNullValuesByKey() : void { $this->collection->add(null); $this->collection->remove(0); $this->assertTrue($this->collection->isEmpty()); } - public function testCanVerifyExistingKeysWithNullValues() + public function testCanVerifyExistingKeysWithNullValues() : void { $this->collection->set('key', null); $this->assertTrue($this->collection->containsKey('key')); diff --git a/tests/Doctrine/Tests/Common/Collections/ClosureExpressionVisitorTest.php b/tests/Doctrine/Tests/Common/Collections/ClosureExpressionVisitorTest.php index 1bc3779d1..59c004091 100644 --- a/tests/Doctrine/Tests/Common/Collections/ClosureExpressionVisitorTest.php +++ b/tests/Doctrine/Tests/Common/Collections/ClosureExpressionVisitorTest.php @@ -37,20 +37,20 @@ class ClosureExpressionVisitorTest extends \PHPUnit_Framework_TestCase */ private $builder; - protected function setUp() + protected function setUp() : void { $this->visitor = new ClosureExpressionVisitor(); $this->builder = new ExpressionBuilder(); } - public function testGetObjectFieldValueIsAccessor() + public function testGetObjectFieldValueIsAccessor() : void { $object = new TestObject(1, 2, true); $this->assertTrue($this->visitor->getObjectFieldValue($object, 'baz')); } - public function testGetObjectFieldValueIsAccessorCamelCase() + public function testGetObjectFieldValueIsAccessorCamelCase() : void { $object = new TestObjectNotCamelCase(1); @@ -59,7 +59,7 @@ public function testGetObjectFieldValueIsAccessorCamelCase() $this->assertEquals(1, $this->visitor->getObjectFieldValue($object, 'fooBar')); } - public function testGetObjectFieldValueIsAccessorBoth() + public function testGetObjectFieldValueIsAccessorBoth() : void { $object = new TestObjectBothCamelCaseAndUnderscore(1, 2); @@ -68,7 +68,7 @@ public function testGetObjectFieldValueIsAccessorBoth() $this->assertEquals(2, $this->visitor->getObjectFieldValue($object, 'fooBar')); } - public function testGetObjectFieldValueIsAccessorOnePublic() + public function testGetObjectFieldValueIsAccessorOnePublic() : void { $object = new TestObjectPublicCamelCaseAndPrivateUnderscore(1, 2); @@ -77,7 +77,7 @@ public function testGetObjectFieldValueIsAccessorOnePublic() $this->assertEquals(2, $this->visitor->getObjectFieldValue($object, 'fooBar')); } - public function testGetObjectFieldValueIsAccessorBothPublic() + public function testGetObjectFieldValueIsAccessorBothPublic() : void { $object = new TestObjectPublicCamelCaseAndPrivateUnderscore(1, 2); @@ -86,14 +86,14 @@ public function testGetObjectFieldValueIsAccessorBothPublic() $this->assertEquals(2, $this->visitor->getObjectFieldValue($object, 'fooBar')); } - public function testGetObjectFieldValueMagicCallMethod() + public function testGetObjectFieldValueMagicCallMethod() : void { $object = new TestObject(1, 2, true, 3); $this->assertEquals(3, $this->visitor->getObjectFieldValue($object, 'qux')); } - public function testWalkEqualsComparison() + public function testWalkEqualsComparison() : void { $closure = $this->visitor->walkComparison($this->builder->eq("foo", 1)); @@ -101,7 +101,7 @@ public function testWalkEqualsComparison() $this->assertFalse($closure(new TestObject(2))); } - public function testWalkNotEqualsComparison() + public function testWalkNotEqualsComparison() : void { $closure = $this->visitor->walkComparison($this->builder->neq("foo", 1)); @@ -109,7 +109,7 @@ public function testWalkNotEqualsComparison() $this->assertTrue($closure(new TestObject(2))); } - public function testWalkLessThanComparison() + public function testWalkLessThanComparison() : void { $closure = $this->visitor->walkComparison($this->builder->lt("foo", 1)); @@ -117,7 +117,7 @@ public function testWalkLessThanComparison() $this->assertTrue($closure(new TestObject(0))); } - public function testWalkLessThanEqualsComparison() + public function testWalkLessThanEqualsComparison() : void { $closure = $this->visitor->walkComparison($this->builder->lte("foo", 1)); @@ -126,7 +126,7 @@ public function testWalkLessThanEqualsComparison() $this->assertTrue($closure(new TestObject(0))); } - public function testWalkGreaterThanEqualsComparison() + public function testWalkGreaterThanEqualsComparison() : void { $closure = $this->visitor->walkComparison($this->builder->gte("foo", 1)); @@ -135,7 +135,7 @@ public function testWalkGreaterThanEqualsComparison() $this->assertFalse($closure(new TestObject(0))); } - public function testWalkGreaterThanComparison() + public function testWalkGreaterThanComparison() : void { $closure = $this->visitor->walkComparison($this->builder->gt("foo", 1)); @@ -144,18 +144,18 @@ public function testWalkGreaterThanComparison() $this->assertFalse($closure(new TestObject(0))); } - public function testWalkInComparison() + public function testWalkInComparison() : void { - $closure = $this->visitor->walkComparison($this->builder->in("foo", array(1, 2, 3))); + $closure = $this->visitor->walkComparison($this->builder->in("foo", [1, 2, 3])); $this->assertTrue($closure(new TestObject(2))); $this->assertTrue($closure(new TestObject(1))); $this->assertFalse($closure(new TestObject(0))); } - public function testWalkNotInComparison() + public function testWalkNotInComparison() : void { - $closure = $this->visitor->walkComparison($this->builder->notIn("foo", array(1, 2, 3))); + $closure = $this->visitor->walkComparison($this->builder->notIn("foo", [1, 2, 3])); $this->assertFalse($closure(new TestObject(1))); $this->assertFalse($closure(new TestObject(2))); @@ -163,7 +163,7 @@ public function testWalkNotInComparison() $this->assertTrue($closure(new TestObject(4))); } - public function testWalkContainsComparison() + public function testWalkContainsComparison() : void { $closure = $this->visitor->walkComparison($this->builder->contains('foo', 'hello')); @@ -171,16 +171,16 @@ public function testWalkContainsComparison() $this->assertFalse($closure(new TestObject('world'))); } - public function testWalkMemberOfComparisonWithObject() + public function testWalkMemberOfComparisonWithObject() : void { $closure = $this->visitor->walkComparison($this->builder->memberof("foo", 2)); - $this->assertTrue($closure(new TestObject(array(1,2,3)))); - $this->assertTrue($closure(new TestObject(array(2)))); - $this->assertFalse($closure(new TestObject(array(1,3,5)))); + $this->assertTrue($closure(new TestObject([1,2,3]))); + $this->assertTrue($closure(new TestObject([2]))); + $this->assertFalse($closure(new TestObject([1,3,5]))); } - public function testWalkStartsWithComparison() + public function testWalkStartsWithComparison() : void { $closure = $this->visitor->walkComparison($this->builder->startsWith('foo', 'hello')); @@ -188,7 +188,7 @@ public function testWalkStartsWithComparison() $this->assertFalse($closure(new TestObject('world'))); } - public function testWalkEndsWithComparison() + public function testWalkEndsWithComparison() : void { $closure = $this->visitor->walkComparison($this->builder->endsWith('foo', 'world')); @@ -196,7 +196,7 @@ public function testWalkEndsWithComparison() $this->assertFalse($closure(new TestObject('hello'))); } - public function testWalkAndCompositeExpression() + public function testWalkAndCompositeExpression() : void { $closure = $this->visitor->walkCompositeExpression( $this->builder->andX( @@ -211,7 +211,7 @@ public function testWalkAndCompositeExpression() $this->assertFalse($closure(new TestObject(0, 0))); } - public function testWalkOrCompositeExpression() + public function testWalkOrCompositeExpression() : void { $closure = $this->visitor->walkCompositeExpression( $this->builder->orX( @@ -226,9 +226,9 @@ public function testWalkOrCompositeExpression() $this->assertFalse($closure(new TestObject(0, 0))); } - public function testSortByFieldAscending() + public function testSortByFieldAscending() : void { - $objects = array(new TestObject("b"), new TestObject("a"), new TestObject("c")); + $objects = [new TestObject("b"), new TestObject("a"), new TestObject("c")]; $sort = ClosureExpressionVisitor::sortByField("foo"); usort($objects, $sort); @@ -238,9 +238,9 @@ public function testSortByFieldAscending() $this->assertEquals("c", $objects[2]->getFoo()); } - public function testSortByFieldDescending() + public function testSortByFieldDescending() : void { - $objects = array(new TestObject("b"), new TestObject("a"), new TestObject("c")); + $objects = [new TestObject("b"), new TestObject("a"), new TestObject("c")]; $sort = ClosureExpressionVisitor::sortByField("foo", -1); usort($objects, $sort); @@ -250,9 +250,9 @@ public function testSortByFieldDescending() $this->assertEquals("a", $objects[2]->getFoo()); } - public function testSortDelegate() + public function testSortDelegate() : void { - $objects = array(new TestObject("a", "c"), new TestObject("a", "b"), new TestObject("a", "a")); + $objects = [new TestObject("a", "c"), new TestObject("a", "b"), new TestObject("a", "a")]; $sort = ClosureExpressionVisitor::sortByField("bar", 1); $sort = ClosureExpressionVisitor::sortByField("foo", 1, $sort); @@ -263,11 +263,11 @@ public function testSortDelegate() $this->assertEquals("c", $objects[2]->getBar()); } - public function testArrayComparison() + public function testArrayComparison() : void { $closure = $this->visitor->walkComparison($this->builder->eq("foo", 42)); - $this->assertTrue($closure(array('foo' => 42))); + $this->assertTrue($closure(['foo' => 42])); } } @@ -286,7 +286,7 @@ public function __construct($foo = null, $bar = null, $baz = null, $qux = null) $this->qux = $qux; } - public function __call($name, $arguments) + public function __call(string $name, array $arguments) { if ('getqux' === $name) { return $this->qux; @@ -313,7 +313,7 @@ class TestObjectNotCamelCase { private $foo_bar; - public function __construct($foo_bar = null) + public function __construct(?int $foo_bar) { $this->foo_bar = $foo_bar; } @@ -329,13 +329,13 @@ class TestObjectBothCamelCaseAndUnderscore private $foo_bar; private $fooBar; - public function __construct($foo_bar = null, $fooBar = null) + public function __construct(int $foo_bar = null, int $fooBar = null) { $this->foo_bar = $foo_bar; $this->fooBar = $fooBar; } - public function getFooBar() + public function getFooBar() : ?int { return $this->fooBar; } @@ -346,13 +346,13 @@ class TestObjectPublicCamelCaseAndPrivateUnderscore private $foo_bar; public $fooBar; - public function __construct($foo_bar = null, $fooBar = null) + public function __construct(int $foo_bar = null, int $fooBar = null) { $this->foo_bar = $foo_bar; $this->fooBar = $fooBar; } - public function getFooBar() + public function getFooBar() : ?int { return $this->fooBar; } diff --git a/tests/Doctrine/Tests/Common/Collections/CollectionTest.php b/tests/Doctrine/Tests/Common/Collections/CollectionTest.php index 65e17d960..5611b805f 100644 --- a/tests/Doctrine/Tests/Common/Collections/CollectionTest.php +++ b/tests/Doctrine/Tests/Common/Collections/CollectionTest.php @@ -8,12 +8,12 @@ class CollectionTest extends BaseCollectionTest { - protected function setUp() + protected function setUp() : void { $this->collection = new ArrayCollection(); } - public function testToString() + public function testToString() : void { $this->collection->add('testing'); $this->assertTrue(is_string((string) $this->collection)); @@ -22,7 +22,7 @@ public function testToString() /** * @group DDC-1637 */ - public function testMatching() + public function testMatching() : void { $this->fillMatchingFixture(); @@ -35,7 +35,7 @@ public function testMatching() /** * @group DDC-1637 */ - public function testMatchingOrdering() + public function testMatchingOrdering() : void { $this->fillMatchingFixture(); @@ -51,7 +51,7 @@ public function testMatchingOrdering() /** * @group DDC-1637 */ - public function testMatchingSlice() + public function testMatchingSlice() : void { $this->fillMatchingFixture(); diff --git a/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php b/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php index b3d3a06fd..548dbfecc 100644 --- a/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php +++ b/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php @@ -5,28 +5,29 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Expr\Comparison; use Doctrine\Common\Collections\Expr\CompositeExpression; +use Doctrine\Common\Collections\ExpressionBuilder; class CriteriaTest extends \PHPUnit_Framework_TestCase { - public function testCreate() + public function testCreate() : void { $criteria = Criteria::create(); - $this->assertInstanceOf('Doctrine\Common\Collections\Criteria', $criteria); + $this->assertInstanceOf(Criteria::class, $criteria); } - public function testConstructor() + public function testConstructor() : void { $expr = new Comparison("field", "=", "value"); - $criteria = new Criteria($expr, array("foo" => "ASC"), 10, 20); + $criteria = new Criteria($expr, ["foo" => "ASC"], 10, 20); $this->assertSame($expr, $criteria->getWhereExpression()); - $this->assertEquals(array("foo" => "ASC"), $criteria->getOrderings()); + $this->assertEquals(["foo" => "ASC"], $criteria->getOrderings()); $this->assertEquals(10, $criteria->getFirstResult()); $this->assertEquals(20, $criteria->getMaxResults()); } - public function testWhere() + public function testWhere() : void { $expr = new Comparison("field", "=", "value"); $criteria = new Criteria(); @@ -36,7 +37,7 @@ public function testWhere() $this->assertSame($expr, $criteria->getWhereExpression()); } - public function testAndWhere() + public function testAndWhere() : void { $expr = new Comparison("field", "=", "value"); $criteria = new Criteria(); @@ -46,13 +47,13 @@ public function testAndWhere() $criteria->andWhere($expr); $where = $criteria->getWhereExpression(); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\CompositeExpression', $where); + $this->assertInstanceOf(CompositeExpression::class, $where); $this->assertEquals(CompositeExpression::TYPE_AND, $where->getType()); - $this->assertSame(array($expr, $expr), $where->getExpressionList()); + $this->assertSame([$expr, $expr], $where->getExpressionList()); } - public function testAndWhereWithoutWhere() + public function testAndWhereWithoutWhere() : void { $expr = new Comparison("field", "=", "value"); $criteria = new Criteria(); @@ -62,7 +63,7 @@ public function testAndWhereWithoutWhere() $this->assertSame($expr, $criteria->getWhereExpression()); } - public function testOrWhere() + public function testOrWhere() : void { $expr = new Comparison("field", "=", "value"); $criteria = new Criteria(); @@ -72,13 +73,13 @@ public function testOrWhere() $criteria->orWhere($expr); $where = $criteria->getWhereExpression(); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\CompositeExpression', $where); + $this->assertInstanceOf(CompositeExpression::class, $where); $this->assertEquals(CompositeExpression::TYPE_OR, $where->getType()); - $this->assertSame(array($expr, $expr), $where->getExpressionList()); + $this->assertSame([$expr, $expr], $where->getExpressionList()); } - public function testOrWhereWithoutWhere() + public function testOrWhereWithoutWhere() : void { $expr = new Comparison("field", "=", "value"); $criteria = new Criteria(); @@ -88,16 +89,16 @@ public function testOrWhereWithoutWhere() $this->assertSame($expr, $criteria->getWhereExpression()); } - public function testOrderings() + public function testOrderings() : void { $criteria = Criteria::create() - ->orderBy(array("foo" => "ASC")); + ->orderBy(["foo" => "ASC"]); - $this->assertEquals(array("foo" => "ASC"), $criteria->getOrderings()); + $this->assertEquals(["foo" => "ASC"], $criteria->getOrderings()); } - public function testExpr() + public function testExpr() : void { - $this->assertInstanceOf('Doctrine\Common\Collections\ExpressionBuilder', Criteria::expr()); + $this->assertInstanceOf(ExpressionBuilder::class, Criteria::expr()); } } diff --git a/tests/Doctrine/Tests/Common/Collections/DerivedCollectionTest.php b/tests/Doctrine/Tests/Common/Collections/DerivedCollectionTest.php index e4054276e..540f439aa 100644 --- a/tests/Doctrine/Tests/Common/Collections/DerivedCollectionTest.php +++ b/tests/Doctrine/Tests/Common/Collections/DerivedCollectionTest.php @@ -19,18 +19,19 @@ namespace Doctrine\Tests\Common\Collections; +use Doctrine\Common\Collections\Criteria; use Doctrine\Tests\DerivedArrayCollection; /** * @author Alexander Golovnya */ -class DerivedCollectionTest +class DerivedCollectionTest extends \PHPUnit_Framework_TestCase { /** * Tests that methods that create a new instance can be called in a derived * class that implements different constructor semantics. */ - public function testDerivedClassCreation() + public function testDerivedClassCreation() : void { $collection = new DerivedArrayCollection(new \stdClass()); $closure = function () { diff --git a/tests/Doctrine/Tests/Common/Collections/Expr/CompositeExpressionTest.php b/tests/Doctrine/Tests/Common/Collections/Expr/CompositeExpressionTest.php index 2f91c7479..b4addc629 100644 --- a/tests/Doctrine/Tests/Common/Collections/Expr/CompositeExpressionTest.php +++ b/tests/Doctrine/Tests/Common/Collections/Expr/CompositeExpressionTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\Common\Collections\Expr; use Doctrine\Common\Collections\Expr\CompositeExpression; +use Doctrine\Common\Collections\Expr\Expression; use Doctrine\Common\Collections\Expr\ExpressionVisitor; use Doctrine\Common\Collections\Expr\Value; use PHPUnit\Framework\TestCase as TestCase; @@ -13,42 +14,29 @@ */ class CompositeExpressionTest extends TestCase { - /** - * @return array - */ - public function invalidDataProvider() + public function invalidDataProvider() : array { - return array( - array( - 'expression' => new Value('value'), - ), - array( - 'expression' => 'wrong-type', - ), - ); + return [ + ['expression' => new Value('value')], + ['expression' => 'wrong-type'], + ]; } /** * @dataProvider invalidDataProvider - * - * @param $expression - * @return void */ - public function testExceptions($expression) + public function testExceptions($expression) : void { $type = CompositeExpression::TYPE_AND; - $expressions = array( + $expressions = [ $expression, - ); + ]; - $this->setExpectedException('\RuntimeException'); + $this->expectException(\RuntimeException::class); new CompositeExpression($type, $expressions); } - /** - * @return void - */ - public function testGetType() + public function testGetType() : void { $compositeExpression = $this->createCompositeExpression(); @@ -58,44 +46,28 @@ public function testGetType() $this->assertSame($expectedType, $actualType); } - /** - * @return CompositeExpression - */ - protected function createCompositeExpression() + protected function createCompositeExpression() : CompositeExpression { - $type = CompositeExpression::TYPE_AND; - $expressions = array( - $this->createMock('Doctrine\Common\Collections\Expr\Expression'), - ); + $type = CompositeExpression::TYPE_AND; + $expressions = [$this->createMock(Expression::class)]; - $compositeExpression = new CompositeExpression($type, $expressions); - - return $compositeExpression; + return new CompositeExpression($type, $expressions); } - /** - * @return void - */ - public function testGetExpressionList() + public function testGetExpressionList() : void { - $compositeExpression = $this->createCompositeExpression(); - - $expectedExpressionList = array( - $this->createMock('Doctrine\Common\Collections\Expr\Expression'), - ); - $actualExpressionList = $compositeExpression->getExpressionList(); + $compositeExpression = $this->createCompositeExpression(); + $expectedExpressionList = [$this->createMock(Expression::class)]; + $actualExpressionList = $compositeExpression->getExpressionList(); $this->assertEquals($expectedExpressionList, $actualExpressionList); } - /** - * @return void - */ - public function testVisitor() + public function testVisitor() : void { $compositeExpression = $this->createCompositeExpression(); - $visitor = $this->getMockForAbstractClass('Doctrine\Common\Collections\Expr\ExpressionVisitor'); + $visitor = $this->getMockForAbstractClass(ExpressionVisitor::class); $visitor ->expects($this->once()) ->method('walkCompositeExpression'); @@ -103,4 +75,4 @@ public function testVisitor() /** @var ExpressionVisitor $visitor */ $compositeExpression->visit($visitor); } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Common/Collections/Expr/ValueTest.php b/tests/Doctrine/Tests/Common/Collections/Expr/ValueTest.php index be807ea76..ccf49f6b6 100644 --- a/tests/Doctrine/Tests/Common/Collections/Expr/ValueTest.php +++ b/tests/Doctrine/Tests/Common/Collections/Expr/ValueTest.php @@ -12,10 +12,7 @@ */ class ValueTest extends TestCase { - /** - * @return void - */ - public function testGetter() + public function testGetter() : void { $value = 'foo'; $valueExpression = new Value($value); @@ -25,12 +22,9 @@ public function testGetter() $this->assertEquals($value, $actualValue); } - /** - * @return void - */ - public function testVisitor() + public function testVisitor() : void { - $visitor = $this->getMockForAbstractClass('Doctrine\Common\Collections\Expr\ExpressionVisitor'); + $visitor = $this->getMockForAbstractClass(ExpressionVisitor::class); $visitor ->expects($this->once()) ->method('walkValue'); @@ -40,4 +34,4 @@ public function testVisitor() $valueExpression = new Value($value); $valueExpression->visit($visitor); } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php b/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php index dbf1972b9..4688cc0d4 100644 --- a/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php +++ b/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php @@ -16,134 +16,134 @@ class ExpressionBuilderTest extends \PHPUnit_Framework_TestCase */ private $builder; - protected function setUp() + protected function setUp() : void { $this->builder = new ExpressionBuilder(); } - public function testAndX() + public function testAndX() : void { $expr = $this->builder->andX($this->builder->eq("a", "b")); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\CompositeExpression', $expr); + $this->assertInstanceOf(CompositeExpression::class, $expr); $this->assertEquals(CompositeExpression::TYPE_AND, $expr->getType()); } - public function testOrX() + public function testOrX() : void { $expr = $this->builder->orX($this->builder->eq("a", "b")); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\CompositeExpression', $expr); + $this->assertInstanceOf(CompositeExpression::class, $expr); $this->assertEquals(CompositeExpression::TYPE_OR, $expr->getType()); } - public function testInvalidAndXArgument() + public function testInvalidAndXArgument() : void { - $this->setExpectedException("RuntimeException"); + $this->expectException(\RuntimeException::class); $this->builder->andX("foo"); } - public function testEq() + public function testEq() : void { $expr = $this->builder->eq("a", "b"); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\Comparison', $expr); + $this->assertInstanceOf(Comparison::class, $expr); $this->assertEquals(Comparison::EQ, $expr->getOperator()); } - public function testNeq() + public function testNeq() : void { $expr = $this->builder->neq("a", "b"); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\Comparison', $expr); + $this->assertInstanceOf(Comparison::class, $expr); $this->assertEquals(Comparison::NEQ, $expr->getOperator()); } - public function testLt() + public function testLt() : void { $expr = $this->builder->lt("a", "b"); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\Comparison', $expr); + $this->assertInstanceOf(Comparison::class, $expr); $this->assertEquals(Comparison::LT, $expr->getOperator()); } - public function testGt() + public function testGt() : void { $expr = $this->builder->gt("a", "b"); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\Comparison', $expr); + $this->assertInstanceOf(Comparison::class, $expr); $this->assertEquals(Comparison::GT, $expr->getOperator()); } - public function testGte() + public function testGte() : void { $expr = $this->builder->gte("a", "b"); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\Comparison', $expr); + $this->assertInstanceOf(Comparison::class, $expr); $this->assertEquals(Comparison::GTE, $expr->getOperator()); } - public function testLte() + public function testLte() : void { $expr = $this->builder->lte("a", "b"); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\Comparison', $expr); + $this->assertInstanceOf(Comparison::class, $expr); $this->assertEquals(Comparison::LTE, $expr->getOperator()); } - public function testIn() + public function testIn() : void { - $expr = $this->builder->in("a", array("b")); + $expr = $this->builder->in("a", ["b"]); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\Comparison', $expr); + $this->assertInstanceOf(Comparison::class, $expr); $this->assertEquals(Comparison::IN, $expr->getOperator()); } - public function testNotIn() + public function testNotIn() : void { - $expr = $this->builder->notIn("a", array("b")); + $expr = $this->builder->notIn("a", ["b"]); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\Comparison', $expr); + $this->assertInstanceOf(Comparison::class, $expr); $this->assertEquals(Comparison::NIN, $expr->getOperator()); } - public function testIsNull() + public function testIsNull() : void { $expr = $this->builder->isNull("a"); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\Comparison', $expr); + $this->assertInstanceOf(Comparison::class, $expr); $this->assertEquals(Comparison::EQ, $expr->getOperator()); } - public function testContains() + public function testContains() : void { $expr = $this->builder->contains("a", "b"); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\Comparison', $expr); + $this->assertInstanceOf(Comparison::class, $expr); $this->assertEquals(Comparison::CONTAINS, $expr->getOperator()); } - public function testMemberOf() + public function testMemberOf() : void { - $expr = $this->builder->memberOf("b", array("a")); + $expr = $this->builder->memberOf("b", ["a"]); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\Comparison', $expr); + $this->assertInstanceOf(Comparison::class, $expr); $this->assertEquals(Comparison::MEMBER_OF, $expr->getOperator()); } - public function testStartsWith() + public function testStartsWith() : void { $expr = $this->builder->startsWith("a", "b"); - $this->assertInstanceOf("Doctrine\Common\Collections\Expr\Comparison", $expr); + $this->assertInstanceOf(Comparison::class, $expr); $this->assertEquals(Comparison::STARTS_WITH, $expr->getOperator()); } - public function testEndsWith() + public function testEndsWith() : void { $expr = $this->builder->endsWith("a", "b"); - $this->assertInstanceOf("Doctrine\Common\Collections\Expr\Comparison", $expr); + $this->assertInstanceOf(Comparison::class, $expr); $this->assertEquals(Comparison::ENDS_WITH, $expr->getOperator()); - } + } } diff --git a/tests/Doctrine/Tests/DerivedArrayCollection.php b/tests/Doctrine/Tests/DerivedArrayCollection.php index 007419174..7afaf6d27 100644 --- a/tests/Doctrine/Tests/DerivedArrayCollection.php +++ b/tests/Doctrine/Tests/DerivedArrayCollection.php @@ -11,14 +11,14 @@ final class DerivedArrayCollection extends ArrayCollection { private $foo; - public function __construct(\stdClass $foo, array $elements = array()) + public function __construct(\stdClass $foo, array $elements = []) { $this->foo = $foo; parent::__construct($elements); } - protected function createFrom(array $elements) + protected function createFrom(array $elements) : self { return new static($this->foo, $elements); } diff --git a/tests/Doctrine/Tests/LazyArrayCollection.php b/tests/Doctrine/Tests/LazyArrayCollection.php index d3af2c353..6c8758faa 100644 --- a/tests/Doctrine/Tests/LazyArrayCollection.php +++ b/tests/Doctrine/Tests/LazyArrayCollection.php @@ -2,16 +2,14 @@ namespace Doctrine\Tests; -use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\AbstractLazyCollection; -use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; /** * Simple lazy collection that used an ArrayCollection as backed collection. */ class LazyArrayCollection extends AbstractLazyCollection { - /** * Apply the collection only in method doInitialize * @var Collection @@ -30,7 +28,7 @@ public function __construct(Collection $collection) /** * Do the initialization logic. */ - protected function doInitialize() + protected function doInitialize() : void { $this->collection = $this->collectionOnInitialization; }