Skip to content

Commit

Permalink
Closes #3288
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Nov 19, 2018
1 parent 66c0a54 commit f5e5add
Show file tree
Hide file tree
Showing 20 changed files with 45 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .php_cs.dist
Expand Up @@ -184,7 +184,7 @@ return PhpCsFixer\Config::create()
'property',
],
],
//'void_return' => true,
'void_return' => true,
'whitespace_after_comma_in_array' => true,
]
)
Expand Down
4 changes: 4 additions & 0 deletions ChangeLog-8.0.md
Expand Up @@ -4,6 +4,10 @@ All notable changes of the PHPUnit 8.0 release series are documented in this fil

## [8.0.0] - 2019-02-01

### Changed

* Implemented [#3288](https://github.com/sebastianbergmann/phpunit/issues/3288): The `void_return` fixer of php-cs-fixer is now in effect

### Removed

* Implemented [#2762](https://github.com/sebastianbergmann/phpunit/issues/2762): Drop support for PHP 7.1
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/MockObject/Matcher/StatelessInvocation.php
Expand Up @@ -33,7 +33,7 @@ abstract class StatelessInvocation implements Invocation
*
* @param BaseInvocation $invocation Object containing information on a mocked or stubbed method which was invoked
*/
public function invoked(BaseInvocation $invocation)
public function invoked(BaseInvocation $invocation): void
{
}

Expand Down
16 changes: 8 additions & 8 deletions src/Framework/TestCase.php
Expand Up @@ -390,28 +390,28 @@ public function __construct($name = null, array $data = [], $dataName = '')
/**
* This method is called before the first test of this test class is run.
*/
public static function setUpBeforeClass()/* The :void return type declaration that should be here would cause a BC issue */
public static function setUpBeforeClass(): void
{
}

/**
* This method is called after the last test of this test class is run.
*/
public static function tearDownAfterClass()/* The :void return type declaration that should be here would cause a BC issue */
public static function tearDownAfterClass(): void
{
}

/**
* This method is called before each test.
*/
protected function setUp()/* The :void return type declaration that should be here would cause a BC issue */
protected function setUp(): void
{
}

/**
* This method is called after each test.
*/
protected function tearDown()/* The :void return type declaration that should be here would cause a BC issue */
protected function tearDown(): void
{
}

Expand Down Expand Up @@ -614,7 +614,7 @@ public function expectExceptionObject(\Exception $exception): void
$this->expectExceptionCode($exception->getCode());
}

public function expectNotToPerformAssertions()
public function expectNotToPerformAssertions(): void
{
$this->doesNotPerformAssertions = true;
}
Expand Down Expand Up @@ -1567,7 +1567,7 @@ protected function createResult(): TestResult
*
* This method is called between setUp() and test.
*/
protected function assertPreConditions()/* The :void return type declaration that should be here would cause a BC issue */
protected function assertPreConditions(): void
{
}

Expand All @@ -1576,7 +1576,7 @@ protected function assertPreConditions()/* The :void return type declaration tha
*
* This method is called between test and tearDown().
*/
protected function assertPostConditions()/* The :void return type declaration that should be here would cause a BC issue */
protected function assertPostConditions(): void
{
}

Expand All @@ -1585,7 +1585,7 @@ protected function assertPostConditions()/* The :void return type declaration th
*
* @throws Throwable
*/
protected function onNotSuccessfulTest(Throwable $t)/* The :void return type declaration that should be here would cause a BC issue */
protected function onNotSuccessfulTest(Throwable $t): void
{
throw $t;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/_files/ClassThatImplementsSerializable.php
Expand Up @@ -14,7 +14,7 @@ public function serialize()
return \get_object_vars($this);
}

public function unserialize($serialized)
public function unserialize($serialized): void
{
foreach (\unserialize($serialized) as $key => $value) {
$this->{$key} = $value;
Expand Down
2 changes: 1 addition & 1 deletion tests/_files/ClassWithAllPossibleReturnTypes.php
Expand Up @@ -9,7 +9,7 @@
*/
class ClassWithAllPossibleReturnTypes
{
public function methodWithNoReturnTypeDeclaration()
public function methodWithNoReturnTypeDeclaration(): void
{
}

Expand Down
2 changes: 1 addition & 1 deletion tests/_files/ClassWithSelfTypeHint.php
Expand Up @@ -9,7 +9,7 @@
*/
class ClassWithSelfTypeHint
{
public function foo(self $foo)
public function foo(self $foo): void
{
}
}
2 changes: 1 addition & 1 deletion tests/_files/ClassWithStaticMethod.php
Expand Up @@ -9,7 +9,7 @@
*/
class ClassWithStaticMethod
{
public static function staticMethod()
public static function staticMethod(): void
{
}
}
8 changes: 4 additions & 4 deletions tests/_files/DataproviderExecutionOrderTest.php
Expand Up @@ -11,28 +11,28 @@

class DataproviderExecutionOrderTest extends TestCase
{
public function testFirstTestThatAlwaysWorks()
public function testFirstTestThatAlwaysWorks(): void
{
$this->assertTrue(true);
}

/**
* @dataProvider dataproviderAdditions
*/
public function testAddNumbersWithADataprovider(int $a, int $b, int $sum)
public function testAddNumbersWithADataprovider(int $a, int $b, int $sum): void
{
$this->assertSame($sum, $a + $b);
}

public function testTestInTheMiddleThatAlwaysWorks()
public function testTestInTheMiddleThatAlwaysWorks(): void
{
$this->assertTrue(true);
}

/**
* @dataProvider dataproviderAdditions
*/
public function testAddMoreNumbersWithADataprovider(int $a, int $b, int $sum)
public function testAddMoreNumbersWithADataprovider(int $a, int $b, int $sum): void
{
$this->assertSame($sum, $a + $b);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/_files/MethodCallbackByReference.php
Expand Up @@ -9,12 +9,12 @@
*/
class MethodCallbackByReference
{
public function bar(&$a, &$b, $c)
public function bar(&$a, &$b, $c): void
{
Legacy::bar($a, $b, $c);
}

public function callback(&$a, &$b, $c)
public function callback(&$a, &$b, $c): void
{
$b = 1;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/_files/MultiDependencyTest.php
Expand Up @@ -38,12 +38,12 @@ public function testThree($a, $b): void
/**
* @depends MultiDependencyTest::testThree
*/
public function testFour()
public function testFour(): void
{
$this->assertTrue(true);
}

public function testFive()
public function testFive(): void
{
$this->assertTrue(true);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/_files/PartialMockTestClass.php
Expand Up @@ -16,11 +16,11 @@ public function __construct()
$this->constructorCalled = true;
}

public function doSomething()
public function doSomething(): void
{
}

public function doAnotherThing()
public function doAnotherThing(): void
{
}
}
8 changes: 4 additions & 4 deletions tests/_files/SingletonClass.php
Expand Up @@ -9,27 +9,27 @@
*/
class SingletonClass
{
public static function getInstance()
public static function getInstance(): void
{
}

protected function __construct()
{
}

private function __sleep()
private function __sleep(): void
{
}

private function __wakeup()
private function __wakeup(): void
{
}

private function __clone()
{
}

public function doSomething()
public function doSomething(): void
{
}
}
2 changes: 2 additions & 0 deletions tests/_files/SomeClass.php
Expand Up @@ -11,9 +11,11 @@ class SomeClass
{
public function doSomething($a, $b)
{
return 'something';
}

public function doSomethingElse($c)
{
return 'something else';
}
}
2 changes: 1 addition & 1 deletion tests/_files/StaticMockTestClass.php
Expand Up @@ -9,7 +9,7 @@
*/
class StaticMockTestClass
{
public static function doSomething()
public static function doSomething(): void
{
}

Expand Down
6 changes: 3 additions & 3 deletions tests/_files/StopOnErrorTestSuite.php
Expand Up @@ -10,19 +10,19 @@

class StopOnErrorTestSuite extends \PHPUnit\Framework\TestCase
{
public function testIncomplete()
public function testIncomplete(): void
{
$this->markTestIncomplete();
}

public function testWithError()
public function testWithError(): void
{
$this->assertTrue(true);

throw new Error('StopOnErrorTestSuite_error');
}

public function testThatIsNeverReached()
public function testThatIsNeverReached(): void
{
$this->assertTrue(true);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/regression/GitHub/3093/Issue3093Test.php
Expand Up @@ -23,7 +23,7 @@ public function testFirstWithoutDependencies(): void
* @depends testFirstWithoutDependencies
* @dataProvider someDataProvider
*/
public function testSecondThatDependsOnFirstAndDataprovider($value)
public function testSecondThatDependsOnFirstAndDataprovider($value): void
{
self::assertTrue(true);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Framework/AssertTest.php
Expand Up @@ -2660,7 +2660,7 @@ public function testScalarTypeCanBeAsserted(): void

public function testCallableTypeCanBeAsserted(): void
{
$this->assertIsCallable(function () {
$this->assertIsCallable(function (): void {
});

try {
Expand Down Expand Up @@ -2807,7 +2807,7 @@ public function testNotCallableTypeCanBeAsserted(): void
$this->assertIsNotCallable(null);

try {
$this->assertIsNotCallable(function () {
$this->assertIsNotCallable(function (): void {
});
} catch (AssertionFailedError $e) {
return;
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Framework/MockObject/GeneratorTest.php
Expand Up @@ -211,7 +211,7 @@ public function testMockingOfThrowable(): void
$this->assertInstanceOf(MockObject::class, $stub);
}

public function testVariadicArgumentsArePassedToOriginalMethod()
public function testVariadicArgumentsArePassedToOriginalMethod(): void
{
/** @var ClassWithVariadicArgumentMethod|MockObject $mock */
$mock = $this->generator->getMock(
Expand All @@ -230,7 +230,7 @@ public function testVariadicArgumentsArePassedToOriginalMethod()
$this->assertSame($arguments, $mock->foo(...$arguments));
}

public function testVariadicArgumentsArePassedToMockedMethod()
public function testVariadicArgumentsArePassedToMockedMethod(): void
{
/** @var ClassWithVariadicArgumentMethod|MockObject $mock */
$mock = $this->createMock(ClassWithVariadicArgumentMethod::class);
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Framework/MockObject/MockMethodTest.php
Expand Up @@ -14,7 +14,7 @@

class MockMethodTest extends TestCase
{
public function testGetNameReturnsMethodName()
public function testGetNameReturnsMethodName(): void
{
$method = new MockMethod(
'ClassName',
Expand All @@ -33,7 +33,7 @@ public function testGetNameReturnsMethodName()
$this->assertEquals('methodName', $method->getName());
}

public function testFailWhenReturnTypeIsParentButThereIsNoParentClass()
public function testFailWhenReturnTypeIsParentButThereIsNoParentClass(): void
{
$method = new MockMethod(
\stdClass::class,
Expand Down

0 comments on commit f5e5add

Please sign in to comment.