123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?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\Operator;
- use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
- /**
- * @covers \PhpCsFixer\Fixer\Operator\NoSpaceAroundDoubleColonFixer
- *
- * @internal
- *
- * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Operator\NoSpaceAroundDoubleColonFixer>
- */
- final class NoSpaceAroundDoubleColonFixerTest extends AbstractFixerTestCase
- {
- /**
- * @dataProvider provideFixCases
- */
- public function testFix(string $expected, string $input): void
- {
- $this->doTest($expected, $input);
- }
- /**
- * @return iterable<array{string, string}>
- */
- public static function provideFixCases(): iterable
- {
- yield [
- '<?php echo self::$a;',
- '<?php echo self :: $a;',
- ];
- yield [
- '<?php echo static::$a;',
- '<?php echo static ::$a;',
- ];
- yield [
- '<?php
- echo F\B::class;
- echo A\B:: /**/ c;
- echo C\B/**/::c;
- ',
- '<?php
- echo F\B:: class;
- echo A\B :: /**/ c;
- echo C\B/**/:: c;
- ',
- ];
- yield [
- '<?php
- namespace {
- class Foo { public const a = 1; }
- echo Foo::a; // Fix
- echo "\n".Place\Bar::$a."\n"; // Fix
- }
- namespace Somewhere\Over\The\Rainbow {
- class Bar {
- public static $a = "BAR-A:: ";
- public function v(?string $z = "zzz"): void
- {
- echo "\n".self::$a.$z; // Fix
- echo "\n".static::class; // Fix
- echo "\n".static # do ...
- :: # ... not ...
- $a.$z; // ... fix
- }
- }
- $bar = new Bar();
- $bar->v();
- }
- # ; echo A :: B;
- // ; echo A :: B;
- /* ; echo A :: B; */
- ',
- '<?php
- namespace {
- class Foo { public const a = 1; }
- echo Foo:: a; // Fix
- echo "\n".Place\Bar :: $a."\n"; // Fix
- }
- namespace Somewhere\Over\The\Rainbow {
- class Bar {
- public static $a = "BAR-A:: ";
- public function v(?string $z = "zzz"): void
- {
- echo "\n".self :: $a.$z; // Fix
- echo "\n".static :: class; // Fix
- echo "\n".static # do ...
- :: # ... not ...
- $a.$z; // ... fix
- }
- }
- $bar = new Bar();
- $bar->v();
- }
- # ; echo A :: B;
- // ; echo A :: B;
- /* ; echo A :: B; */
- ',
- ];
- }
- }
|