Skip to content

Commit

Permalink
Fix CS/WS issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 5, 2024
1 parent d25bfbe commit 3822cd4
Show file tree
Hide file tree
Showing 77 changed files with 541 additions and 333 deletions.
293 changes: 147 additions & 146 deletions src/Framework/Assert/Functions.php

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/Framework/Constraint/ArrayHasKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use function array_key_exists;
use function is_array;
use ArrayAccess;
use SebastianBergmann\RecursionContext\InvalidArgumentException;

/**
* Constraint that asserts that the array it is evaluated for has a given key.
Expand Down Expand Up @@ -39,7 +40,7 @@ public function __construct($key)
/**
* Returns a string representation of the constraint.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws InvalidArgumentException
*/
public function toString(): string
{
Expand Down Expand Up @@ -73,7 +74,7 @@ protected function matches($other): bool
*
* @param mixed $other evaluated value or object
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws InvalidArgumentException
*/
protected function failureDescription($other): string
{
Expand Down
7 changes: 4 additions & 3 deletions src/Framework/Constraint/ArraySubset.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use ArrayObject;
use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\RecursionContext\InvalidArgumentException;
use Traversable;

/**
Expand Down Expand Up @@ -56,8 +57,8 @@ public function __construct(iterable $subset, bool $strict = false)
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
public function evaluate($other, string $description = '', bool $returnResult = false)
{
Expand Down Expand Up @@ -93,7 +94,7 @@ public function evaluate($other, string $description = '', bool $returnResult =
/**
* Returns a string representation of the constraint.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws InvalidArgumentException
*/
public function toString(): string
{
Expand All @@ -108,7 +109,7 @@ public function toString(): string
*
* @param mixed $other evaluated value or object
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws InvalidArgumentException
*/
protected function failureDescription($other): string
{
Expand Down
6 changes: 4 additions & 2 deletions src/Framework/Constraint/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
namespace PHPUnit\Framework\Constraint;

use PHPUnit\Framework\Assert;
use PHPUnit\Framework\Exception;
use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\RecursionContext\InvalidArgumentException;

/**
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338
Expand Down Expand Up @@ -41,9 +43,9 @@ public function __construct(Constraint $constraint, string $attributeName)
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @throws \PHPUnit\Framework\Exception
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws Exception
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
public function evaluate($other, string $description = '', bool $returnResult = false)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Framework/Constraint/Composite.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use function count;
use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\RecursionContext\InvalidArgumentException;

/**
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338
Expand Down Expand Up @@ -39,8 +40,8 @@ public function __construct(Constraint $innerConstraint)
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
public function evaluate($other, string $description = '', bool $returnResult = false)
{
Expand Down
7 changes: 4 additions & 3 deletions src/Framework/Constraint/Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use PHPUnit\Framework\SelfDescribing;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\Exporter\Exporter;
use SebastianBergmann\RecursionContext\InvalidArgumentException;

/**
* Abstract base class for constraints which can be applied to any value.
Expand All @@ -36,8 +37,8 @@ abstract class Constraint implements Countable, SelfDescribing
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
public function evaluate($other, string $description = '', bool $returnResult = false)
{
Expand Down Expand Up @@ -94,8 +95,8 @@ protected function matches($other): bool
* @param mixed $other evaluated value or object
* @param string $description Additional information about the test
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*
* @psalm-return never-return
*/
Expand Down Expand Up @@ -146,7 +147,7 @@ protected function additionalFailureDescription($other): string
*
* @param mixed $other evaluated value or object
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws InvalidArgumentException
*/
protected function failureDescription($other): string
{
Expand Down
3 changes: 2 additions & 1 deletion src/Framework/Constraint/ExceptionCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace PHPUnit\Framework\Constraint;

use function sprintf;
use SebastianBergmann\RecursionContext\InvalidArgumentException;
use Throwable;

final class ExceptionCode extends Constraint
Expand Down Expand Up @@ -51,7 +52,7 @@ protected function matches($other): bool
*
* @param mixed $other evaluated value or object
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws InvalidArgumentException
*/
protected function failureDescription($other): string
{
Expand Down
4 changes: 3 additions & 1 deletion src/Framework/Constraint/GreaterThan.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*/
namespace PHPUnit\Framework\Constraint;

use SebastianBergmann\RecursionContext\InvalidArgumentException;

/**
* Constraint that asserts that the value it is evaluated for is greater
* than a given value.
Expand All @@ -31,7 +33,7 @@ public function __construct($value)
/**
* Returns a string representation of the constraint.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws InvalidArgumentException
*/
public function toString(): string
{
Expand Down
3 changes: 2 additions & 1 deletion src/Framework/Constraint/IsEqual.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\Comparator\Factory as ComparatorFactory;
use SebastianBergmann\RecursionContext\InvalidArgumentException;

/**
* Constraint that checks if one value is equal to another.
Expand Down Expand Up @@ -109,7 +110,7 @@ public function evaluate($other, string $description = '', bool $returnResult =
/**
* Returns a string representation of the constraint.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws InvalidArgumentException
*/
public function toString(): string
{
Expand Down
7 changes: 4 additions & 3 deletions src/Framework/Constraint/IsIdentical.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use function sprintf;
use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\RecursionContext\InvalidArgumentException;

/**
* Constraint that asserts that one value is identical to another.
Expand Down Expand Up @@ -50,8 +51,8 @@ public function __construct($value)
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
public function evaluate($other, string $description = '', bool $returnResult = false)
{
Expand Down Expand Up @@ -91,7 +92,7 @@ public function evaluate($other, string $description = '', bool $returnResult =
/**
* Returns a string representation of the constraint.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws InvalidArgumentException
*/
public function toString(): string
{
Expand All @@ -111,7 +112,7 @@ public function toString(): string
*
* @param mixed $other evaluated value or object
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws InvalidArgumentException
*/
protected function failureDescription($other): string
{
Expand Down
3 changes: 2 additions & 1 deletion src/Framework/Constraint/IsInstanceOf.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use function sprintf;
use ReflectionClass;
use ReflectionException;
use SebastianBergmann\RecursionContext\InvalidArgumentException;

/**
* Constraint that asserts that the object it is evaluated for is an instance
Expand Down Expand Up @@ -62,7 +63,7 @@ protected function matches($other): bool
*
* @param mixed $other evaluated value or object
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws InvalidArgumentException
*/
protected function failureDescription($other): string
{
Expand Down
4 changes: 3 additions & 1 deletion src/Framework/Constraint/IsJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
namespace PHPUnit\Framework\Constraint;

use function json_decode;

use function json_last_error;
use function sprintf;
use SebastianBergmann\RecursionContext\InvalidArgumentException;

/**
* Constraint that asserts that a string is valid JSON.
Expand Down Expand Up @@ -55,7 +57,7 @@ protected function matches($other): bool
*
* @param mixed $other evaluated value or object
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws InvalidArgumentException
*/
protected function failureDescription($other): string
{
Expand Down
5 changes: 3 additions & 2 deletions src/Framework/Constraint/IsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use function is_scalar;
use function is_string;
use function sprintf;
use PHPUnit\Framework\Exception;
use TypeError;

/**
Expand Down Expand Up @@ -120,12 +121,12 @@ final class IsType extends Constraint
private $type;

/**
* @throws \PHPUnit\Framework\Exception
* @throws Exception
*/
public function __construct(string $type)
{
if (!isset(self::KNOWN_TYPES[$type])) {
throw new \PHPUnit\Framework\Exception(
throw new Exception(
sprintf(
'Type specified for PHPUnit\Framework\Constraint\IsType <%s> ' .
'is not a valid type.',
Expand Down
6 changes: 4 additions & 2 deletions src/Framework/Constraint/JsonMatches.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@

use function json_decode;
use function sprintf;
use PHPUnit\Framework\Exception;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Util\Json;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\RecursionContext\InvalidArgumentException;

/**
* Asserts whether or not two JSON objects are equal.
Expand Down Expand Up @@ -72,9 +74,9 @@ protected function matches($other): bool
* @param mixed $other evaluated value or object
* @param string $description Additional information about the test
*
* @throws \PHPUnit\Framework\Exception
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws Exception
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*
* @psalm-return never-return
*/
Expand Down
4 changes: 3 additions & 1 deletion src/Framework/Constraint/LessThan.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*/
namespace PHPUnit\Framework\Constraint;

use SebastianBergmann\RecursionContext\InvalidArgumentException;

/**
* Constraint that asserts that the value it is evaluated for is less than
* a given value.
Expand All @@ -31,7 +33,7 @@ public function __construct($value)
/**
* Returns a string representation of the constraint.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws InvalidArgumentException
*/
public function toString(): string
{
Expand Down
8 changes: 5 additions & 3 deletions src/Framework/Constraint/LogicalAnd.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

use function array_values;
use function count;
use PHPUnit\Framework\Exception;
use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\RecursionContext\InvalidArgumentException;

/**
* Logical AND.
Expand All @@ -35,15 +37,15 @@ public static function fromConstraints(Constraint ...$constraints): self
/**
* @param Constraint[] $constraints
*
* @throws \PHPUnit\Framework\Exception
* @throws Exception
*/
public function setConstraints(array $constraints): void
{
$this->constraints = [];

foreach ($constraints as $constraint) {
if (!($constraint instanceof Constraint)) {
throw new \PHPUnit\Framework\Exception(
throw new Exception(
'All parameters to ' . __CLASS__ .
' must be a constraint object.'
);
Expand All @@ -63,8 +65,8 @@ public function setConstraints(array $constraints): void
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
public function evaluate($other, string $description = '', bool $returnResult = false)
{
Expand Down
5 changes: 3 additions & 2 deletions src/Framework/Constraint/LogicalNot.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use function preg_match;
use function str_replace;
use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\RecursionContext\InvalidArgumentException;

/**
* Logical NOT.
Expand Down Expand Up @@ -100,8 +101,8 @@ public function __construct($constraint)
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
public function evaluate($other, string $description = '', bool $returnResult = false)
{
Expand Down Expand Up @@ -150,7 +151,7 @@ public function count(): int
*
* @param mixed $other evaluated value or object
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws InvalidArgumentException
*/
protected function failureDescription($other): string
{
Expand Down
Loading

0 comments on commit 3822cd4

Please sign in to comment.