[BUGFIX] Respect indent_size for tabs (#81)

- Do not take tab_width into account. This is interpreted by the editor program
This commit is contained in:
Sebastian Schreiber 2021-05-20 16:26:08 +02:00 committed by GitHub
parent 9fd252d8ae
commit b5c00cbf1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 8 additions and 14 deletions

View File

@ -48,7 +48,7 @@ final class JsonFileFormatterTest extends AbstractTestCase
$file = new File($inputFileInfo, $inputFileInfo->getContents());
$editorConfigConfigurationBuilder = new EditorConfigConfigurationBuilder();
$editorConfigConfigurationBuilder->withIndent(Indent::createTabWithSize(1));
$editorConfigConfigurationBuilder->withIndent(Indent::createTab());
$this->jsonFileFormatter->format($file, $editorConfigConfigurationBuilder->build());

View File

@ -48,7 +48,7 @@ final class XmlFileFormatterTest extends AbstractTestCase
$file = new File($inputFileInfo, $inputFileInfo->getContents());
$editorConfigConfigurationBuilder = new EditorConfigConfigurationBuilder();
$editorConfigConfigurationBuilder->withIndent(Indent::createTabWithSize(1));
$editorConfigConfigurationBuilder->withIndent(Indent::createTab());
$this->xmlFileFormatter->format($file, $editorConfigConfigurationBuilder->build());

View File

@ -30,11 +30,11 @@ final class EditorConfigConfigurationTest extends TestCase
public function testIndentForTab(): void
{
$editorConfigConfigurationBuilder = new EditorConfigConfigurationBuilder();
$editorConfigConfigurationBuilder->withIndent(Indent::createTabWithSize(4));
$editorConfigConfigurationBuilder->withIndent(Indent::createTab());
$editorConfigConfiguration = $editorConfigConfigurationBuilder->build();
$this->assertSame(' ', $editorConfigConfiguration->getIndent());
$this->assertSame(' ', $editorConfigConfiguration->getIndent());
}
public function testIndentForSpace(): void

View File

@ -37,7 +37,7 @@ final class IndentTest extends TestCase
public function testFromSizeAndStyleWithInvalidSizeThrowsException(): void
{
$this->expectException(InvalidIndentSizeException::class);
Indent::createTabWithSize(0);
Indent::fromSizeAndStyle(0, 'invalid');
}
public function testFromSizeAndStyleWithInvalidStyleThrowsException(): void

View File

@ -51,12 +51,6 @@ final class EditorConfigParser
$editorConfigConfigurationBuilder->withInsertFinalNewline($insertFinalNewline);
}
if (array_key_exists(EditorConfigOption::TAB_WIDTH, $configuration)) {
$editorConfigConfigurationBuilder->withIndentSize(
$configuration[EditorConfigOption::TAB_WIDTH]->getValue()
);
}
return $editorConfigConfigurationBuilder->build();
}
}

View File

@ -65,7 +65,7 @@ final class XmlFileFormatter implements FileFormatterInterface
{
$editorConfigConfigurationBuilder = new EditorConfigConfigurationBuilder();
$editorConfigConfigurationBuilder->withIndent(Indent::createTabWithSize(1));
$editorConfigConfigurationBuilder->withIndent(Indent::createTab());
return $editorConfigConfigurationBuilder;
}

View File

@ -75,9 +75,9 @@ final class Indent
return self::fromSizeAndStyle($size, self::SPACE);
}
public static function createTabWithSize(int $size): self
public static function createTab(): self
{
return self::fromSizeAndStyle($size, self::TAB);
return self::fromSizeAndStyle(1, self::TAB);
}
public static function fromSizeAndStyle(int $size, string $style): self