From fca3754cf11d0211e15d6c7e7261b8005c4a8347 Mon Sep 17 00:00:00 2001 From: Philipp Scheit
true
if $item matches,
+ * @return bool true
if $item matches,
* otherwise false
.
*
* @see Hamcrest\BaseMatcher
*/
public function matches($item);
- /**
- * Generate a description of why the matcher has not accepted the item.
- * The description will be part of a larger description of why a matching
- * failed, so it should be concise.
- * This method assumes that matches($item)
is false, but
- * will not check this.
- *
- * @param mixed $item The item that the Matcher has rejected.
- * @param Description $description
- * @return
- */
+ /**
+ * Generate a description of why the matcher has not accepted the item.
+ * The description will be part of a larger description of why a matching
+ * failed, so it should be concise.
+ * This method assumes that matches($item)
is false, but
+ * will not check this.
+ *
+ * @param mixed $item The item that the Matcher has rejected.
+ * @param Description $description
+ * @return
+ */
public function describeMismatch($item, Description $description);
}
diff --git a/hamcrest/Hamcrest/MatcherAssert.php b/hamcrest/Hamcrest/MatcherAssert.php
index d546dbee6..dff1971fb 100644
--- a/hamcrest/Hamcrest/MatcherAssert.php
+++ b/hamcrest/Hamcrest/MatcherAssert.php
@@ -107,8 +107,9 @@ private static function doAssert($identifier, $actual, Matcher $matcher)
$description->appendText($identifier . PHP_EOL);
}
$description->appendText('Expected: ')
- ->appendDescriptionOf($matcher)
- ->appendText(PHP_EOL . ' but: ');
+ ->appendDescriptionOf($matcher)
+ ->appendText(PHP_EOL . ' but: ')
+ ;
$matcher->describeMismatch($actual, $description);
diff --git a/hamcrest/Hamcrest/Matchers.php b/hamcrest/Hamcrest/Matchers.php
index 23232e450..77eb12d91 100644
--- a/hamcrest/Hamcrest/Matchers.php
+++ b/hamcrest/Hamcrest/Matchers.php
@@ -5,7 +5,6 @@
*/
// This file is generated from the static method @factory doctags.
-
namespace Hamcrest;
/**
diff --git a/hamcrest/Hamcrest/Number/IsCloseTo.php b/hamcrest/Hamcrest/Number/IsCloseTo.php
index 15453e526..8efea877e 100644
--- a/hamcrest/Hamcrest/Number/IsCloseTo.php
+++ b/hamcrest/Hamcrest/Number/IsCloseTo.php
@@ -33,18 +33,18 @@ protected function matchesSafely($item)
protected function describeMismatchSafely($item, Description $mismatchDescription)
{
$mismatchDescription->appendValue($item)
- ->appendText(' differed by ')
- ->appendValue($this->_actualDelta($item))
- ;
+ ->appendText(' differed by ')
+ ->appendValue($this->_actualDelta($item))
+ ;
}
public function describeTo(Description $description)
{
$description->appendText('a numeric value within ')
- ->appendValue($this->_delta)
- ->appendText(' of ')
- ->appendValue($this->_value)
- ;
+ ->appendValue($this->_delta)
+ ->appendText(' of ')
+ ->appendValue($this->_value)
+ ;
}
/**
diff --git a/hamcrest/Hamcrest/Number/OrderingComparison.php b/hamcrest/Hamcrest/Number/OrderingComparison.php
index 369d0cfa5..6248c570a 100644
--- a/hamcrest/Hamcrest/Number/OrderingComparison.php
+++ b/hamcrest/Hamcrest/Number/OrderingComparison.php
@@ -37,18 +37,18 @@ protected function describeMismatchSafely($item, Description $mismatchDescriptio
->appendValue($item)->appendText(' was ')
->appendText($this->_comparison($this->_compare($this->_value, $item)))
->appendText(' ')->appendValue($this->_value)
- ;
+ ;
}
public function describeTo(Description $description)
{
$description->appendText('a value ')
->appendText($this->_comparison($this->_minCompare))
- ;
+ ;
if ($this->_minCompare != $this->_maxCompare) {
$description->appendText(' or ')
->appendText($this->_comparison($this->_maxCompare))
- ;
+ ;
}
$description->appendText(' ')->appendValue($this->_value);
}
diff --git a/hamcrest/Hamcrest/Text/IsEqualIgnoringCase.php b/hamcrest/Hamcrest/Text/IsEqualIgnoringCase.php
index 3836a8c37..939623aa1 100644
--- a/hamcrest/Hamcrest/Text/IsEqualIgnoringCase.php
+++ b/hamcrest/Hamcrest/Text/IsEqualIgnoringCase.php
@@ -35,9 +35,9 @@ protected function describeMismatchSafely($item, Description $mismatchDescriptio
public function describeTo(Description $description)
{
$description->appendText('equalToIgnoringCase(')
- ->appendValue($this->_string)
- ->appendText(')')
- ;
+ ->appendValue($this->_string)
+ ->appendText(')')
+ ;
}
/**
diff --git a/hamcrest/Hamcrest/Text/IsEqualIgnoringWhiteSpace.php b/hamcrest/Hamcrest/Text/IsEqualIgnoringWhiteSpace.php
index 853692b03..5951b711f 100644
--- a/hamcrest/Hamcrest/Text/IsEqualIgnoringWhiteSpace.php
+++ b/hamcrest/Hamcrest/Text/IsEqualIgnoringWhiteSpace.php
@@ -37,9 +37,9 @@ protected function describeMismatchSafely($item, Description $mismatchDescriptio
public function describeTo(Description $description)
{
$description->appendText('equalToIgnoringWhiteSpace(')
- ->appendValue($this->_string)
- ->appendText(')')
- ;
+ ->appendValue($this->_string)
+ ->appendText(')')
+ ;
}
/**
diff --git a/hamcrest/Hamcrest/Text/StringContainsInOrder.php b/hamcrest/Hamcrest/Text/StringContainsInOrder.php
index e75de65d2..03e9935d2 100644
--- a/hamcrest/Hamcrest/Text/StringContainsInOrder.php
+++ b/hamcrest/Hamcrest/Text/StringContainsInOrder.php
@@ -43,9 +43,9 @@ protected function describeMismatchSafely($item, Description $mismatchDescriptio
public function describeTo(Description $description)
{
$description->appendText('a string containing ')
- ->appendValueList('', ', ', '', $this->_substrings)
- ->appendText(' in order')
- ;
+ ->appendValueList('', ', ', '', $this->_substrings)
+ ->appendText(' in order')
+ ;
}
/**
diff --git a/hamcrest/Hamcrest/Text/SubstringMatcher.php b/hamcrest/Hamcrest/Text/SubstringMatcher.php
index e560ad627..96a31dcd0 100644
--- a/hamcrest/Hamcrest/Text/SubstringMatcher.php
+++ b/hamcrest/Hamcrest/Text/SubstringMatcher.php
@@ -33,10 +33,10 @@ protected function describeMismatchSafely($item, Description $mismatchDescriptio
public function describeTo(Description $description)
{
$description->appendText('a string ')
- ->appendText($this->relationship())
- ->appendText(' ')
- ->appendValue($this->_substring)
- ;
+ ->appendText($this->relationship())
+ ->appendText(' ')
+ ->appendValue($this->_substring)
+ ;
}
abstract protected function evalSubstringOf($string);
diff --git a/hamcrest/Hamcrest/Type/IsArray.php b/hamcrest/Hamcrest/Type/IsArray.php
index 9179102ff..7ffc69694 100644
--- a/hamcrest/Hamcrest/Type/IsArray.php
+++ b/hamcrest/Hamcrest/Type/IsArray.php
@@ -27,6 +27,6 @@ public function __construct()
*/
public static function arrayValue()
{
- return new self;
+ return new self();
}
}
diff --git a/hamcrest/Hamcrest/Type/IsBoolean.php b/hamcrest/Hamcrest/Type/IsBoolean.php
index 35b617cf4..f8fa1daf6 100644
--- a/hamcrest/Hamcrest/Type/IsBoolean.php
+++ b/hamcrest/Hamcrest/Type/IsBoolean.php
@@ -27,6 +27,6 @@ public function __construct()
*/
public static function booleanValue()
{
- return new self;
+ return new self();
}
}
diff --git a/hamcrest/Hamcrest/Type/IsCallable.php b/hamcrest/Hamcrest/Type/IsCallable.php
index f2bcd35ba..507774901 100644
--- a/hamcrest/Hamcrest/Type/IsCallable.php
+++ b/hamcrest/Hamcrest/Type/IsCallable.php
@@ -32,6 +32,6 @@ public function matches($item)
*/
public static function callableValue()
{
- return new self;
+ return new self();
}
}
diff --git a/hamcrest/Hamcrest/Type/IsDouble.php b/hamcrest/Hamcrest/Type/IsDouble.php
index 3ddd8e852..8b057f485 100644
--- a/hamcrest/Hamcrest/Type/IsDouble.php
+++ b/hamcrest/Hamcrest/Type/IsDouble.php
@@ -29,6 +29,6 @@ public function __construct()
*/
public static function doubleValue()
{
- return new self;
+ return new self();
}
}
diff --git a/hamcrest/Hamcrest/Type/IsInteger.php b/hamcrest/Hamcrest/Type/IsInteger.php
index 47c86bd68..df3926d40 100644
--- a/hamcrest/Hamcrest/Type/IsInteger.php
+++ b/hamcrest/Hamcrest/Type/IsInteger.php
@@ -27,6 +27,6 @@ public function __construct()
*/
public static function integerValue()
{
- return new self;
+ return new self();
}
}
diff --git a/hamcrest/Hamcrest/Type/IsNumeric.php b/hamcrest/Hamcrest/Type/IsNumeric.php
index bc7440547..c9673af1e 100644
--- a/hamcrest/Hamcrest/Type/IsNumeric.php
+++ b/hamcrest/Hamcrest/Type/IsNumeric.php
@@ -31,7 +31,7 @@ public function matches($item)
* This check is necessary because PHP 7 doesn't recognize hexadecimal string as numeric anymore.
*
* @param mixed $item
- * @return boolean
+ * @return bool
*/
private function isHexadecimal($item)
{
@@ -49,6 +49,6 @@ private function isHexadecimal($item)
*/
public static function numericValue()
{
- return new self;
+ return new self();
}
}
diff --git a/hamcrest/Hamcrest/Type/IsObject.php b/hamcrest/Hamcrest/Type/IsObject.php
index 65918fcf3..31f3d8e3c 100644
--- a/hamcrest/Hamcrest/Type/IsObject.php
+++ b/hamcrest/Hamcrest/Type/IsObject.php
@@ -27,6 +27,6 @@ public function __construct()
*/
public static function objectValue()
{
- return new self;
+ return new self();
}
}
diff --git a/hamcrest/Hamcrest/Type/IsResource.php b/hamcrest/Hamcrest/Type/IsResource.php
index 426cf77c9..3bffc1ae6 100644
--- a/hamcrest/Hamcrest/Type/IsResource.php
+++ b/hamcrest/Hamcrest/Type/IsResource.php
@@ -27,6 +27,6 @@ public function __construct()
*/
public static function resourceValue()
{
- return new self;
+ return new self();
}
}
diff --git a/hamcrest/Hamcrest/Type/IsScalar.php b/hamcrest/Hamcrest/Type/IsScalar.php
index 3f3b427fa..8b207c2bf 100644
--- a/hamcrest/Hamcrest/Type/IsScalar.php
+++ b/hamcrest/Hamcrest/Type/IsScalar.php
@@ -29,6 +29,6 @@ public function matches($item)
*/
public static function scalarValue()
{
- return new self;
+ return new self();
}
}
diff --git a/hamcrest/Hamcrest/Type/IsString.php b/hamcrest/Hamcrest/Type/IsString.php
index d96d7db38..d852a4a3e 100644
--- a/hamcrest/Hamcrest/Type/IsString.php
+++ b/hamcrest/Hamcrest/Type/IsString.php
@@ -27,6 +27,6 @@ public function __construct()
*/
public static function stringValue()
{
- return new self;
+ return new self();
}
}
diff --git a/hamcrest/Hamcrest/TypeSafeMatcher.php b/hamcrest/Hamcrest/TypeSafeMatcher.php
index 56e299a9a..dc3532038 100644
--- a/hamcrest/Hamcrest/TypeSafeMatcher.php
+++ b/hamcrest/Hamcrest/TypeSafeMatcher.php
@@ -14,13 +14,13 @@ abstract class TypeSafeMatcher extends BaseMatcher
{
/* Types that PHP can compare against */
- const TYPE_ANY = 0;
- const TYPE_STRING = 1;
- const TYPE_NUMERIC = 2;
- const TYPE_ARRAY = 3;
- const TYPE_OBJECT = 4;
- const TYPE_RESOURCE = 5;
- const TYPE_BOOLEAN = 6;
+ public const TYPE_ANY = 0;
+ public const TYPE_STRING = 1;
+ public const TYPE_NUMERIC = 2;
+ public const TYPE_ARRAY = 3;
+ public const TYPE_OBJECT = 4;
+ public const TYPE_RESOURCE = 5;
+ public const TYPE_BOOLEAN = 6;
/**
* The type that is required for a safe comparison
diff --git a/hamcrest/Hamcrest/Util.php b/hamcrest/Hamcrest/Util.php
index 169b03663..7c0b5afeb 100644
--- a/hamcrest/Hamcrest/Util.php
+++ b/hamcrest/Hamcrest/Util.php
@@ -27,8 +27,7 @@ public static function wrapValueWithIsEqual($item)
{
return ($item instanceof Matcher)
? $item
- : Core\IsEqual::equalTo($item)
- ;
+ : Core\IsEqual::equalTo($item);
}
/**
diff --git a/hamcrest/Hamcrest/Xml/HasXPath.php b/hamcrest/Hamcrest/Xml/HasXPath.php
index bedf9694a..b1c9eeea2 100644
--- a/hamcrest/Hamcrest/Xml/HasXPath.php
+++ b/hamcrest/Hamcrest/Xml/HasXPath.php
@@ -131,7 +131,8 @@ protected function matchesContent(\DOMNodeList $nodes, Description $mismatchDesc
$content[] = $node->textContent;
}
$mismatchDescription->appendText('XPath returned ')
- ->appendValue($content);
+ ->appendValue($content)
+ ;
}
return false;
@@ -152,7 +153,8 @@ protected function matchesExpression($result, Description $mismatchDescription)
return true;
}
$mismatchDescription->appendText('XPath expression result was ')
- ->appendValue($result);
+ ->appendValue($result)
+ ;
} else {
if ($this->_matcher->matches($result)) {
return true;
@@ -167,8 +169,9 @@ protected function matchesExpression($result, Description $mismatchDescription)
public function describeTo(Description $description)
{
$description->appendText('XML or HTML document with XPath "')
- ->appendText($this->_xpath)
- ->appendText('"');
+ ->appendText($this->_xpath)
+ ->appendText('"')
+ ;
if ($this->_matcher !== null) {
$description->appendText(' ');
$this->_matcher->describeTo($description);
diff --git a/tests/Hamcrest/AbstractMatcherTest.php b/tests/Hamcrest/AbstractMatcherTest.php
index 8a1fb2a95..64b8dd8ef 100644
--- a/tests/Hamcrest/AbstractMatcherTest.php
+++ b/tests/Hamcrest/AbstractMatcherTest.php
@@ -3,14 +3,15 @@
use PHPUnit\Framework\TestCase;
-class UnknownType {
+class UnknownType
+{
}
abstract class AbstractMatcherTest extends TestCase
{
- const ARGUMENT_IGNORED = "ignored";
- const ANY_NON_NULL_ARGUMENT = "notnull";
+ public const ARGUMENT_IGNORED = "ignored";
+ public const ANY_NON_NULL_ARGUMENT = "notnull";
abstract protected function createMatcher();
diff --git a/tests/Hamcrest/Array/IsArrayContainingKeyTest.php b/tests/Hamcrest/Array/IsArrayContainingKeyTest.php
index 31770d8dd..1155f6971 100644
--- a/tests/Hamcrest/Array/IsArrayContainingKeyTest.php
+++ b/tests/Hamcrest/Array/IsArrayContainingKeyTest.php
@@ -13,14 +13,14 @@ protected function createMatcher()
public function testMatchesSingleElementArrayContainingKey()
{
- $array = array('a'=>1);
+ $array = array('a' => 1);
$this->assertMatches(hasKey('a'), $array, 'Matches single key');
}
public function testMatchesArrayContainingKey()
{
- $array = array('a'=>1, 'b'=>2, 'c'=>3);
+ $array = array('a' => 1, 'b' => 2, 'c' => 3);
$this->assertMatches(hasKey('a'), $array, 'Matches a');
$this->assertMatches(hasKey('c'), $array, 'Matches c');
@@ -28,14 +28,14 @@ public function testMatchesArrayContainingKey()
public function testMatchesArrayContainingKeyWithIntegerKeys()
{
- $array = array(1=>'A', 2=>'B');
+ $array = array(1 => 'A', 2 => 'B');
assertThat($array, hasKey(1));
}
public function testMatchesArrayContainingKeyWithNumberKeys()
{
- $array = array(1=>'A', 2=>'B');
+ $array = array(1 => 'A', 2 => 'B');
assertThat($array, hasKey(1));
@@ -55,7 +55,7 @@ public function testDoesNotMatchEmptyArray()
public function testDoesNotMatchArrayMissingKey()
{
- $array = array('a'=>1, 'b'=>2, 'c'=>3);
+ $array = array('a' => 1, 'b' => 2, 'c' => 3);
$this->assertMismatchDescription('array was ["a" => <1>, "b" => <2>, "c" => <3>]', hasKey('d'), $array);
}
diff --git a/tests/Hamcrest/Array/IsArrayContainingKeyValuePairTest.php b/tests/Hamcrest/Array/IsArrayContainingKeyValuePairTest.php
index a415f9f7a..c88d250d9 100644
--- a/tests/Hamcrest/Array/IsArrayContainingKeyValuePairTest.php
+++ b/tests/Hamcrest/Array/IsArrayContainingKeyValuePairTest.php
@@ -13,7 +13,7 @@ protected function createMatcher()
public function testMatchesArrayContainingMatchingKeyAndValue()
{
- $array = array('a'=>1, 'b'=>2);
+ $array = array('a' => 1, 'b' => 2);
$this->assertMatches(hasKeyValuePair(equalTo('a'), equalTo(1)), $array, 'matcherA');
$this->assertMatches(hasKeyValuePair(equalTo('b'), equalTo(2)), $array, 'matcherB');
diff --git a/tests/Hamcrest/Array/IsArrayTest.php b/tests/Hamcrest/Array/IsArrayTest.php
index e4db53e79..cba7e8b75 100644
--- a/tests/Hamcrest/Array/IsArrayTest.php
+++ b/tests/Hamcrest/Array/IsArrayTest.php
@@ -72,8 +72,8 @@ public function testHasAReadableMismatchDescriptionWhenKeysDontMatch()
public function testSupportsMatchesAssociativeArrays()
{
$this->assertMatches(
- anArray(array('x'=>equalTo('a'), 'y'=>equalTo('b'), 'z'=>equalTo('c'))),
- array('x'=>'a', 'y'=>'b', 'z'=>'c'),
+ anArray(array('x' => equalTo('a'), 'y' => equalTo('b'), 'z' => equalTo('c'))),
+ array('x' => 'a', 'y' => 'b', 'z' => 'c'),
'should match associative array with matching elements'
);
}
@@ -81,8 +81,8 @@ public function testSupportsMatchesAssociativeArrays()
public function testDoesNotMatchAnAssociativeArrayWhenKeysDoNotMatch()
{
$this->assertDoesNotMatch(
- anArray(array('x'=>equalTo('a'), 'y'=>equalTo('b'))),
- array('x'=>'b', 'z'=>'c'),
+ anArray(array('x' => equalTo('a'), 'y' => equalTo('b'))),
+ array('x' => 'b', 'z' => 'c'),
'should not match array with different keys'
);
}
diff --git a/tests/Hamcrest/StringDescriptionTest.php b/tests/Hamcrest/StringDescriptionTest.php
index b42b9b469..f788e178e 100644
--- a/tests/Hamcrest/StringDescriptionTest.php
+++ b/tests/Hamcrest/StringDescriptionTest.php
@@ -130,7 +130,7 @@ public function testSelfDescribingObjectsCanBeAppended()
$this->_description
->appendDescriptionOf(new \Hamcrest\SampleSelfDescriber('foo'))
->appendDescriptionOf(new \Hamcrest\SampleSelfDescriber('bar'))
- ;
+ ;
$this->assertEquals('foobar', (string) $this->_description);
}
diff --git a/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php b/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php
index 8b4463a9e..082214fa5 100644
--- a/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php
+++ b/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php
@@ -4,7 +4,7 @@
class StringContainsIgnoringCaseTest extends \Hamcrest\AbstractMatcherTest
{
- const EXCERPT = 'ExcErPt';
+ public const EXCERPT = 'ExcErPt';
private $_stringContains;
diff --git a/tests/Hamcrest/Text/StringContainsTest.php b/tests/Hamcrest/Text/StringContainsTest.php
index 814c1ca1b..baa19bfcf 100644
--- a/tests/Hamcrest/Text/StringContainsTest.php
+++ b/tests/Hamcrest/Text/StringContainsTest.php
@@ -4,7 +4,7 @@
class StringContainsTest extends \Hamcrest\AbstractMatcherTest
{
- const EXCERPT = 'EXCERPT';
+ public const EXCERPT = 'EXCERPT';
private $_stringContains;
diff --git a/tests/Hamcrest/Text/StringEndsWithTest.php b/tests/Hamcrest/Text/StringEndsWithTest.php
index 46177f464..aab91f0e7 100644
--- a/tests/Hamcrest/Text/StringEndsWithTest.php
+++ b/tests/Hamcrest/Text/StringEndsWithTest.php
@@ -4,7 +4,7 @@
class StringEndsWithTest extends \Hamcrest\AbstractMatcherTest
{
- const EXCERPT = 'EXCERPT';
+ public const EXCERPT = 'EXCERPT';
private $_stringEndsWith;
diff --git a/tests/Hamcrest/Text/StringStartsWithTest.php b/tests/Hamcrest/Text/StringStartsWithTest.php
index f0eb14b7e..a1a9255f6 100644
--- a/tests/Hamcrest/Text/StringStartsWithTest.php
+++ b/tests/Hamcrest/Text/StringStartsWithTest.php
@@ -4,7 +4,7 @@
class StringStartsWithTest extends \Hamcrest\AbstractMatcherTest
{
- const EXCERPT = 'EXCERPT';
+ public const EXCERPT = 'EXCERPT';
private $_stringStartsWith;
diff --git a/tests/Hamcrest/Type/IsDoubleTest.php b/tests/Hamcrest/Type/IsDoubleTest.php
index 85c2a963c..41c03bd3b 100644
--- a/tests/Hamcrest/Type/IsDoubleTest.php
+++ b/tests/Hamcrest/Type/IsDoubleTest.php
@@ -12,7 +12,7 @@ protected function createMatcher()
public function testEvaluatesToTrueIfArgumentMatchesType()
{
assertThat((float) 5.2, floatValue());
- assertThat((double) 5.3, doubleValue());
+ assertThat((float) 5.3, doubleValue());
}
public function testEvaluatesToFalseIfArgumentDoesntMatchType()
diff --git a/tests/Hamcrest/Type/IsObjectTest.php b/tests/Hamcrest/Type/IsObjectTest.php
index a3b617c20..33e054eec 100644
--- a/tests/Hamcrest/Type/IsObjectTest.php
+++ b/tests/Hamcrest/Type/IsObjectTest.php
@@ -11,7 +11,7 @@ protected function createMatcher()
public function testEvaluatesToTrueIfArgumentMatchesType()
{
- assertThat(new \stdClass, objectValue());
+ assertThat(new \stdClass(), objectValue());
}
public function testEvaluatesToFalseIfArgumentDoesntMatchType()
From f7c0e894d43a4142e53973e3584bbaf13709f064 Mon Sep 17 00:00:00 2001
From: Philipp Scheit