diff --git a/tests/AssertTest.php b/tests/AssertTest.php index d6eea0e6..15527cfa 100644 --- a/tests/AssertTest.php +++ b/tests/AssertTest.php @@ -13,8 +13,8 @@ use ArrayIterator; use ArrayObject; -use Exception; use Error; +use Exception; use LogicException; use RuntimeException; use stdClass; @@ -516,12 +516,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() { 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 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('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), @@ -698,7 +698,7 @@ public function getStringConversions() array('string', array(self::getResource()), 'Expected a string. Got: resource'), array('eq', array('1', '2'), 'Expected a value equal to "2". Got: "1"'), - array('eq', array(new ToStringClass("XXX"), new ToStringClass("YYY")), 'Expected a value equal to Webmozart\Assert\Tests\ToStringClass: "YYY". Got: Webmozart\Assert\Tests\ToStringClass: "XXX"'), + array('eq', array(new ToStringClass('XXX'), new ToStringClass('YYY')), 'Expected a value equal to Webmozart\Assert\Tests\ToStringClass: "YYY". Got: Webmozart\Assert\Tests\ToStringClass: "XXX"'), array('eq', array(1, 2), 'Expected a value equal to 2. Got: 1'), array('eq', array(true, false), 'Expected a value equal to false. Got: true'), array('eq', array(true, null), 'Expected a value equal to null. Got: true'), @@ -732,8 +732,8 @@ public function testAnUnknownMethodThrowsABadMethodCall() /** * @ignore */ -class ToStringClass { - +class ToStringClass +{ /** * @var string */ diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index c48b10d0..07a99c7b 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -20,15 +20,17 @@ class BaseTestCase extends TestCase * @param string $exceptionMessage * @param int $exceptionCode */ - public function setExpectedException($exceptionName, $exceptionMessage = '', $exceptionCode = null) { + public function setExpectedException($exceptionName, $exceptionMessage = '', $exceptionCode = null) + { if (method_exists($this, 'expectException')) { $this->expectException($exceptionName); - if($exceptionMessage) { + if ($exceptionMessage) { $this->expectExceptionMessage($exceptionMessage); } - if( $exceptionCode) { + if ($exceptionCode) { $this->expectExceptionCode($exceptionCode); } + return; } parent::setExpectedException($exceptionName, $exceptionMessage, $exceptionCode); diff --git a/tests/ProjectCodeTest.php b/tests/ProjectCodeTest.php index d7f611c7..822f5d69 100644 --- a/tests/ProjectCodeTest.php +++ b/tests/ProjectCodeTest.php @@ -2,9 +2,9 @@ namespace Webmozart\Assert\Tests; -use Webmozart\Assert\Bin\MixinGenerator; use ReflectionClass; use ReflectionMethod; +use Webmozart\Assert\Bin\MixinGenerator; /** * @coversNothing @@ -20,7 +20,7 @@ class ProjectCodeTest extends BaseTestCase */ public static function doSetUpBeforeClass() { - self::$readmeContent = file_get_contents(__DIR__ . '/../README.md'); + self::$readmeContent = file_get_contents(__DIR__.'/../README.md'); $rc = new ReflectionClass('\Webmozart\Assert\Mixin'); self::$assertDocComment = $rc->getDocComment(); @@ -38,13 +38,14 @@ public static function doSetUpBeforeClass() */ public function testHasNullOr($method) { - $fullMethodName = 'nullOr' . ucfirst($method); + $fullMethodName = 'nullOr'.ucfirst($method); if ($method === 'notNull' || $method === 'null') { $this->addToAssertionCount(1); + return; } - $correct = strpos( (string)self::$assertDocComment,'@method static void ' . $fullMethodName); + $correct = strpos((string) self::$assertDocComment, '@method static void '.$fullMethodName); if (!$correct) { $correct = in_array($fullMethodName, self::$mixinMethodNames, true); } @@ -56,7 +57,7 @@ public function testHasNullOr($method) )); } - $this->addToAssertionCount(1); + $this->addToAssertionCount(1); } /** @@ -66,9 +67,9 @@ public function testHasNullOr($method) */ public function testHasAll($method) { - $fullMethodName = 'all' . ucfirst($method); + $fullMethodName = 'all'.ucfirst($method); - $correct = strpos((string) self::$assertDocComment,'@method static void ' . $fullMethodName); + $correct = strpos((string) self::$assertDocComment, '@method static void '.$fullMethodName); if (!$correct) { $correct = in_array($fullMethodName, self::$mixinMethodNames, true); } @@ -90,9 +91,9 @@ public function testHasAll($method) */ public function testIsInReadme($method) { - $correct = strpos((string) self::$readmeContent,$method); + $correct = strpos((string) self::$readmeContent, $method); - if($correct === false) { + if ($correct === false) { $this->fail(sprintf( 'All methods must be documented in the README.md, please add the "%s" method.', $method @@ -126,7 +127,6 @@ public function testHasThrowsAnnotation($method) $method->getName() ) ); - } /** @@ -138,13 +138,14 @@ public function testHasCorrespondingStaticAnalysisFile($method) { $doc = $method->getDocComment(); - if($doc === false || strpos($doc, '@psalm-assert') === false) { + if ($doc === false || strpos($doc, '@psalm-assert') === false) { $this->addToAssertionCount(1); + return; } $this->assertFileExists( - __DIR__ . '/static-analysis/assert-'. $method->getName() . '.php' + __DIR__.'/static-analysis/assert-'.$method->getName().'.php' ); } @@ -152,14 +153,15 @@ public function testMixinIsUpToDateVersion() { if (version_compare(PHP_VERSION, '7.2.0') < 0) { $this->markTestSkipped('mixin generator is implemented using php 7.2 features'); + return; } - require_once __DIR__ . '/../bin/src/MixinGenerator.php'; + require_once __DIR__.'/../bin/src/MixinGenerator.php'; $generator = new MixinGenerator(); - $actual = file_get_contents(__DIR__ . '/../src/Mixin.php'); + $actual = file_get_contents(__DIR__.'/../src/Mixin.php'); $this->assertEquals($generator->generate(), $actual, 'please regenerate Mixin with `php bin/generate.php` command in the project root'); } @@ -169,7 +171,7 @@ public function testMixinIsUpToDateVersion() */ public function providesMethodNames() { - return array_map(function($value) { + return array_map(function ($value) { return array($value->getName()); }, $this->getMethods()); } @@ -179,7 +181,7 @@ public function providesMethodNames() */ public function provideMethods() { - return array_map(function($value) { + return array_map(function ($value) { return array($value); }, $this->getMethods()); } diff --git a/tests/static-analysis/assert-isNotA.php b/tests/static-analysis/assert-isNotA.php index 5aa2c1f9..f8b9ba29 100644 --- a/tests/static-analysis/assert-isNotA.php +++ b/tests/static-analysis/assert-isNotA.php @@ -2,8 +2,8 @@ namespace Webmozart\Assert\Tests\StaticAnalysis; -use stdClass; use DateTime; +use stdClass; use Webmozart\Assert\Assert; /** diff --git a/tests/static-analysis/assert-keyNotExists.php b/tests/static-analysis/assert-keyNotExists.php index 0edc8fcd..de14f1e9 100644 --- a/tests/static-analysis/assert-keyNotExists.php +++ b/tests/static-analysis/assert-keyNotExists.php @@ -32,7 +32,6 @@ function nullOrKeyNotExists(?array $array, $key): ?array * @psalm-pure * * @param iterable $array - * * @param array-key $key * * @return iterable diff --git a/tests/static-analysis/assert-notEmpty.php b/tests/static-analysis/assert-notEmpty.php index 9bdc12fb..83a4ef57 100644 --- a/tests/static-analysis/assert-notEmpty.php +++ b/tests/static-analysis/assert-notEmpty.php @@ -50,7 +50,6 @@ function notEmptyArray(array $value) return $value; } - /** * @psalm-pure * diff --git a/tests/static-analysis/assert-notInstanceOf.php b/tests/static-analysis/assert-notInstanceOf.php index d5a331b7..0236894f 100644 --- a/tests/static-analysis/assert-notInstanceOf.php +++ b/tests/static-analysis/assert-notInstanceOf.php @@ -2,8 +2,8 @@ namespace Webmozart\Assert\Tests\StaticAnalysis; -use stdClass; use DateTime; +use stdClass; use Webmozart\Assert\Assert; /**