Skip to content

Commit

Permalink
Run php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowhand committed Oct 16, 2024
1 parent eceaa83 commit 8be8250
Show file tree
Hide file tree
Showing 18 changed files with 937 additions and 744 deletions.
109 changes: 81 additions & 28 deletions src/Assert.php

Large diffs are not rendered by default.

1,294 changes: 728 additions & 566 deletions src/Mixin.php

Large diffs are not rendered by default.

71 changes: 32 additions & 39 deletions tests/AssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@

namespace Webmozart\Assert\Tests;

use ArrayIterator;
use ArrayObject;
use Error;
use Exception;
use LogicException;
use PHPUnit\Framework\TestCase;
use RuntimeException;
use stdClass;
use Webmozart\Assert\Assert;

/**
Expand Down Expand Up @@ -107,9 +100,9 @@ public function getTests()
array('scalar', array(true), true),
array('scalar', array(null), false),
array('scalar', array(array()), false),
array('scalar', array(new stdClass()), false),
array('object', array(new stdClass()), true),
array('object', array(new RuntimeException()), true),
array('scalar', array(new \stdClass()), false),
array('object', array(new \stdClass()), true),
array('object', array(new \RuntimeException()), true),
array('object', array(null), false),
array('object', array(true), false),
array('object', array(1), false),
Expand All @@ -125,43 +118,43 @@ public function getTests()
array('isCallable', array('foobar'), false),
array('isArray', array(array()), true),
array('isArray', array(array(1, 2, 3)), true),
array('isArray', array(new ArrayIterator(array())), false),
array('isArray', array(new \ArrayIterator(array())), false),
array('isArray', array(123), false),
array('isArray', array(new stdClass()), false),
array('isArray', array(new \stdClass()), false),
array('isTraversable', array(array()), true),
array('isTraversable', array(array(1, 2, 3)), true),
array('isTraversable', array(new ArrayIterator(array())), true),
array('isTraversable', array(new \ArrayIterator(array())), true),
array('isTraversable', array(123), false),
array('isTraversable', array(new stdClass()), false),
array('isTraversable', array(new \stdClass()), false),
array('isArrayAccessible', array(array()), true),
array('isArrayAccessible', array(array(1, 2, 3)), true),
array('isArrayAccessible', array(new ArrayObject(array())), true),
array('isArrayAccessible', array(new \ArrayObject(array())), true),
array('isArrayAccessible', array(123), false),
array('isArrayAccessible', array(new stdClass()), false),
array('isArrayAccessible', array(new \stdClass()), false),
array('isCountable', array(array()), true),
array('isCountable', array(array(1, 2)), true),
array('isCountable', array(new ArrayIterator(array())), true),
array('isCountable', array(new stdClass()), false),
array('isCountable', array(new \ArrayIterator(array())), true),
array('isCountable', array(new \stdClass()), false),
array('isCountable', array(new \SimpleXMLElement('<foo>bar</foo>')), true),
array('isCountable', array('abcd'), false),
array('isCountable', array(123), false),
array('isIterable', array(array()), true),
array('isIterable', array(array(1, 2, 3)), true),
array('isIterable', array(new ArrayIterator(array())), true),
array('isIterable', array(new \ArrayIterator(array())), true),
array('isIterable', array(123), false),
array('isIterable', array(new stdClass()), false),
array('isInstanceOf', array(new stdClass(), 'stdClass'), true),
array('isInstanceOf', array(new Exception(), 'stdClass'), false),
array('isIterable', array(new \stdClass()), false),
array('isInstanceOf', array(new \stdClass(), 'stdClass'), true),
array('isInstanceOf', array(new \Exception(), 'stdClass'), false),
array('isInstanceOf', array(123, 'stdClass'), false),
array('isInstanceOf', array(array(), 'stdClass'), false),
array('isInstanceOf', array(null, 'stdClass'), false),
array('notInstanceOf', array(new stdClass(), 'stdClass'), false),
array('notInstanceOf', array(new Exception(), 'stdClass'), true),
array('notInstanceOf', array(new \stdClass(), 'stdClass'), false),
array('notInstanceOf', array(new \Exception(), 'stdClass'), true),
array('notInstanceOf', array(123, 'stdClass'), true),
array('notInstanceOf', array(array(), 'stdClass'), true),
array('isInstanceOfAny', array(new ArrayIterator(), array('Iterator', 'ArrayAccess')), true),
array('isInstanceOfAny', array(new Exception(), array('Exception', 'Countable')), true),
array('isInstanceOfAny', array(new Exception(), array('ArrayAccess', 'Countable')), false),
array('isInstanceOfAny', array(new \ArrayIterator(), array('Iterator', 'ArrayAccess')), true),
array('isInstanceOfAny', array(new \Exception(), array('Exception', 'Countable')), true),
array('isInstanceOfAny', array(new \Exception(), array('ArrayAccess', 'Countable')), false),
array('isInstanceOfAny', array(123, array('stdClass')), false),
array('isInstanceOfAny', array(array(), array('stdClass')), false),
array('isAOf', array('stdClass', 'stdClass'), true),
Expand Down Expand Up @@ -452,16 +445,16 @@ public function getTests()
array('propertyNotExists', array((object) array('property' => null), 'property'), false),
array('propertyNotExists', array((object) array('property' => null), 'foo'), true),
array('methodExists', array('RuntimeException', 'getMessage'), true),
array('methodExists', array(new RuntimeException(), 'getMessage'), true),
array('methodExists', array(new \RuntimeException(), 'getMessage'), true),
array('methodExists', array('stdClass', 'getMessage'), false),
array('methodExists', array(new stdClass(), 'getMessage'), false),
array('methodExists', array(new \stdClass(), 'getMessage'), false),
array('methodExists', array(null, 'getMessage'), false),
array('methodExists', array(true, 'getMessage'), false),
array('methodExists', array(1, 'getMessage'), false),
array('methodNotExists', array('RuntimeException', 'getMessage'), false),
array('methodNotExists', array(new RuntimeException(), 'getMessage'), false),
array('methodNotExists', array(new \RuntimeException(), 'getMessage'), false),
array('methodNotExists', array('stdClass', 'getMessage'), true),
array('methodNotExists', array(new stdClass(), 'getMessage'), true),
array('methodNotExists', array(new \stdClass(), 'getMessage'), true),
array('methodNotExists', array(null, 'getMessage'), true),
array('methodNotExists', array(true, 'getMessage'), true),
array('methodNotExists', array(1, 'getMessage'), true),
Expand All @@ -475,7 +468,7 @@ public function getTests()
array('validArrayKey', array(1), true),
array('validArrayKey', array(false), false),
array('validArrayKey', array(true), false),
array('validArrayKey', array(new stdClass()), false),
array('validArrayKey', array(new \stdClass()), false),
array('validArrayKey', array(new ToStringClass('testString')), false),
array('validArrayKey', array(self::getResource()), false),
array('count', array(array(0, 1, 2), 3), true),
Expand Down Expand Up @@ -535,12 +528,12 @@ public function getTests()
array('uuid', array('ff6f8cb0-c57da-51e1-9b21-0800200c9a66'), false),
array('uuid', array('af6f8cb-c57d-11e1-9b21-0800200c9a66'), false),
array('uuid', array('3f6f8cb0-c57d-11e1-9b21-0800200c9a6'), false),
array('throws', array(function () { throw new LogicException('test'); }, 'LogicException'), true),
array('throws', array(function () { throw new LogicException('test'); }, 'IllogicException'), false),
array('throws', array(function () { throw new Exception('test'); }), true),
array('throws', array(function () { throw new \LogicException('test'); }, 'LogicException'), true),
array('throws', array(function () { throw new \LogicException('test'); }, 'IllogicException'), false),
array('throws', array(function () { throw new \Exception('test'); }), true),
array('throws', array(function () { trigger_error('test'); }, 'Throwable'), true, false, 70000),
array('throws', array(function () { trigger_error('test'); }, 'Unthrowable'), false, false, 70000),
array('throws', array(function () { throw new Error(); }, 'Throwable'), true, true, 70000),
array('throws', array(function () { throw new \Error(); }, 'Throwable'), true, true, 70000),
array('ip', array('192.168.0.1'), true),
array('ip', array(new ToStringClass('192.168.0.1')), true),
array('ip', array('255.255.255.255'), true),
Expand Down Expand Up @@ -731,7 +724,7 @@ public function testAllTraversable($method, $args, $success, $multibyte = false,
}

$arg = array_shift($args);
array_unshift($args, new ArrayIterator(array($arg)));
array_unshift($args, new \ArrayIterator(array($arg)));

call_user_func_array(array('Webmozart\Assert\Assert', 'all'.ucfirst($method)), $args);
$this->addToAssertionCount(1);
Expand All @@ -745,7 +738,7 @@ public function getStringConversions()
array('string', array(true), 'Expected a string. Got: boolean'),
array('string', array(null), 'Expected a string. Got: NULL'),
array('string', array(array()), 'Expected a string. Got: array'),
array('string', array(new stdClass()), 'Expected a string. Got: stdClass'),
array('string', array(new \stdClass()), 'Expected a string. Got: stdClass'),
array('string', array(self::getResource()), 'Expected a string. Got: resource'),

array('eq', array('1', '2'), 'Expected a value equal to "2". Got: "1"'),
Expand All @@ -755,7 +748,7 @@ public function getStringConversions()
array('eq', array(true, null), 'Expected a value equal to null. Got: true'),
array('eq', array(null, true), 'Expected a value equal to true. Got: null'),
array('eq', array(array(1), array(2)), 'Expected a value equal to array. Got: array'),
array('eq', array(new ArrayIterator(array()), new stdClass()), 'Expected a value equal to stdClass. Got: ArrayIterator'),
array('eq', array(new \ArrayIterator(array()), new \stdClass()), 'Expected a value equal to stdClass. Got: ArrayIterator'),
array('eq', array(1, self::getResource()), 'Expected a value equal to resource. Got: 1'),

array('lessThan', array(new \DateTime('2020-01-01 00:00:00+00:00'), new \DateTime('1999-01-01 00:00:00+00:00')), 'Expected a value less than DateTime: "1999-01-01T00:00:00+00:00". Got: DateTime: "2020-01-01T00:00:00+00:00"'),
Expand Down
12 changes: 5 additions & 7 deletions tests/ProjectCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Webmozart\Assert\Tests;

use PHPUnit\Framework\TestCase;
use ReflectionClass;
use ReflectionMethod;
use Webmozart\Assert\Bin\MixinGenerator;

/**
Expand All @@ -23,7 +21,7 @@ public static function doSetUpBeforeClass()
{
self::$readmeContent = file_get_contents(__DIR__.'/../README.md');

$rc = new ReflectionClass('\Webmozart\Assert\Mixin');
$rc = new \ReflectionClass('\Webmozart\Assert\Mixin');
self::$assertDocComment = $rc->getDocComment();

self::$mixinMethodNames = array();
Expand Down Expand Up @@ -106,7 +104,7 @@ public function testIsInReadme($method)
/**
* @dataProvider provideMethods
*
* @param ReflectionMethod $method
* @param \ReflectionMethod $method
*/
public function testHasThrowsAnnotation($method)
{
Expand All @@ -133,7 +131,7 @@ public function testHasThrowsAnnotation($method)
/**
* @dataProvider provideMethods
*
* @param ReflectionMethod $method
* @param \ReflectionMethod $method
*/
public function testHasCorrespondingStaticAnalysisFile($method)
{
Expand Down Expand Up @@ -198,10 +196,10 @@ private function getMethods()
return $methods;
}

$rc = new ReflectionClass('\Webmozart\Assert\Assert');
$rc = new \ReflectionClass('\Webmozart\Assert\Assert');
$methods = array();

$rcMethods = $rc->getMethods(ReflectionMethod::IS_PUBLIC);
$rcMethods = $rc->getMethods(\ReflectionMethod::IS_PUBLIC);

foreach ($rcMethods as $rcMethod) {
if ($rcMethod->getFileName() !== $rc->getFileName()) {
Expand Down
17 changes: 8 additions & 9 deletions tests/static-analysis/assert-count.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace Webmozart\Assert\Tests\StaticAnalysis;

use Countable;
use Webmozart\Assert\Assert;

/**
* @param Countable|array $value
* @param \Countable|array $value
*
* @return Countable|array
* @return \Countable|array
*/
function count($value, int $number)
{
Expand All @@ -18,9 +17,9 @@ function count($value, int $number)
}

/**
* @param null|Countable|array $value
* @param null|\Countable|array $value
*
* @return null|Countable|array
* @return null|\Countable|array
*/
function nullOrCount($value, int $number)
{
Expand All @@ -30,9 +29,9 @@ function nullOrCount($value, int $number)
}

/**
* @param iterable<Countable|array> $value
* @param iterable<\Countable|array> $value
*
* @return iterable<Countable|array>
* @return iterable<\Countable|array>
*/
function allCount(iterable $value, int $number): iterable
{
Expand All @@ -42,9 +41,9 @@ function allCount(iterable $value, int $number): iterable
}

/**
* @param iterable<Countable|array|null> $value
* @param iterable<\Countable|array|null> $value
*
* @return iterable<Countable|array|null>
* @return iterable<\Countable|array|null>
*/
function allNullOrCount(iterable $value, int $number): iterable
{
Expand Down
17 changes: 8 additions & 9 deletions tests/static-analysis/assert-countBetween.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

namespace Webmozart\Assert\Tests\StaticAnalysis;

use Countable;
use Webmozart\Assert\Assert;

/**
* @param Countable|array $value
* @param \Countable|array $value
* @param int|float $min
* @param int|float $max
*
* @return Countable|array
* @return \Countable|array
*/
function countBetween($value, $min, $max)
{
Expand All @@ -20,11 +19,11 @@ function countBetween($value, $min, $max)
}

/**
* @param null|Countable|array $value
* @param null|\Countable|array $value
* @param int|float $min
* @param int|float $max
*
* @return null|Countable|array
* @return null|\Countable|array
*/
function nullOrCountBetween($value, $min, $max)
{
Expand All @@ -34,11 +33,11 @@ function nullOrCountBetween($value, $min, $max)
}

/**
* @param iterable<Countable|array> $value
* @param iterable<\Countable|array> $value
* @param int|float $min
* @param int|float $max
*
* @return iterable<Countable|array>
* @return iterable<\Countable|array>
*/
function allCountBetween(iterable $value, $min, $max): iterable
{
Expand All @@ -48,11 +47,11 @@ function allCountBetween(iterable $value, $min, $max): iterable
}

/**
* @param iterable<Countable|array|null> $value
* @param iterable<\Countable|array|null> $value
* @param int|float $min
* @param int|float $max
*
* @return iterable<Countable|array|null>
* @return iterable<\Countable|array|null>
*/
function allNullOrCountBetween(iterable $value, $min, $max): iterable
{
Expand Down
17 changes: 8 additions & 9 deletions tests/static-analysis/assert-implementsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@

namespace Webmozart\Assert\Tests\StaticAnalysis;

use Serializable;
use Webmozart\Assert\Assert;

/**
* @psalm-pure
*
* @param mixed $value
*
* @return class-string<Serializable>
* @return class-string<\Serializable>
*/
function implementsInterface($value): string
{
Assert::implementsInterface($value, Serializable::class);
Assert::implementsInterface($value, \Serializable::class);

return $value;
}
Expand All @@ -24,11 +23,11 @@ function implementsInterface($value): string
*
* @param mixed $value
*
* @return null|class-string<Serializable>
* @return null|class-string<\Serializable>
*/
function nullOrImplementsInterface($value): ?string
{
Assert::nullOrImplementsInterface($value, Serializable::class);
Assert::nullOrImplementsInterface($value, \Serializable::class);

return $value;
}
Expand All @@ -38,11 +37,11 @@ function nullOrImplementsInterface($value): ?string
*
* @param mixed $value
*
* @return iterable<class-string<Serializable>>
* @return iterable<class-string<\Serializable>>
*/
function allImplementsInterface($value): iterable
{
Assert::allImplementsInterface($value, Serializable::class);
Assert::allImplementsInterface($value, \Serializable::class);

return $value;
}
Expand All @@ -52,11 +51,11 @@ function allImplementsInterface($value): iterable
*
* @param mixed $value
*
* @return iterable<class-string<Serializable>|null>
* @return iterable<class-string<\Serializable>|null>
*/
function allNullOrImplementsInterface($value): iterable
{
Assert::allNullOrImplementsInterface($value, Serializable::class);
Assert::allNullOrImplementsInterface($value, \Serializable::class);

return $value;
}
Loading

0 comments on commit 8be8250

Please sign in to comment.