Skip to content

Commit 6058a83

Browse files
authored
Dev cleanup (#1031)
1 parent 2df54fe commit 6058a83

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

.dev-tools/src/Readme/ReadmeCommand.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use PhpCsFixer\Fixer\DeprecatedFixerInterface;
1616
use PhpCsFixer\Fixer\WhitespacesAwareFixerInterface;
1717
use PhpCsFixer\FixerDefinition\CodeSampleInterface;
18-
use PhpCsFixer\StdinFileInfo;
1918
use PhpCsFixer\Tokenizer\Tokens;
2019
use PhpCsFixer\Utils;
2120
use PhpCsFixer\WhitespacesFixerConfig;
@@ -236,7 +235,7 @@ private function fixers(): string
236235
$fixer->configure($codeSample->getConfiguration() ?? []);
237236
}
238237
$tokens = Tokens::fromCode($originalCode);
239-
$fixer->fix(new StdinFileInfo(), $tokens);
238+
$fixer->fix($this->createSplFileInfoDouble(), $tokens);
240239
$fixedCode = $tokens->generateCode();
241240

242241
$output .= \sprintf(
@@ -268,6 +267,21 @@ private function diff(string $from, string $to): string
268267
return \substr($diff, $start + 1, -1);
269268
}
270269

270+
private function createSplFileInfoDouble(): \SplFileInfo
271+
{
272+
return new class (\getcwd() . '/file.php') extends \SplFileInfo {
273+
public function __construct(string $filename)
274+
{
275+
parent::__construct($filename);
276+
}
277+
278+
public function getRealPath(): string
279+
{
280+
return $this->getPathname();
281+
}
282+
};
283+
}
284+
271285
private function contributing(): string
272286
{
273287
return \sprintf(

tests/Fixer/AbstractFixerTestCase.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,16 @@ final protected function assertSuccessorName(string $successorName): void
250250

251251
private function createSplFileInfoDouble(): \SplFileInfo
252252
{
253-
return new class ('') extends \SplFileInfo {};
253+
return new class (\getcwd() . '/src/file.php') extends \SplFileInfo {
254+
public function __construct(string $filename)
255+
{
256+
parent::__construct($filename);
257+
}
258+
259+
public function getRealPath(): string
260+
{
261+
return $this->getPathname();
262+
}
263+
};
254264
}
255265
}

0 commit comments

Comments
 (0)