diff --git a/.gitignore b/.gitignore
index 7611d841f..664d419cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
composer.lock
tests/.phpunit.result.cache
vendor
+/.php-cs-fixer.cache
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
new file mode 100644
index 000000000..c5635b0d4
--- /dev/null
+++ b/.php-cs-fixer.dist.php
@@ -0,0 +1,38 @@
+in(__DIR__.'/hamcrest')
+ ->in(__DIR__.'/generator')
+ ->in(__DIR__.'/tests')
+ ->notPath('Matchers.php')
+ ->notPath('Hamcrest.php')
+ ->name('*.php')
+;
+
+return (new PhpCsFixer\Config())
+ ->setRules([
+ // Use PSR-12 as base but disable the cosmetic rules
+ '@PSR12' => true,
+
+ // namespace should come directly after the opening tag
+ 'blank_line_after_opening_tag' => false,
+ 'linebreak_after_opening_tag' => true,
+ 'blank_lines_before_namespace' => ['min_line_breaks' => 1, 'max_line_breaks' => 1],
+
+ // add semicolons to the last lines of chained calls
+ 'multiline_whitespace_before_semicolons' => ['strategy' => 'new_line_for_chained_calls'],
+ 'method_chaining_indentation' => true,
+
+ // parentheses on new expressions when there are no arguments
+ 'new_with_parentheses' => ['named_class' => true, 'anonymous_class' => true],
+
+ // use consistent naming for boolean, bool, integer, int, etc
+ 'phpdoc_scalar' => true,
+
+ // allow a new line after the class opening
+ 'no_blank_lines_after_class_opening' => false,
+
+ ])
+ ->setFinder($finder)
+ ->setRiskyAllowed(false)
+;
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 5df55df9f..badb4e872 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -12,11 +12,18 @@ Feel free to ask any questions and share your experiences in the [Issue tracking
1. Create your feature addition or a bug fix branch based on __`master`__ branch in your repository's fork.
2. Make necessary changes, but __don't mix__ code reformatting with code changes on topic.
3. Add tests for those changes (please look into `tests/` folder for some examples). This is important so we don't break it in a future version unintentionally.
-4. Check your code using "Coding Standard" (see below).
+4. Fix your code style by using the "Coding Standard" (see below).
5. Commit your code.
6. Squash your commits by topic to preserve a clean and readable log.
7. Create Pull Request.
+## Coding Standard
+
+To keep a consice coding standard in the repository, run:
+```bash
+vendor/bin/php-cs-fixer fix
+```
+
## Running the Tests
### Installation/Configuration
diff --git a/composer.json b/composer.json
index ddffd1939..a86827ba0 100644
--- a/composer.json
+++ b/composer.json
@@ -20,7 +20,8 @@
"require-dev": {
"phpunit/php-file-iterator": "^1.4 || ^2.0 || ^3.0",
- "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0 || ^8.0 || ^9.0"
+ "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0 || ^8.0 || ^9.0",
+ "friendsofphp/php-cs-fixer": "^3.75"
},
"replace": {
diff --git a/generator/FactoryCall.php b/generator/FactoryCall.php
index 83965b2ae..31986262f 100644
--- a/generator/FactoryCall.php
+++ b/generator/FactoryCall.php
@@ -11,7 +11,7 @@ class FactoryCall
*
* @var string
*/
- const INDENT = ' ';
+ public const INDENT = ' ';
/**
* @var FactoryMethod
diff --git a/generator/FactoryFile.php b/generator/FactoryFile.php
index dd6109b1f..55a3fbe71 100644
--- a/generator/FactoryFile.php
+++ b/generator/FactoryFile.php
@@ -11,7 +11,7 @@ abstract class FactoryFile
*
* @var string
*/
- const INDENT = ' ';
+ public const INDENT = ' ';
private $indent;
diff --git a/generator/GlobalFunctionFile.php b/generator/GlobalFunctionFile.php
index ec8b1b392..ce86824cb 100644
--- a/generator/GlobalFunctionFile.php
+++ b/generator/GlobalFunctionFile.php
@@ -34,8 +34,8 @@ public function build()
public function generateFactoryCall(FactoryCall $call)
{
$code = "if (!function_exists('{$call->getName()}')) {\n";
- $code.= parent::generateFactoryCall($call);
- $code.= "}\n";
+ $code .= parent::generateFactoryCall($call);
+ $code .= "}\n";
return $code;
}
diff --git a/hamcrest/Hamcrest/Arrays/IsArray.php b/hamcrest/Hamcrest/Arrays/IsArray.php
index 9ea569703..0827332f7 100644
--- a/hamcrest/Hamcrest/Arrays/IsArray.php
+++ b/hamcrest/Hamcrest/Arrays/IsArray.php
@@ -55,13 +55,13 @@ protected function describeMismatchSafely($actual, Description $mismatchDescript
return;
} elseif (array_keys($actual) != array_keys($this->_elementMatchers)) {
$mismatchDescription->appendText('array keys were ')
- ->appendValueList(
- $this->descriptionStart(),
- $this->descriptionSeparator(),
- $this->descriptionEnd(),
- array_keys($actual)
- )
- ;
+ ->appendValueList(
+ $this->descriptionStart(),
+ $this->descriptionSeparator(),
+ $this->descriptionEnd(),
+ array_keys($actual)
+ )
+ ;
return;
}
@@ -70,7 +70,8 @@ protected function describeMismatchSafely($actual, Description $mismatchDescript
foreach ($this->_elementMatchers as $k => $matcher) {
if (!$matcher->matches($actual[$k])) {
$mismatchDescription->appendText('element ')->appendValue($k)
- ->appendText(' was ')->appendValue($actual[$k]);
+ ->appendText(' was ')->appendValue($actual[$k])
+ ;
return;
}
diff --git a/hamcrest/Hamcrest/Arrays/IsArrayContaining.php b/hamcrest/Hamcrest/Arrays/IsArrayContaining.php
index 0e4a1eda9..8b6895782 100644
--- a/hamcrest/Hamcrest/Arrays/IsArrayContaining.php
+++ b/hamcrest/Hamcrest/Arrays/IsArrayContaining.php
@@ -43,8 +43,8 @@ protected function describeMismatchSafely($array, Description $mismatchDescripti
public function describeTo(Description $description)
{
$description
- ->appendText('an array containing ')
- ->appendDescriptionOf($this->_elementMatcher)
+ ->appendText('an array containing ')
+ ->appendDescriptionOf($this->_elementMatcher)
;
}
diff --git a/hamcrest/Hamcrest/Arrays/IsArrayContainingInAnyOrder.php b/hamcrest/Hamcrest/Arrays/IsArrayContainingInAnyOrder.php
index 9009026b8..8ac0c27bb 100644
--- a/hamcrest/Hamcrest/Arrays/IsArrayContainingInAnyOrder.php
+++ b/hamcrest/Hamcrest/Arrays/IsArrayContainingInAnyOrder.php
@@ -41,8 +41,8 @@ protected function matchesSafelyWithDiagnosticDescription($array, Description $m
public function describeTo(Description $description)
{
$description->appendList('[', ', ', ']', $this->_elementMatchers)
- ->appendText(' in any order')
- ;
+ ->appendText(' in any order')
+ ;
}
/**
diff --git a/hamcrest/Hamcrest/Arrays/IsArrayContainingKey.php b/hamcrest/Hamcrest/Arrays/IsArrayContainingKey.php
index 523477e7b..23ab6e6a0 100644
--- a/hamcrest/Hamcrest/Arrays/IsArrayContainingKey.php
+++ b/hamcrest/Hamcrest/Arrays/IsArrayContainingKey.php
@@ -39,8 +39,8 @@ protected function describeMismatchSafely($array, Description $mismatchDescripti
{
//Not using appendValueList() so that keys can be shown
$mismatchDescription->appendText('array was ')
- ->appendText('[')
- ;
+ ->appendText('[')
+ ;
$loop = false;
foreach ($array as $key => $value) {
if ($loop) {
@@ -55,9 +55,9 @@ protected function describeMismatchSafely($array, Description $mismatchDescripti
public function describeTo(Description $description)
{
$description
- ->appendText('array with key ')
- ->appendDescriptionOf($this->_keyMatcher)
- ;
+ ->appendText('array with key ')
+ ->appendDescriptionOf($this->_keyMatcher)
+ ;
}
/**
diff --git a/hamcrest/Hamcrest/Arrays/IsArrayContainingKeyValuePair.php b/hamcrest/Hamcrest/Arrays/IsArrayContainingKeyValuePair.php
index 9ac3eba80..e6e0af2d4 100644
--- a/hamcrest/Hamcrest/Arrays/IsArrayContainingKeyValuePair.php
+++ b/hamcrest/Hamcrest/Arrays/IsArrayContainingKeyValuePair.php
@@ -42,8 +42,8 @@ protected function describeMismatchSafely($array, Description $mismatchDescripti
{
//Not using appendValueList() so that keys can be shown
$mismatchDescription->appendText('array was ')
- ->appendText('[')
- ;
+ ->appendText('[')
+ ;
$loop = false;
foreach ($array as $key => $value) {
if ($loop) {
@@ -58,11 +58,11 @@ protected function describeMismatchSafely($array, Description $mismatchDescripti
public function describeTo(Description $description)
{
$description->appendText('array containing [')
- ->appendDescriptionOf($this->_keyMatcher)
- ->appendText(' => ')
- ->appendDescriptionOf($this->_valueMatcher)
- ->appendText(']')
- ;
+ ->appendDescriptionOf($this->_keyMatcher)
+ ->appendText(' => ')
+ ->appendDescriptionOf($this->_valueMatcher)
+ ->appendText(']')
+ ;
}
/**
diff --git a/hamcrest/Hamcrest/Arrays/MatchingOnce.php b/hamcrest/Hamcrest/Arrays/MatchingOnce.php
index 324c7e089..c515e9113 100644
--- a/hamcrest/Hamcrest/Arrays/MatchingOnce.php
+++ b/hamcrest/Hamcrest/Arrays/MatchingOnce.php
@@ -31,9 +31,9 @@ public function isFinished($items)
}
$this->_mismatchDescription
- ->appendText('No item matches: ')->appendList('', ', ', '', $this->_elementMatchers)
- ->appendText(' in ')->appendValueList('[', ', ', ']', $items)
- ;
+ ->appendText('No item matches: ')->appendList('', ', ', '', $this->_elementMatchers)
+ ->appendText(' in ')->appendValueList('[', ', ', ']', $items)
+ ;
return false;
}
@@ -53,7 +53,7 @@ private function _isNotSurplus($item)
private function _isMatched($item)
{
- /** @var $matcher \Hamcrest\Matcher */
+ /** @var $matcher \Hamcrest\Matcher */
foreach ($this->_elementMatchers as $i => $matcher) {
if ($matcher->matches($item)) {
unset($this->_elementMatchers[$i]);
diff --git a/hamcrest/Hamcrest/Collection/IsEmptyTraversable.php b/hamcrest/Hamcrest/Collection/IsEmptyTraversable.php
index 8ab58ea5a..90a172bbf 100644
--- a/hamcrest/Hamcrest/Collection/IsEmptyTraversable.php
+++ b/hamcrest/Hamcrest/Collection/IsEmptyTraversable.php
@@ -49,7 +49,7 @@ public function describeTo(Description $description)
public static function emptyTraversable()
{
if (!self::$_INSTANCE) {
- self::$_INSTANCE = new self;
+ self::$_INSTANCE = new self();
}
return self::$_INSTANCE;
diff --git a/hamcrest/Hamcrest/Core/DescribedAs.php b/hamcrest/Hamcrest/Core/DescribedAs.php
index 5b2583fa7..b22c31c72 100644
--- a/hamcrest/Hamcrest/Core/DescribedAs.php
+++ b/hamcrest/Hamcrest/Core/DescribedAs.php
@@ -18,7 +18,7 @@ class DescribedAs extends BaseMatcher
private $_matcher;
private $_values;
- const ARG_PATTERN = '/%([0-9]+)/';
+ public const ARG_PATTERN = '/%([0-9]+)/';
public function __construct($descriptionTemplate, Matcher $matcher, array $values)
{
diff --git a/hamcrest/Hamcrest/Core/IsCollectionContaining.php b/hamcrest/Hamcrest/Core/IsCollectionContaining.php
index 5e60426d1..71eab0b0d 100644
--- a/hamcrest/Hamcrest/Core/IsCollectionContaining.php
+++ b/hamcrest/Hamcrest/Core/IsCollectionContaining.php
@@ -43,9 +43,9 @@ protected function describeMismatchSafely($items, Description $mismatchDescripti
public function describeTo(Description $description)
{
$description
- ->appendText('a collection containing ')
- ->appendDescriptionOf($this->_elementMatcher)
- ;
+ ->appendText('a collection containing ')
+ ->appendDescriptionOf($this->_elementMatcher)
+ ;
}
/**
diff --git a/hamcrest/Hamcrest/Core/IsInstanceOf.php b/hamcrest/Hamcrest/Core/IsInstanceOf.php
index 7a5c92a6b..ba419fbaa 100644
--- a/hamcrest/Hamcrest/Core/IsInstanceOf.php
+++ b/hamcrest/Hamcrest/Core/IsInstanceOf.php
@@ -37,7 +37,8 @@ protected function matchesWithDiagnosticDescription($item, Description $mismatch
if (!($item instanceof $this->_theClass)) {
$mismatchDescription->appendText('[' . get_class($item) . '] ')
- ->appendValue($item);
+ ->appendValue($item)
+ ;
return false;
}
@@ -48,8 +49,8 @@ protected function matchesWithDiagnosticDescription($item, Description $mismatch
public function describeTo(Description $description)
{
$description->appendText('an instance of ')
- ->appendText($this->_theClass)
- ;
+ ->appendText($this->_theClass)
+ ;
}
/**
diff --git a/hamcrest/Hamcrest/Core/IsSame.php b/hamcrest/Hamcrest/Core/IsSame.php
index 810787050..94432eddd 100644
--- a/hamcrest/Hamcrest/Core/IsSame.php
+++ b/hamcrest/Hamcrest/Core/IsSame.php
@@ -29,9 +29,9 @@ public function matches($object)
public function describeTo(Description $description)
{
$description->appendText('sameInstance(')
- ->appendValue($this->_object)
- ->appendText(')')
- ;
+ ->appendValue($this->_object)
+ ->appendText(')')
+ ;
}
/**
diff --git a/hamcrest/Hamcrest/Core/IsTypeOf.php b/hamcrest/Hamcrest/Core/IsTypeOf.php
index d24f0f94c..7092c0643 100644
--- a/hamcrest/Hamcrest/Core/IsTypeOf.php
+++ b/hamcrest/Hamcrest/Core/IsTypeOf.php
@@ -42,10 +42,10 @@ public function describeMismatch($item, Description $description)
$description->appendText('was null');
} else {
$description->appendText('was ')
- ->appendText(self::getTypeDescription(strtolower(gettype($item))))
- ->appendText(' ')
- ->appendValue($item)
- ;
+ ->appendText(self::getTypeDescription(strtolower(gettype($item))))
+ ->appendText(' ')
+ ->appendValue($item)
+ ;
}
}
diff --git a/hamcrest/Hamcrest/FeatureMatcher.php b/hamcrest/Hamcrest/FeatureMatcher.php
index 59f6cc734..1a12bdb80 100644
--- a/hamcrest/Hamcrest/FeatureMatcher.php
+++ b/hamcrest/Hamcrest/FeatureMatcher.php
@@ -50,7 +50,8 @@ public function matchesSafelyWithDiagnosticDescription($actual, Description $mis
if (!$this->_subMatcher->matches($featureValue)) {
$mismatchDescription->appendText($this->_featureName)
- ->appendText(' was ')->appendValue($featureValue);
+ ->appendText(' was ')->appendValue($featureValue)
+ ;
return false;
}
@@ -61,7 +62,7 @@ public function matchesSafelyWithDiagnosticDescription($actual, Description $mis
final public function describeTo(Description $description)
{
$description->appendText($this->_featureDescription)->appendText(' ')
- ->appendDescriptionOf($this->_subMatcher)
- ;
+ ->appendDescriptionOf($this->_subMatcher)
+ ;
}
}
diff --git a/hamcrest/Hamcrest/Matcher.php b/hamcrest/Hamcrest/Matcher.php
index e5dcf0939..10b6d8f38 100644
--- a/hamcrest/Hamcrest/Matcher.php
+++ b/hamcrest/Hamcrest/Matcher.php
@@ -28,23 +28,23 @@ interface Matcher extends SelfDescribing
*
* @param mixed $item the object against which the matcher is evaluated.
*
- * @return boolean 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/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()