Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Feb 24, 2017
1 parent 09f699d commit f4626c4
Show file tree
Hide file tree
Showing 35 changed files with 670 additions and 659 deletions.
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
Comparator

Copyright (c) 2002-2015, Sebastian Bergmann <sebastian@phpunit.de>.
Copyright (c) 2002-2017, Sebastian Bergmann <sebastian@phpunit.de>.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
7 changes: 4 additions & 3 deletions src/ArrayComparator.php
Expand Up @@ -18,8 +18,9 @@ class ArrayComparator extends Comparator
/**
* Returns whether the comparator can compare two values.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
*
* @return bool
*/
public function accepts($expected, $actual)
Expand All @@ -39,7 +40,7 @@ public function accepts($expected, $actual)
*
* @throws ComparisonFailure
*/
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array())
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = [])
{
if ($canonicalize) {
sort($expected);
Expand Down
5 changes: 3 additions & 2 deletions src/Comparator.php
Expand Up @@ -43,8 +43,9 @@ public function setFactory(Factory $factory)
/**
* Returns whether the comparator can compare two values.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
*
* @return bool
*/
abstract public function accepts($expected, $actual);
Expand Down
5 changes: 5 additions & 0 deletions src/ComparisonFailure.php
Expand Up @@ -19,24 +19,28 @@ class ComparisonFailure extends \RuntimeException
{
/**
* Expected value of the retrieval which does not match $actual.
*
* @var mixed
*/
protected $expected;

/**
* Actually retrieved value which does not match $expected.
*
* @var mixed
*/
protected $actual;

/**
* The string representation of the expected value
*
* @var string
*/
protected $expectedAsString;

/**
* The string representation of the actual value
*
* @var string
*/
protected $actualAsString;
Expand All @@ -49,6 +53,7 @@ class ComparisonFailure extends \RuntimeException
/**
* Optional message which is placed in front of the first line
* returned by toString().
*
* @var string
*/
protected $message;
Expand Down
14 changes: 8 additions & 6 deletions src/DOMNodeComparator.php
Expand Up @@ -21,8 +21,9 @@ class DOMNodeComparator extends ObjectComparator
/**
* Returns whether the comparator can compare two values.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
*
* @return bool
*/
public function accepts($expected, $actual)
Expand All @@ -42,7 +43,7 @@ public function accepts($expected, $actual)
*
* @throws ComparisonFailure
*/
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array())
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = [])
{
$expectedAsString = $this->nodeToText($expected, true, $ignoreCase);
$actualAsString = $this->nodeToText($actual, true, $ignoreCase);
Expand All @@ -69,9 +70,10 @@ public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = f
* Returns the normalized, whitespace-cleaned, and indented textual
* representation of a DOMNode.
*
* @param DOMNode $node
* @param bool $canonicalize
* @param bool $ignoreCase
* @param DOMNode $node
* @param bool $canonicalize
* @param bool $ignoreCase
*
* @return string
*/
private function nodeToText(DOMNode $node, $canonicalize, $ignoreCase)
Expand Down
10 changes: 6 additions & 4 deletions src/DateTimeComparator.php
Expand Up @@ -18,8 +18,9 @@ class DateTimeComparator extends ObjectComparator
/**
* Returns whether the comparator can compare two values.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
*
* @return bool
*/
public function accepts($expected, $actual)
Expand All @@ -40,7 +41,7 @@ public function accepts($expected, $actual)
*
* @throws ComparisonFailure
*/
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array())
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = [])
{
$delta = new \DateInterval(sprintf('PT%sS', abs($delta)));

Expand All @@ -65,7 +66,8 @@ public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = f
* 'Invalid DateTimeInterface object' if the provided DateTimeInterface was not properly
* initialized.
*
* @param \DateTimeInterface $datetime
* @param \DateTimeInterface $datetime
*
* @return string
*/
private function dateTimeToString($datetime)
Expand Down
7 changes: 4 additions & 3 deletions src/DoubleComparator.php
Expand Up @@ -25,13 +25,14 @@ class DoubleComparator extends NumericComparator
/**
* Returns whether the comparator can compare two values.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
*
* @return bool
*/
public function accepts($expected, $actual)
{
return (is_double($expected) || is_double($actual)) && is_numeric($expected) && is_numeric($actual);
return (is_float($expected) || is_float($actual)) && is_numeric($expected) && is_numeric($actual);
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/ExceptionComparator.php
Expand Up @@ -18,8 +18,9 @@ class ExceptionComparator extends ObjectComparator
/**
* Returns whether the comparator can compare two values.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
*
* @return bool
*/
public function accepts($expected, $actual)
Expand All @@ -31,7 +32,8 @@ public function accepts($expected, $actual)
* Converts an object to an array containing all of its private, protected
* and public properties.
*
* @param object $object
* @param object $object
*
* @return array
*/
protected function toArray($object)
Expand Down
7 changes: 4 additions & 3 deletions src/Factory.php
Expand Up @@ -18,7 +18,7 @@ class Factory
/**
* @var Comparator[]
*/
private $comparators = array();
private $comparators = [];

/**
* @var Factory
Expand Down Expand Up @@ -59,8 +59,9 @@ public static function getInstance()
/**
* Returns the correct comparator for comparing two values.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
*
* @return Comparator
*/
public function getComparatorFor($expected, $actual)
Expand Down
10 changes: 6 additions & 4 deletions src/MockObjectComparator.php
Expand Up @@ -18,8 +18,9 @@ class MockObjectComparator extends ObjectComparator
/**
* Returns whether the comparator can compare two values.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
*
* @return bool
*/
public function accepts($expected, $actual)
Expand All @@ -31,7 +32,8 @@ public function accepts($expected, $actual)
* Converts an object to an array containing all of its private, protected
* and public properties.
*
* @param object $object
* @param object $object
*
* @return array
*/
protected function toArray($object)
Expand All @@ -42,4 +44,4 @@ protected function toArray($object)

return $array;
}
}
}
7 changes: 4 additions & 3 deletions src/NumericComparator.php
Expand Up @@ -18,16 +18,17 @@ class NumericComparator extends ScalarComparator
/**
* Returns whether the comparator can compare two values.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
*
* @return bool
*/
public function accepts($expected, $actual)
{
// all numerical values, but not if one of them is a double
// or both of them are strings
return is_numeric($expected) && is_numeric($actual) &&
!(is_double($expected) || is_double($actual)) &&
!(is_float($expected) || is_float($actual)) &&
!(is_string($expected) && is_string($actual));
}

Expand Down
16 changes: 9 additions & 7 deletions src/ObjectComparator.php
Expand Up @@ -18,8 +18,9 @@ class ObjectComparator extends ArrayComparator
/**
* Returns whether the comparator can compare two values.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
*
* @return bool
*/
public function accepts($expected, $actual)
Expand All @@ -39,7 +40,7 @@ public function accepts($expected, $actual)
*
* @throws ComparisonFailure
*/
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array())
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = [])
{
if (get_class($actual) !== get_class($expected)) {
throw new ComparisonFailure(
Expand All @@ -57,12 +58,12 @@ public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = f
}

// don't compare twice to allow for cyclic dependencies
if (in_array(array($actual, $expected), $processed, true) ||
in_array(array($expected, $actual), $processed, true)) {
if (in_array([$actual, $expected], $processed, true) ||
in_array([$expected, $actual], $processed, true)) {
return;
}

$processed[] = array($actual, $expected);
$processed[] = [$actual, $expected];

// don't compare objects if they are identical
// this helps to avoid the error "maximum function nesting level reached"
Expand Down Expand Up @@ -95,7 +96,8 @@ public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = f
* Converts an object to an array containing all of its private, protected
* and public properties.
*
* @param object $object
* @param object $object
*
* @return array
*/
protected function toArray($object)
Expand Down
5 changes: 3 additions & 2 deletions src/ResourceComparator.php
Expand Up @@ -18,8 +18,9 @@ class ResourceComparator extends Comparator
/**
* Returns whether the comparator can compare two values.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
*
* @return bool
*/
public function accepts($expected, $actual)
Expand Down
6 changes: 4 additions & 2 deletions src/ScalarComparator.php
Expand Up @@ -18,9 +18,11 @@ class ScalarComparator extends Comparator
/**
* Returns whether the comparator can compare two values.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
*
* @return bool
*
* @since Method available since Release 3.6.0
*/
public function accepts($expected, $actual)
Expand Down
5 changes: 3 additions & 2 deletions src/SplObjectStorageComparator.php
Expand Up @@ -18,8 +18,9 @@ class SplObjectStorageComparator extends Comparator
/**
* Returns whether the comparator can compare two values.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
*
* @return bool
*/
public function accepts($expected, $actual)
Expand Down
5 changes: 3 additions & 2 deletions src/TypeComparator.php
Expand Up @@ -18,8 +18,9 @@ class TypeComparator extends Comparator
/**
* Returns whether the comparator can compare two values.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
*
* @return bool
*/
public function accepts($expected, $actual)
Expand Down

0 comments on commit f4626c4

Please sign in to comment.