* Dariusz RumiƄski * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer\Tests\Fixer\FunctionNotation; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; use PhpCsFixer\Tokenizer\Tokens; /** * @author Mark Nielsen * * @internal * * @covers \PhpCsFixer\Fixer\FunctionNotation\VoidReturnFixer */ final class VoidReturnFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } public static function provideFixCases(): iterable { yield [' null;', ]; yield [ ' 1;', ]; yield [ ' var_dump($a);', ]; } /** * @dataProvider provideFix80Cases * * @requires PHP 8.0 */ public function testFix80(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } /** * @return iterable> */ public static function provideFix80Cases(): iterable { yield [ ' sprintf('$x%d', $n), array_keys(array_fill(0, $arguments, true)), )) )); $this->fixer->fix(self::getTestFile(), $tokens); self::assertNull($this->lintSource($tokens->generateCode())); } public static function provideMethodWillNotCauseSyntaxErrorCases(): iterable { // List: https://www.php.net/manual/en/language.oop5.magic.php yield ['__construct']; yield ['__destruct']; yield ['__call', 2]; yield ['__callStatic', 2, true]; yield ['__get', 1]; yield ['__set', 2]; yield ['__isset', 1]; yield ['__unset', 1]; yield ['__sleep']; yield ['__wakeup']; yield ['__serialize']; yield ['__unserialize', 1]; yield ['__toString']; yield ['__invoke']; yield ['__set_state', 1, true]; yield ['__clone']; yield ['__debugInfo']; } }