* 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; /** * @internal * * @covers \PhpCsFixer\AbstractFopenFlagFixer * @covers \PhpCsFixer\Fixer\FunctionNotation\FopenFlagsFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\FunctionNotation\FopenFlagsFixer> * * @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\FunctionNotation\FopenFlagsFixer */ final class FopenFlagsFixerTest extends AbstractFixerTestCase { /** * @param _AutogeneratedInputConfiguration $config * * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input = null, array $config = []): void { $this->fixer->configure($config); $this->doTest($expected, $input); } public static function provideFixCases(): iterable { yield 'missing "b"' => [ ' [ ' [ ' [ ' false], ]; yield '"t" and superfluous "b"' => [ ' false], ]; yield 'superfluous "b"' => [ ' false], ]; foreach (self::provideDoNotFixCodeSamples() as $name => $code) { yield $name.' with b_mode' => [$code]; yield $name.' without b_mode' => [$code, null, ['b_mode' => false]]; } } /** * @return iterable */ private static function provideDoNotFixCodeSamples(): iterable { yield 'not simple flags' => ' ' ' ' ' 'fopen($foo, "r+");'; yield 'comments, PHPDoc and literal' => ' ' '