Repository: symplify/symplify (php)

Issue:
[ECS] Some sniffs do not return all errors
In some cases, only partial errors can be detected through sniffing. The simplest case is 10 identical files with less than 10 detected errors.

## Minimal PHP Code Causing Issue
Create 10 files in `src` with the following contents
```php
<?php return [1,2 ];
```

## Configuration
```php
<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;

return static function (ContainerConfigurator $containerConfigurator): void {
    $services = $containerConfigurator->services();
    $services->set(\PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays\ArrayDeclarationSniff::class);
    $parameters = $containerConfigurator->parameters();
    $parameters->set(Option::PATHS, [__DIR__ . '/src']);
};
```

## Command

`vendor/bin/ecs check`


## Output
```
2 errors are fixable! Just add "--fix" to console command and rerun to apply.
```

## Expected Behavior
```
10 errors are fixable! Just add "--fix" to console command and rerun to apply.
```

Pull request description:
[ECS] Improved conflict detection during auto fixing
Reset the `$inConflict` so that changes requested via `\PHP_CodeSniffer\Fixer::replaceToken()` are not rejected.

Fixes #3878 refs https://github.com/squizlabs/PHP_CodeSniffer/commit/2f755565cd9a9b24549802ba57b9112d0b83a369

Patch:
diff --git a/packages/easy-coding-standard/packages/SniffRunner/Application/SniffFileProcessor.php b/packages/easy-coding-standard/packages/SniffRunner/Application/SniffFileProcessor.php
index 37e3e6963..5bb5ed14e 100644
--- a/packages/easy-coding-standard/packages/SniffRunner/Application/SniffFileProcessor.php
+++ b/packages/easy-coding-standard/packages/SniffRunner/Application/SniffFileProcessor.php
@@ -17,6 +17,7 @@ use Symplify\EasyCodingStandard\SniffRunner\ValueObject\Error\CodingStandardErro
 use Symplify\EasyCodingStandard\SniffRunner\ValueObject\File;
 use Symplify\EasyCodingStandard\ValueObject\Configuration;
 use Symplify\EasyCodingStandard\ValueObject\Error\FileDiff;
+use Symplify\PackageBuilder\Reflection\PrivatesAccessor;
 use Symplify\SmartFileSystem\SmartFileInfo;
 use Symplify\SmartFileSystem\SmartFileSystem;
 
@@ -45,6 +46,7 @@ final class SniffFileProcessor implements FileProcessorInterface
         private SniffMetadataCollector $sniffMetadataCollector,
         private SmartFileSystem $smartFileSystem,
         private FileDiffFactory $fileDiffFactory,
+        private PrivatesAccessor $privatesAccessor,
         array $sniffs
     ) {
         $this->addCompatibilityLayer();
@@ -151,6 +153,7 @@ final class SniffFileProcessor implements FileProcessorInterface
             // Only needed once file content has changed.
             $content = $previousContent;
 
+            $this->privatesAccessor->setPrivateProperty($fixer, 'inConflict', false);
             $file->setContent($content);
             $file->processWithTokenListenersAndFileInfo($tokenListeners, $smartFileInfo);
 


Test patch:
diff --git a/packages/easy-coding-standard/tests/Issues/Fixture/fixture3878.php.inc b/packages/easy-coding-standard/tests/Issues/Fixture/fixture3878.php.inc
new file mode 100644
index 000000000..87d999607
--- /dev/null
+++ b/packages/easy-coding-standard/tests/Issues/Fixture/fixture3878.php.inc
@@ -0,0 +1,10 @@
+<?php return [1,2 ];
+
+?>
+-----
+<?php return [
+              1,
+              2,
+             ];
+
+?>
diff --git a/packages/easy-coding-standard/tests/Issues/Issue3878Test.php b/packages/easy-coding-standard/tests/Issues/Issue3878Test.php
new file mode 100644
index 000000000..99d3036dc
--- /dev/null
+++ b/packages/easy-coding-standard/tests/Issues/Issue3878Test.php
@@ -0,0 +1,37 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Symplify\EasyCodingStandard\Tests\Issues;
+
+use Iterator;
+use Symplify\EasyCodingStandard\Testing\PHPUnit\AbstractCheckerTestCase;
+use Symplify\SmartFileSystem\SmartFileInfo;
+
+/**
+ * @see https://github.com/symplify/symplify/issues/3878
+ */
+final class Issue3878Test extends AbstractCheckerTestCase
+{
+    /**
+     * @dataProvider provideData()
+     */
+    public function test(SmartFileInfo $fileInfo): void
+    {
+        $this->doTestFileInfo($fileInfo);
+        $this->doTestFileInfo($fileInfo);
+    }
+
+    /**
+     * @return Iterator<SmartFileInfo[]>
+     */
+    public function provideData(): Iterator
+    {
+        yield [new SmartFileInfo(__DIR__ . '/Fixture/fixture3878.php.inc')];
+    }
+
+    public function provideConfig(): string
+    {
+        return __DIR__ . '/config/config3878.php';
+    }
+}
diff --git a/packages/easy-coding-standard/tests/Issues/config/config3878.php b/packages/easy-coding-standard/tests/Issues/config/config3878.php
new file mode 100644
index 000000000..e0d162e76
--- /dev/null
+++ b/packages/easy-coding-standard/tests/Issues/config/config3878.php
@@ -0,0 +1,11 @@
+<?php
+
+declare(strict_types=1);
+
+use PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays\ArrayDeclarationSniff;
+use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
+
+return static function (ContainerConfigurator $containerConfigurator): void {
+    $services = $containerConfigurator->services();
+    $services->set(ArrayDeclarationSniff::class);
+};