diff --git a/.dev-tools/src/Readme/ReadmeCommand.php b/.dev-tools/src/Readme/ReadmeCommand.php index be8f4f3a..e6048e1d 100644 --- a/.dev-tools/src/Readme/ReadmeCommand.php +++ b/.dev-tools/src/Readme/ReadmeCommand.php @@ -15,7 +15,6 @@ use PhpCsFixer\Fixer\DeprecatedFixerInterface; use PhpCsFixer\Fixer\WhitespacesAwareFixerInterface; use PhpCsFixer\FixerDefinition\CodeSampleInterface; -use PhpCsFixer\StdinFileInfo; use PhpCsFixer\Tokenizer\Tokens; use PhpCsFixer\Utils; use PhpCsFixer\WhitespacesFixerConfig; @@ -236,7 +235,7 @@ private function fixers(): string $fixer->configure($codeSample->getConfiguration() ?? []); } $tokens = Tokens::fromCode($originalCode); - $fixer->fix(new StdinFileInfo(), $tokens); + $fixer->fix($this->createSplFileInfoDouble(), $tokens); $fixedCode = $tokens->generateCode(); $output .= \sprintf( @@ -268,6 +267,21 @@ private function diff(string $from, string $to): string return \substr($diff, $start + 1, -1); } + private function createSplFileInfoDouble(): \SplFileInfo + { + return new class (\getcwd() . '/file.php') extends \SplFileInfo { + public function __construct(string $filename) + { + parent::__construct($filename); + } + + public function getRealPath(): string + { + return $this->getPathname(); + } + }; + } + private function contributing(): string { return \sprintf( diff --git a/tests/Fixer/AbstractFixerTestCase.php b/tests/Fixer/AbstractFixerTestCase.php index a4a7c3a6..ea29ae3c 100644 --- a/tests/Fixer/AbstractFixerTestCase.php +++ b/tests/Fixer/AbstractFixerTestCase.php @@ -250,6 +250,16 @@ final protected function assertSuccessorName(string $successorName): void private function createSplFileInfoDouble(): \SplFileInfo { - return new class ('') extends \SplFileInfo {}; + return new class (\getcwd() . '/src/file.php') extends \SplFileInfo { + public function __construct(string $filename) + { + parent::__construct($filename); + } + + public function getRealPath(): string + { + return $this->getPathname(); + } + }; } }