123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- declare(strict_types=1);
- /*
- * This file is part of PHP CS Fixer.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- * Dariusz Rumiński <dariusz.ruminski@gmail.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- namespace PhpCsFixer\Tests\Fixer\Casing;
- use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
- /**
- * @internal
- *
- * @covers \PhpCsFixer\Fixer\Casing\IntegerLiteralCaseFixer
- *
- * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Casing\IntegerLiteralCaseFixer>
- */
- final class IntegerLiteralCaseFixerTest extends AbstractFixerTestCase
- {
- /**
- * @dataProvider provideFixCases
- */
- public function testFix(string $expected, ?string $input = null): void
- {
- $this->doTest($expected, $input);
- }
- /**
- * @return iterable<int|string, array{0: string, 1?: string}>
- */
- public static function provideFixCases(): iterable
- {
- yield [
- '<?php $foo1 = 0xFF; $foo2 = 0xDEFA; $foo3 = 0xFA; $foo4 = 0xFA;',
- '<?php $foo1 = 0XFF; $foo2 = 0xdefa; $foo3 = 0Xfa; $foo4 = 0xFA;',
- ];
- yield [
- '<?php $foo = 0xA1FB20;',
- '<?php $foo = 0xa1fb20;',
- ];
- yield [
- '<?php $foo = -0xA1FB20;',
- '<?php $foo = -0xa1fb20;',
- ];
- yield [
- '<?php $foo = 0b1101;',
- '<?php $foo = 0B1101;',
- ];
- yield [
- '<?php $A = 1_234_567;',
- ];
- yield [
- '<?php $A = +0xAA_FF_00;',
- '<?php $A = +0Xaa_ff_00;',
- ];
- yield [
- '<?php $A = -0x00_AA_FF_00;',
- '<?php $A = -0X00_aa_ff_00;',
- ];
- yield 'bin_PHP_INT_MAX' => [
- '<?php $foo = 0b111111111111111111111111111111111111111111111111111111111111111;',
- '<?php $foo = 0B111111111111111111111111111111111111111111111111111111111111111;',
- ];
- yield 'hex_plus_PHP_INT_MAX' => [
- '<?php $foo = +0x7FFFFFFFFFFFFFFF;',
- '<?php $foo = +0X7fffffffffffffff;',
- ];
- yield 'hex_minus_PHP_INT_MAX' => [
- '<?php $foo = -0x7FFFFFFFFFFFFFFF;',
- '<?php $foo = -0X7fffffffffffffff;',
- ];
- }
- /**
- * @dataProvider provideFix81Cases
- *
- * @requires PHP 8.1
- */
- public function testFix81(string $expected, ?string $input = null): void
- {
- $this->doTest($expected, $input);
- }
- /**
- * @return iterable<array{string, string}>
- */
- public static function provideFix81Cases(): iterable
- {
- yield [
- '<?php $foo = 0o123;',
- '<?php $foo = 0O123;',
- ];
- yield [
- '<?php $foo = -0o123;',
- '<?php $foo = -0O123;',
- ];
- }
- }
|