Skip to content

Commit

Permalink
Apply CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyholm committed Jan 18, 2021
1 parent 1eeaf13 commit 69ee43f
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 33 deletions.
20 changes: 10 additions & 10 deletions tests/AssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

use ArrayIterator;
use ArrayObject;
use Exception;
use Error;
use Exception;
use LogicException;
use RuntimeException;
use stdClass;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -732,8 +732,8 @@ public function testAnUnknownMethodThrowsABadMethodCall()
/**
* @ignore
*/
class ToStringClass {

class ToStringClass
{
/**
* @var string
*/
Expand Down
8 changes: 5 additions & 3 deletions tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
34 changes: 18 additions & 16 deletions tests/ProjectCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Webmozart\Assert\Tests;

use Webmozart\Assert\Bin\MixinGenerator;
use ReflectionClass;
use ReflectionMethod;
use Webmozart\Assert\Bin\MixinGenerator;

/**
* @coversNothing
Expand All @@ -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();
Expand All @@ -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);
}
Expand All @@ -56,7 +57,7 @@ public function testHasNullOr($method)
));
}

$this->addToAssertionCount(1);
$this->addToAssertionCount(1);
}

/**
Expand All @@ -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);
}
Expand All @@ -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
Expand Down Expand Up @@ -126,7 +127,6 @@ public function testHasThrowsAnnotation($method)
$method->getName()
)
);

}

/**
Expand All @@ -138,28 +138,30 @@ 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'
);
}

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');
}
Expand All @@ -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());
}
Expand All @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/static-analysis/assert-isNotA.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Webmozart\Assert\Tests\StaticAnalysis;

use stdClass;
use DateTime;
use stdClass;
use Webmozart\Assert\Assert;

/**
Expand Down
1 change: 0 additions & 1 deletion tests/static-analysis/assert-keyNotExists.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function nullOrKeyNotExists(?array $array, $key): ?array
* @psalm-pure
*
* @param iterable<array> $array
*
* @param array-key $key
*
* @return iterable<array>
Expand Down
1 change: 0 additions & 1 deletion tests/static-analysis/assert-notEmpty.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ function notEmptyArray(array $value)
return $value;
}


/**
* @psalm-pure
*
Expand Down
2 changes: 1 addition & 1 deletion tests/static-analysis/assert-notInstanceOf.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Webmozart\Assert\Tests\StaticAnalysis;

use stdClass;
use DateTime;
use stdClass;
use Webmozart\Assert\Assert;

/**
Expand Down

0 comments on commit 69ee43f

Please sign in to comment.