Updated Rector to commit 37df55a2fd

37df55a2fd [DX] Remove non-PHP file formatting based on editorconfig, rather let external coding standard tools handle the file format (#2378)
This commit is contained in:
Tomas Votruba 2022-05-27 16:47:28 +00:00
parent 72da510fdc
commit b748edb1e3
89 changed files with 67 additions and 8507 deletions

View File

@ -6,9 +6,6 @@ namespace RectorPrefix20220527;
use RectorPrefix20220527\Composer\Semver\VersionParser;
use RectorPrefix20220527\Doctrine\Inflector\Inflector;
use RectorPrefix20220527\Doctrine\Inflector\Rules\English\InflectorFactory;
use RectorPrefix20220527\Ergebnis\Json\Printer\Printer;
use RectorPrefix20220527\Ergebnis\Json\Printer\PrinterInterface;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfig;
use RectorPrefix20220527\OndraM\CiDetector\CiDetector;
use PhpParser\BuilderFactory;
use PhpParser\Lexer;
@ -139,7 +136,4 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services->set(\PHPStan\Analyser\ScopeFactory::class)->factory([\RectorPrefix20220527\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createScopeFactory']);
$services->set(\PHPStan\PhpDoc\TypeNodeResolver::class)->factory([\RectorPrefix20220527\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createTypeNodeResolver']);
$services->set(\Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider::class)->factory([\RectorPrefix20220527\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createDynamicSourceLocatorProvider']);
$services->set(\RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfig::class);
$services->set(\RectorPrefix20220527\Ergebnis\Json\Printer\Printer::class);
$services->alias(\RectorPrefix20220527\Ergebnis\Json\Printer\PrinterInterface::class, \RectorPrefix20220527\Ergebnis\Json\Printer\Printer::class);
};

View File

@ -1,12 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\FileFormatter\Contract\Formatter;
use Rector\Core\ValueObject\Application\File;
use Rector\FileFormatter\ValueObject\EditorConfigConfiguration;
interface FileFormatterInterface
{
public function supports(\Rector\Core\ValueObject\Application\File $file) : bool;
public function format(\Rector\Core\ValueObject\Application\File $file, \Rector\FileFormatter\ValueObject\EditorConfigConfiguration $editorConfigConfiguration) : void;
}

View File

@ -1,49 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\FileFormatter\EditorConfig;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Declaration;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfig;
use Rector\Core\ValueObject\Application\File;
use Rector\FileFormatter\ValueObject\EditorConfigConfiguration;
use Rector\FileFormatter\ValueObject\EditorConfigOption;
use Rector\FileFormatter\ValueObjectFactory\EditorConfigConfigurationBuilder;
/**
* @see \Rector\Tests\FileFormatter\EditorConfig\EditorConfigParser\EditorConfigParserTest
*/
final class EditorConfigParser
{
/**
* @readonly
* @var \Idiosyncratic\EditorConfig\EditorConfig
*/
private $editorConfig;
public function __construct(\RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfig $editorConfig)
{
$this->editorConfig = $editorConfig;
}
public function extractConfigurationForFile(\Rector\Core\ValueObject\Application\File $file, \Rector\FileFormatter\ValueObjectFactory\EditorConfigConfigurationBuilder $editorConfigConfigurationBuilder) : \Rector\FileFormatter\ValueObject\EditorConfigConfiguration
{
$smartFileInfo = $file->getSmartFileInfo();
/** @var Declaration[] $configuration */
$configuration = $this->editorConfig->getConfigForPath($smartFileInfo->getRealPath());
if (\array_key_exists(\Rector\FileFormatter\ValueObject\EditorConfigOption::INDENT_STYLE, $configuration)) {
$indentStyle = (string) $configuration[\Rector\FileFormatter\ValueObject\EditorConfigOption::INDENT_STYLE]->getValue();
$editorConfigConfigurationBuilder->withIndentStyle($indentStyle);
}
if (\array_key_exists(\Rector\FileFormatter\ValueObject\EditorConfigOption::INDENT_SIZE, $configuration)) {
$indentSize = (int) $configuration[\Rector\FileFormatter\ValueObject\EditorConfigOption::INDENT_SIZE]->getValue();
$editorConfigConfigurationBuilder->withIndentSize($indentSize);
}
if (\array_key_exists(\Rector\FileFormatter\ValueObject\EditorConfigOption::END_OF_LINE, $configuration)) {
$endOfLine = (string) $configuration[\Rector\FileFormatter\ValueObject\EditorConfigOption::END_OF_LINE]->getValue();
$editorConfigConfigurationBuilder->withEndOfLineFromEditorConfig($endOfLine);
}
if (\array_key_exists(\Rector\FileFormatter\ValueObject\EditorConfigOption::INSERT_FINAL_NEWLINE, $configuration)) {
$insertFinalNewline = (bool) $configuration[\Rector\FileFormatter\ValueObject\EditorConfigOption::INSERT_FINAL_NEWLINE]->getValue();
$editorConfigConfigurationBuilder->withInsertFinalNewline($insertFinalNewline);
}
return $editorConfigConfigurationBuilder->build();
}
}

View File

@ -1,16 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\FileFormatter\Enum;
final class IndentType
{
/**
* @var string
*/
public const SPACE = 'space';
/**
* @var string
*/
public const TAB = 'tab';
}

View File

@ -1,14 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\FileFormatter\Exception;
use InvalidArgumentException;
final class InvalidIndentSizeException extends \InvalidArgumentException
{
public function __construct(int $size, int $minimumSize)
{
$message = \sprintf('Size %d must be greater than %d', $size, $minimumSize);
parent::__construct($message);
}
}

View File

@ -1,14 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\FileFormatter\Exception;
use InvalidArgumentException;
final class InvalidIndentStringException extends \InvalidArgumentException
{
public function __construct(string $value)
{
$message = \sprintf('The "%s" is not valid indentation', $value);
parent::__construct($message);
}
}

View File

@ -1,16 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\FileFormatter\Exception;
use InvalidArgumentException;
use Rector\FileFormatter\Enum\IndentType;
final class InvalidIndentStyleException extends \InvalidArgumentException
{
public function __construct(string $style)
{
$allowedIndentTypesString = \implode('", "', [\Rector\FileFormatter\Enum\IndentType::SPACE, \Rector\FileFormatter\Enum\IndentType::TAB]);
$message = \sprintf('Given style "%s" is not allowed. Allowed are "%s"', $style, $allowedIndentTypesString);
parent::__construct($message);
}
}

View File

@ -1,17 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\FileFormatter\Exception;
use InvalidArgumentException;
final class InvalidNewLineStringException extends \InvalidArgumentException
{
public static function fromString(string $string) : self
{
return new self(\sprintf('"%s" is not a valid new-line character sequence.', $string));
}
public static function create(string $message) : self
{
return new self($message);
}
}

View File

@ -1,14 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\FileFormatter\Exception;
use UnexpectedValueException;
final class ParseIndentException extends \UnexpectedValueException
{
public function __construct(string $string)
{
$message = \sprintf('The content "%s" could not be parsed', $string);
parent::__construct($message);
}
}

View File

@ -1,84 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\FileFormatter;
use Rector\Core\Configuration\Option;
use Rector\Core\ValueObject\Application\File;
use Rector\FileFormatter\Contract\Formatter\FileFormatterInterface;
use Rector\FileFormatter\EditorConfig\EditorConfigParser;
use Rector\FileFormatter\Exception\InvalidNewLineStringException;
use Rector\FileFormatter\Exception\ParseIndentException;
use Rector\FileFormatter\ValueObject\EditorConfigConfiguration;
use Rector\FileFormatter\ValueObject\Indent;
use Rector\FileFormatter\ValueObject\NewLine;
use Rector\FileFormatter\ValueObjectFactory\EditorConfigConfigurationBuilder;
use RectorPrefix20220527\Symplify\PackageBuilder\Parameter\ParameterProvider;
final class FileFormatter
{
/**
* @readonly
* @var \Rector\FileFormatter\EditorConfig\EditorConfigParser
*/
private $editorConfigParser;
/**
* @readonly
* @var \Symplify\PackageBuilder\Parameter\ParameterProvider
*/
private $parameterProvider;
/**
* @var FileFormatterInterface[]
* @readonly
*/
private $fileFormatters = [];
/**
* @param FileFormatterInterface[] $fileFormatters
*/
public function __construct(\Rector\FileFormatter\EditorConfig\EditorConfigParser $editorConfigParser, \RectorPrefix20220527\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, array $fileFormatters = [])
{
$this->editorConfigParser = $editorConfigParser;
$this->parameterProvider = $parameterProvider;
$this->fileFormatters = $fileFormatters;
}
/**
* @param File[] $files
*/
public function format(array $files) : void
{
foreach ($files as $file) {
if (!$file->hasChanged()) {
continue;
}
foreach ($this->fileFormatters as $fileFormatter) {
if (!$fileFormatter->supports($file)) {
continue;
}
$editorConfigConfigurationBuilder = new \Rector\FileFormatter\ValueObjectFactory\EditorConfigConfigurationBuilder();
$this->sniffOriginalFileContent($file, $editorConfigConfigurationBuilder);
$editorConfiguration = $this->createEditorConfiguration($file, $editorConfigConfigurationBuilder);
$fileFormatter->format($file, $editorConfiguration);
}
}
}
private function sniffOriginalFileContent(\Rector\Core\ValueObject\Application\File $file, \Rector\FileFormatter\ValueObjectFactory\EditorConfigConfigurationBuilder $editorConfigConfigurationBuilder) : void
{
// Try to sniff into the original content to get the indentation and new line
try {
$indent = \Rector\FileFormatter\ValueObject\Indent::fromContent($file->getOriginalFileContent());
$editorConfigConfigurationBuilder->withIndent($indent);
} catch (\Rector\FileFormatter\Exception\ParseIndentException $exception) {
}
try {
$newLine = \Rector\FileFormatter\ValueObject\NewLine::fromContent($file->getOriginalFileContent());
$editorConfigConfigurationBuilder->withNewLine($newLine);
} catch (\Rector\FileFormatter\Exception\InvalidNewLineStringException $exception) {
}
}
private function createEditorConfiguration(\Rector\Core\ValueObject\Application\File $file, \Rector\FileFormatter\ValueObjectFactory\EditorConfigConfigurationBuilder $editorConfigConfigurationBuilder) : \Rector\FileFormatter\ValueObject\EditorConfigConfiguration
{
if (!$this->parameterProvider->provideBoolParameter(\Rector\Core\Configuration\Option::ENABLE_EDITORCONFIG)) {
return $editorConfigConfigurationBuilder->build();
}
return $this->editorConfigParser->extractConfigurationForFile($file, $editorConfigConfigurationBuilder);
}
}

View File

@ -1,35 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\FileFormatter\Formatter;
use RectorPrefix20220527\Ergebnis\Json\Printer\PrinterInterface;
use Rector\Core\ValueObject\Application\File;
use Rector\FileFormatter\Contract\Formatter\FileFormatterInterface;
use Rector\FileFormatter\ValueObject\EditorConfigConfiguration;
/**
* @see \Rector\Tests\FileFormatter\Formatter\JsonFileFormatter\JsonFileFormatterTest
*/
final class JsonFileFormatter implements \Rector\FileFormatter\Contract\Formatter\FileFormatterInterface
{
/**
* @readonly
* @var \Ergebnis\Json\Printer\PrinterInterface
*/
private $jsonPrinter;
public function __construct(\RectorPrefix20220527\Ergebnis\Json\Printer\PrinterInterface $jsonPrinter)
{
$this->jsonPrinter = $jsonPrinter;
}
public function supports(\Rector\Core\ValueObject\Application\File $file) : bool
{
$smartFileInfo = $file->getSmartFileInfo();
return $smartFileInfo->getExtension() === 'json';
}
public function format(\Rector\Core\ValueObject\Application\File $file, \Rector\FileFormatter\ValueObject\EditorConfigConfiguration $editorConfigConfiguration) : void
{
$newFileContent = $this->jsonPrinter->print($file->getFileContent(), $editorConfigConfiguration->getIndent(), $editorConfigConfiguration->getNewLine());
$newFileContent .= $editorConfigConfiguration->getFinalNewline();
$file->changeFileContent($newFileContent);
}
}

View File

@ -1,56 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\FileFormatter\ValueObject;
/**
* @see \Rector\Tests\FileFormatter\ValueObject\EditorConfigConfigurationTest
*/
final class EditorConfigConfiguration
{
/**
* @readonly
* @var \Rector\FileFormatter\ValueObject\Indent
*/
private $indent;
/**
* @readonly
* @var \Rector\FileFormatter\ValueObject\NewLine
*/
private $newLine;
/**
* @readonly
* @var bool
*/
private $insertFinalNewline;
public function __construct(\Rector\FileFormatter\ValueObject\Indent $indent, \Rector\FileFormatter\ValueObject\NewLine $newLine, bool $insertFinalNewline)
{
$this->indent = $indent;
$this->newLine = $newLine;
$this->insertFinalNewline = $insertFinalNewline;
}
public function getNewLine() : string
{
return $this->newLine->__toString();
}
public function getFinalNewline() : string
{
return $this->insertFinalNewline ? $this->getNewLine() : '';
}
public function getIndent() : string
{
return $this->indent->__toString();
}
public function getIndentStyleCharacter() : string
{
return $this->indent->getIndentStyleCharacter();
}
public function getIndentStyle() : string
{
return $this->indent->getIndentStyle();
}
public function getIndentSize() : int
{
return $this->indent->getIndentSize();
}
}

View File

@ -1,28 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\FileFormatter\ValueObject;
final class EditorConfigOption
{
/**
* @var string
*/
public const INDENT_STYLE = 'indent_style';
/**
* @var string
*/
public const INDENT_SIZE = 'indent_size';
/**
* @var string
*/
public const END_OF_LINE = 'end_of_line';
/**
* @var string
*/
public const INSERT_FINAL_NEWLINE = 'insert_final_newline';
/**
* @var string
*/
public const TAB_WIDTH = 'tab_width';
}

View File

@ -1,106 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\FileFormatter\ValueObject;
use RectorPrefix20220527\Nette\Utils\Strings;
use Rector\FileFormatter\Enum\IndentType;
use Rector\FileFormatter\Exception\InvalidIndentSizeException;
use Rector\FileFormatter\Exception\InvalidIndentStringException;
use Rector\FileFormatter\Exception\InvalidIndentStyleException;
use Rector\FileFormatter\Exception\ParseIndentException;
use Stringable;
/**
* @see \Rector\Tests\FileFormatter\ValueObject\IndentTest
*/
final class Indent
{
/**
* @var array<string, string>
*/
public const CHARACTERS = [\Rector\FileFormatter\Enum\IndentType::SPACE => ' ', \Rector\FileFormatter\Enum\IndentType::TAB => "\t"];
/**
* @see https://regex101.com/r/A2XiaF/1
* @var string
*/
private const VALID_INDENT_REGEX = '#^( *|\\t+)$#';
/**
* @var int
*/
private const MINIMUM_SIZE = 1;
/**
* @see https://regex101.com/r/3HFEjX/1
* @var string
*/
private const PARSE_INDENT_REGEX = '/^(?P<indent>( +|\\t+)).*/m';
/**
* @readonly
* @var string
*/
private $string;
private function __construct(string $string)
{
$this->string = $string;
}
public function __toString() : string
{
return $this->string;
}
public static function fromString(string $content) : self
{
$match = \RectorPrefix20220527\Nette\Utils\Strings::match($content, self::VALID_INDENT_REGEX);
if ($match === null) {
throw new \Rector\FileFormatter\Exception\InvalidIndentStringException($content);
}
return new self($content);
}
public static function createSpaceWithSize(int $size) : self
{
return self::fromSizeAndStyle($size, \Rector\FileFormatter\Enum\IndentType::SPACE);
}
public static function createTab() : self
{
return self::fromSizeAndStyle(1, \Rector\FileFormatter\Enum\IndentType::TAB);
}
/**
* @param IndentType::* $style
*/
public static function fromSizeAndStyle(int $size, string $style) : self
{
if ($size < self::MINIMUM_SIZE) {
throw new \Rector\FileFormatter\Exception\InvalidIndentSizeException($size, self::MINIMUM_SIZE);
}
if (!\array_key_exists($style, self::CHARACTERS)) {
throw new \Rector\FileFormatter\Exception\InvalidIndentStyleException($style);
}
$value = \str_repeat(self::CHARACTERS[$style], $size);
return new self($value);
}
public static function fromContent(string $content) : self
{
$match = \RectorPrefix20220527\Nette\Utils\Strings::match($content, self::PARSE_INDENT_REGEX);
if (isset($match['indent'])) {
return self::fromString($match['indent']);
}
throw new \Rector\FileFormatter\Exception\ParseIndentException($content);
}
public function getIndentSize() : int
{
return \strlen($this->string);
}
/**
* @return IndentType::*
*/
public function getIndentStyle() : string
{
return $this->startsWithSpace() ? \Rector\FileFormatter\Enum\IndentType::SPACE : \Rector\FileFormatter\Enum\IndentType::TAB;
}
public function getIndentStyleCharacter() : string
{
return $this->startsWithSpace() ? self::CHARACTERS[\Rector\FileFormatter\Enum\IndentType::SPACE] : self::CHARACTERS[\Rector\FileFormatter\Enum\IndentType::TAB];
}
private function startsWithSpace() : bool
{
return \strncmp($this->string, ' ', \strlen(' ')) === 0;
}
}

View File

@ -1,79 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\FileFormatter\ValueObject;
use RectorPrefix20220527\Nette\Utils\Strings;
use const PHP_EOL;
use Rector\FileFormatter\Exception\InvalidNewLineStringException;
use Stringable;
/**
* @see \Rector\Tests\FileFormatter\ValueObject\NewLineTest
*/
final class NewLine
{
/**
* @var string
*/
public const LINE_FEED = 'lf';
/**
* @var string
*/
public const CARRIAGE_RETURN = 'cr';
/**
* @var string
*/
public const CARRIAGE_RETURN_LINE_FEED = 'crlf';
/**
* @var array<string, string>
*/
private const ALLOWED_END_OF_LINE = [self::LINE_FEED => "\n", self::CARRIAGE_RETURN => "\r", self::CARRIAGE_RETURN_LINE_FEED => "\r\n"];
/**
* @see https://regex101.com/r/icaBBp/1
* @var string
*/
private const NEWLINE_REGEX = '#(?P<newLine>\\r\\n|\\n|\\r)#';
/**
* @see https://regex101.com/r/WrY9ZW/1/
* @var string
*/
private const VALID_NEWLINE_REGEX = '#^(?>\\r\\n|\\n|\\r)$#';
/**
* @readonly
* @var string
*/
private $string;
private function __construct(string $string)
{
$this->string = $string;
}
public function __toString() : string
{
return $this->string;
}
public static function fromSingleCharacter(string $content) : self
{
$matches = \RectorPrefix20220527\Nette\Utils\Strings::match($content, self::VALID_NEWLINE_REGEX);
if ($matches === null) {
throw \Rector\FileFormatter\Exception\InvalidNewLineStringException::fromString($content);
}
return new self($content);
}
public static function fromContent(string $content) : self
{
$match = \RectorPrefix20220527\Nette\Utils\Strings::match($content, self::NEWLINE_REGEX);
if (isset($match['newLine'])) {
return self::fromSingleCharacter($match['newLine']);
}
return self::fromSingleCharacter(\PHP_EOL);
}
public static function fromEditorConfig(string $endOfLine) : self
{
if (!\array_key_exists($endOfLine, self::ALLOWED_END_OF_LINE)) {
$allowedEndOfLineValues = \array_keys(self::ALLOWED_END_OF_LINE);
$message = \sprintf('The endOfLine "%s" is not allowed. Allowed are "%s"', $endOfLine, \implode(',', $allowedEndOfLineValues));
throw \Rector\FileFormatter\Exception\InvalidNewLineStringException::create($message);
}
return self::fromSingleCharacter(self::ALLOWED_END_OF_LINE[$endOfLine]);
}
}

View File

@ -1,77 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\FileFormatter\ValueObjectFactory;
use Rector\FileFormatter\Enum\IndentType;
use Rector\FileFormatter\ValueObject\EditorConfigConfiguration;
use Rector\FileFormatter\ValueObject\Indent;
use Rector\FileFormatter\ValueObject\NewLine;
final class EditorConfigConfigurationBuilder
{
/**
* @var \Rector\FileFormatter\ValueObject\NewLine
*/
private $newLine;
/**
* @var IndentType::*
*/
private $indentStyle = \Rector\FileFormatter\Enum\IndentType::SPACE;
/**
* @var int
*/
private $indentSize = 4;
/**
* @var bool
*/
private $insertFinalNewline = \true;
/**
* @param IndentType::* $indentStyle
*/
public function __construct(string $indentStyle = \Rector\FileFormatter\Enum\IndentType::SPACE, int $indentSize = 4, bool $insertFinalNewline = \true)
{
$this->indentStyle = $indentStyle;
$this->indentSize = $indentSize;
$this->insertFinalNewline = $insertFinalNewline;
$this->newLine = \Rector\FileFormatter\ValueObject\NewLine::fromEditorConfig('lf');
}
public function withNewLine(\Rector\FileFormatter\ValueObject\NewLine $newLine) : self
{
$this->newLine = $newLine;
return $this;
}
public function withIndent(\Rector\FileFormatter\ValueObject\Indent $indent) : self
{
$this->indentSize = $indent->getIndentSize();
$this->indentStyle = $indent->getIndentStyle();
return $this;
}
/**
* @param IndentType::* $indentStyle
*/
public function withIndentStyle(string $indentStyle) : self
{
$this->indentStyle = $indentStyle;
return $this;
}
public function withIndentSize(int $indentSize) : self
{
$this->indentSize = $indentSize;
return $this;
}
public function withInsertFinalNewline(bool $insertFinalNewline) : self
{
$this->insertFinalNewline = $insertFinalNewline;
return $this;
}
public function withEndOfLineFromEditorConfig(string $endOfLine) : self
{
$this->newLine = \Rector\FileFormatter\ValueObject\NewLine::fromEditorConfig($endOfLine);
return $this;
}
public function build() : \Rector\FileFormatter\ValueObject\EditorConfigConfiguration
{
$newLine = $this->newLine;
return new \Rector\FileFormatter\ValueObject\EditorConfigConfiguration(\Rector\FileFormatter\ValueObject\Indent::fromSizeAndStyle($this->indentSize, $this->indentStyle), $newLine, $this->insertFinalNewline);
}
}

View File

@ -14,7 +14,6 @@ use Rector\Core\ValueObject\Configuration;
use Rector\Core\ValueObject\Error\SystemError;
use Rector\Core\ValueObject\Reporting\FileDiff;
use Rector\Core\ValueObjectFactory\Application\FileFactory;
use Rector\FileFormatter\FileFormatter;
use Rector\Parallel\Application\ParallelFileProcessor;
use Rector\Parallel\ValueObject\Bridge;
use RectorPrefix20220527\Symfony\Component\Console\Input\InputInterface;
@ -47,11 +46,6 @@ final class ApplicationFileProcessor
* @var \Rector\Core\Application\FileDecorator\FileDiffFileDecorator
*/
private $fileDiffFileDecorator;
/**
* @readonly
* @var \Rector\FileFormatter\FileFormatter
*/
private $fileFormatter;
/**
* @readonly
* @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesProcessor
@ -110,11 +104,10 @@ final class ApplicationFileProcessor
/**
* @param FileProcessorInterface[] $fileProcessors
*/
public function __construct(\RectorPrefix20220527\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\Application\FileDecorator\FileDiffFileDecorator $fileDiffFileDecorator, \Rector\FileFormatter\FileFormatter $fileFormatter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesProcessor $removedAndAddedFilesProcessor, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle, \Rector\Core\ValueObjectFactory\Application\FileFactory $fileFactory, \PHPStan\Analyser\NodeScopeResolver $nodeScopeResolver, \RectorPrefix20220527\Symplify\PackageBuilder\Yaml\ParametersMerger $parametersMerger, \Rector\Parallel\Application\ParallelFileProcessor $parallelFileProcessor, \RectorPrefix20220527\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \RectorPrefix20220527\Symplify\EasyParallel\ScheduleFactory $scheduleFactory, \RectorPrefix20220527\Symplify\EasyParallel\FileSystem\FilePathNormalizer $filePathNormalizer, \RectorPrefix20220527\Symplify\EasyParallel\CpuCoreCountProvider $cpuCoreCountProvider, array $fileProcessors = [])
public function __construct(\RectorPrefix20220527\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\Application\FileDecorator\FileDiffFileDecorator $fileDiffFileDecorator, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesProcessor $removedAndAddedFilesProcessor, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle, \Rector\Core\ValueObjectFactory\Application\FileFactory $fileFactory, \PHPStan\Analyser\NodeScopeResolver $nodeScopeResolver, \RectorPrefix20220527\Symplify\PackageBuilder\Yaml\ParametersMerger $parametersMerger, \Rector\Parallel\Application\ParallelFileProcessor $parallelFileProcessor, \RectorPrefix20220527\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \RectorPrefix20220527\Symplify\EasyParallel\ScheduleFactory $scheduleFactory, \RectorPrefix20220527\Symplify\EasyParallel\FileSystem\FilePathNormalizer $filePathNormalizer, \RectorPrefix20220527\Symplify\EasyParallel\CpuCoreCountProvider $cpuCoreCountProvider, array $fileProcessors = [])
{
$this->smartFileSystem = $smartFileSystem;
$this->fileDiffFileDecorator = $fileDiffFileDecorator;
$this->fileFormatter = $fileFormatter;
$this->removedAndAddedFilesProcessor = $removedAndAddedFilesProcessor;
$this->rectorOutputStyle = $rectorOutputStyle;
$this->fileFactory = $fileFactory;
@ -146,7 +139,6 @@ final class ApplicationFileProcessor
// 2. PHPStan has to know about all files too
$this->configurePHPStanNodeScopeResolver($files);
$systemErrorsAndFileDiffs = $this->processFiles($files, $configuration);
$this->fileFormatter->format($files);
$this->fileDiffFileDecorator->decorate($files);
$this->printFiles($files, $configuration);
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '30b5b53c0ed3031b75341efe02a53d8367861dd4';
public const PACKAGE_VERSION = '37df55a2fd1a2d6baceb128d8d25cabb19bea833';
/**
* @var string
*/
public const RELEASE_DATE = '2022-05-27 16:15:01';
public const RELEASE_DATE = '2022-05-27 18:40:49';
/**
* @var string
*/

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitcb35e254f08652faad722828c850129e::getLoader();
return ComposerAutoloaderInit2ab66d11b53f9eefc2121becfa7d9f0f::getLoader();

View File

@ -395,8 +395,6 @@ return array(
'RectorPrefix20220527\\Doctrine\\Inflector\\Rules\\Word' => $vendorDir . '/doctrine/inflector/lib/Doctrine/Inflector/Rules/Word.php',
'RectorPrefix20220527\\Doctrine\\Inflector\\RulesetInflector' => $vendorDir . '/doctrine/inflector/lib/Doctrine/Inflector/RulesetInflector.php',
'RectorPrefix20220527\\Doctrine\\Inflector\\WordInflector' => $vendorDir . '/doctrine/inflector/lib/Doctrine/Inflector/WordInflector.php',
'RectorPrefix20220527\\Ergebnis\\Json\\Printer\\Printer' => $vendorDir . '/ergebnis/json-printer/src/Printer.php',
'RectorPrefix20220527\\Ergebnis\\Json\\Printer\\PrinterInterface' => $vendorDir . '/ergebnis/json-printer/src/PrinterInterface.php',
'RectorPrefix20220527\\Evenement\\EventEmitter' => $vendorDir . '/evenement/evenement/src/Evenement/EventEmitter.php',
'RectorPrefix20220527\\Evenement\\EventEmitterInterface' => $vendorDir . '/evenement/evenement/src/Evenement/EventEmitterInterface.php',
'RectorPrefix20220527\\Evenement\\EventEmitterTrait' => $vendorDir . '/evenement/evenement/src/Evenement/EventEmitterTrait.php',
@ -456,23 +454,6 @@ return array(
'RectorPrefix20220527\\Helmich\\TypoScriptParser\\Tokenizer\\TokenizerInterface' => $vendorDir . '/helmich/typo3-typoscript-parser/src/Tokenizer/TokenizerInterface.php',
'RectorPrefix20220527\\Helmich\\TypoScriptParser\\Tokenizer\\UnknownOperatorException' => $vendorDir . '/helmich/typo3-typoscript-parser/src/Tokenizer/UnknownOperatorException.php',
'RectorPrefix20220527\\Helmich\\TypoScriptParser\\TypoScriptParserExtension' => $vendorDir . '/helmich/typo3-typoscript-parser/src/TypoScriptParserExtension.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\BooleanDeclaration' => $vendorDir . '/idiosyncratic/editorconfig/src/Declaration/BooleanDeclaration.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\Charset' => $vendorDir . '/idiosyncratic/editorconfig/src/Declaration/Charset.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\Declaration' => $vendorDir . '/idiosyncratic/editorconfig/src/Declaration/Declaration.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\EndOfLine' => $vendorDir . '/idiosyncratic/editorconfig/src/Declaration/EndOfLine.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\Factory' => $vendorDir . '/idiosyncratic/editorconfig/src/Declaration/Factory.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\GenericDeclaration' => $vendorDir . '/idiosyncratic/editorconfig/src/Declaration/GenericDeclaration.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\IndentSize' => $vendorDir . '/idiosyncratic/editorconfig/src/Declaration/IndentSize.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\IndentStyle' => $vendorDir . '/idiosyncratic/editorconfig/src/Declaration/IndentStyle.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\InsertFinalNewline' => $vendorDir . '/idiosyncratic/editorconfig/src/Declaration/InsertFinalNewline.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\MaxLineLength' => $vendorDir . '/idiosyncratic/editorconfig/src/Declaration/MaxLineLength.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\TabWidth' => $vendorDir . '/idiosyncratic/editorconfig/src/Declaration/TabWidth.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\TrimTrailingWhitespace' => $vendorDir . '/idiosyncratic/editorconfig/src/Declaration/TrimTrailingWhitespace.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\UnsetDeclaration' => $vendorDir . '/idiosyncratic/editorconfig/src/Declaration/UnsetDeclaration.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\EditorConfig' => $vendorDir . '/idiosyncratic/editorconfig/src/EditorConfig.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\EditorConfigFile' => $vendorDir . '/idiosyncratic/editorconfig/src/EditorConfigFile.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Exception\\InvalidValue' => $vendorDir . '/idiosyncratic/editorconfig/src/Exception/InvalidValue.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Section' => $vendorDir . '/idiosyncratic/editorconfig/src/Section.php',
'RectorPrefix20220527\\MyCLabs\\Enum\\Enum' => $vendorDir . '/myclabs/php-enum/src/Enum.php',
'RectorPrefix20220527\\MyCLabs\\Enum\\PHPUnit\\Comparator' => $vendorDir . '/myclabs/php-enum/src/PHPUnit/Comparator.php',
'RectorPrefix20220527\\Nette\\ArgumentOutOfRangeException' => $vendorDir . '/nette/utils/src/exceptions.php',
@ -2122,21 +2103,6 @@ return array(
'Rector\\FamilyTree\\NodeAnalyzer\\ClassChildAnalyzer' => $baseDir . '/packages/FamilyTree/NodeAnalyzer/ClassChildAnalyzer.php',
'Rector\\FamilyTree\\Reflection\\FamilyRelationsAnalyzer' => $baseDir . '/packages/FamilyTree/Reflection/FamilyRelationsAnalyzer.php',
'Rector\\FamilyTree\\ValueObject\\PropertyType' => $baseDir . '/packages/FamilyTree/ValueObject/PropertyType.php',
'Rector\\FileFormatter\\Contract\\Formatter\\FileFormatterInterface' => $baseDir . '/packages/FileFormatter/Contract/Formatter/FileFormatterInterface.php',
'Rector\\FileFormatter\\EditorConfig\\EditorConfigParser' => $baseDir . '/packages/FileFormatter/EditorConfig/EditorConfigParser.php',
'Rector\\FileFormatter\\Enum\\IndentType' => $baseDir . '/packages/FileFormatter/Enum/IndentType.php',
'Rector\\FileFormatter\\Exception\\InvalidIndentSizeException' => $baseDir . '/packages/FileFormatter/Exception/InvalidIndentSizeException.php',
'Rector\\FileFormatter\\Exception\\InvalidIndentStringException' => $baseDir . '/packages/FileFormatter/Exception/InvalidIndentStringException.php',
'Rector\\FileFormatter\\Exception\\InvalidIndentStyleException' => $baseDir . '/packages/FileFormatter/Exception/InvalidIndentStyleException.php',
'Rector\\FileFormatter\\Exception\\InvalidNewLineStringException' => $baseDir . '/packages/FileFormatter/Exception/InvalidNewLineStringException.php',
'Rector\\FileFormatter\\Exception\\ParseIndentException' => $baseDir . '/packages/FileFormatter/Exception/ParseIndentException.php',
'Rector\\FileFormatter\\FileFormatter' => $baseDir . '/packages/FileFormatter/FileFormatter.php',
'Rector\\FileFormatter\\Formatter\\JsonFileFormatter' => $baseDir . '/packages/FileFormatter/Formatter/JsonFileFormatter.php',
'Rector\\FileFormatter\\ValueObjectFactory\\EditorConfigConfigurationBuilder' => $baseDir . '/packages/FileFormatter/ValueObjectFactory/EditorConfigConfigurationBuilder.php',
'Rector\\FileFormatter\\ValueObject\\EditorConfigConfiguration' => $baseDir . '/packages/FileFormatter/ValueObject/EditorConfigConfiguration.php',
'Rector\\FileFormatter\\ValueObject\\EditorConfigOption' => $baseDir . '/packages/FileFormatter/ValueObject/EditorConfigOption.php',
'Rector\\FileFormatter\\ValueObject\\Indent' => $baseDir . '/packages/FileFormatter/ValueObject/Indent.php',
'Rector\\FileFormatter\\ValueObject\\NewLine' => $baseDir . '/packages/FileFormatter/ValueObject/NewLine.php',
'Rector\\FileSystemRector\\Contract\\AddedFileInterface' => $baseDir . '/packages/FileSystemRector/Contract/AddedFileInterface.php',
'Rector\\FileSystemRector\\Contract\\FileWithNodesInterface' => $baseDir . '/packages/FileSystemRector/Contract/FileWithNodesInterface.php',
'Rector\\FileSystemRector\\Parser\\FileInfoParser' => $baseDir . '/packages/FileSystemRector/Parser/FileInfoParser.php',

View File

@ -61,10 +61,8 @@ return array(
'RectorPrefix20220527\\Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
'RectorPrefix20220527\\OndraM\\CiDetector\\' => array($vendorDir . '/ondram/ci-detector/src'),
'RectorPrefix20220527\\MyCLabs\\Enum\\' => array($vendorDir . '/myclabs/php-enum/src'),
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\' => array($vendorDir . '/idiosyncratic/editorconfig/src'),
'RectorPrefix20220527\\Helmich\\TypoScriptParser\\' => array($vendorDir . '/helmich/typo3-typoscript-parser/src'),
'RectorPrefix20220527\\Evenement\\' => array($vendorDir . '/evenement/evenement/src/Evenement'),
'RectorPrefix20220527\\Ergebnis\\Json\\Printer\\' => array($vendorDir . '/ergebnis/json-printer/src'),
'RectorPrefix20220527\\Doctrine\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib/Doctrine/Inflector'),
'RectorPrefix20220527\\Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),
'RectorPrefix20220527\\Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitcb35e254f08652faad722828c850129e
class ComposerAutoloaderInit2ab66d11b53f9eefc2121becfa7d9f0f
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInitcb35e254f08652faad722828c850129e
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitcb35e254f08652faad722828c850129e', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit2ab66d11b53f9eefc2121becfa7d9f0f', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitcb35e254f08652faad722828c850129e', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit2ab66d11b53f9eefc2121becfa7d9f0f', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitcb35e254f08652faad722828c850129e::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit2ab66d11b53f9eefc2121becfa7d9f0f::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInitcb35e254f08652faad722828c850129e::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit2ab66d11b53f9eefc2121becfa7d9f0f::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequirecb35e254f08652faad722828c850129e($fileIdentifier, $file);
composerRequire2ab66d11b53f9eefc2121becfa7d9f0f($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInitcb35e254f08652faad722828c850129e
* @param string $file
* @return void
*/
function composerRequirecb35e254f08652faad722828c850129e($fileIdentifier, $file)
function composerRequire2ab66d11b53f9eefc2121becfa7d9f0f($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInitcb35e254f08652faad722828c850129e
class ComposerStaticInit2ab66d11b53f9eefc2121becfa7d9f0f
{
public static $files = array (
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
@ -83,10 +83,8 @@ class ComposerStaticInitcb35e254f08652faad722828c850129e
'RectorPrefix20220527\\Psr\\Cache\\' => 31,
'RectorPrefix20220527\\OndraM\\CiDetector\\' => 39,
'RectorPrefix20220527\\MyCLabs\\Enum\\' => 34,
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\' => 48,
'RectorPrefix20220527\\Helmich\\TypoScriptParser\\' => 46,
'RectorPrefix20220527\\Evenement\\' => 31,
'RectorPrefix20220527\\Ergebnis\\Json\\Printer\\' => 43,
'RectorPrefix20220527\\Doctrine\\Inflector\\' => 40,
'RectorPrefix20220527\\Composer\\XdebugHandler\\' => 44,
'RectorPrefix20220527\\Composer\\Semver\\' => 37,
@ -324,10 +322,6 @@ class ComposerStaticInitcb35e254f08652faad722828c850129e
array (
0 => __DIR__ . '/..' . '/myclabs/php-enum/src',
),
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\' =>
array (
0 => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src',
),
'RectorPrefix20220527\\Helmich\\TypoScriptParser\\' =>
array (
0 => __DIR__ . '/..' . '/helmich/typo3-typoscript-parser/src',
@ -336,10 +330,6 @@ class ComposerStaticInitcb35e254f08652faad722828c850129e
array (
0 => __DIR__ . '/..' . '/evenement/evenement/src/Evenement',
),
'RectorPrefix20220527\\Ergebnis\\Json\\Printer\\' =>
array (
0 => __DIR__ . '/..' . '/ergebnis/json-printer/src',
),
'RectorPrefix20220527\\Doctrine\\Inflector\\' =>
array (
0 => __DIR__ . '/..' . '/doctrine/inflector/lib/Doctrine/Inflector',
@ -764,8 +754,6 @@ class ComposerStaticInitcb35e254f08652faad722828c850129e
'RectorPrefix20220527\\Doctrine\\Inflector\\Rules\\Word' => __DIR__ . '/..' . '/doctrine/inflector/lib/Doctrine/Inflector/Rules/Word.php',
'RectorPrefix20220527\\Doctrine\\Inflector\\RulesetInflector' => __DIR__ . '/..' . '/doctrine/inflector/lib/Doctrine/Inflector/RulesetInflector.php',
'RectorPrefix20220527\\Doctrine\\Inflector\\WordInflector' => __DIR__ . '/..' . '/doctrine/inflector/lib/Doctrine/Inflector/WordInflector.php',
'RectorPrefix20220527\\Ergebnis\\Json\\Printer\\Printer' => __DIR__ . '/..' . '/ergebnis/json-printer/src/Printer.php',
'RectorPrefix20220527\\Ergebnis\\Json\\Printer\\PrinterInterface' => __DIR__ . '/..' . '/ergebnis/json-printer/src/PrinterInterface.php',
'RectorPrefix20220527\\Evenement\\EventEmitter' => __DIR__ . '/..' . '/evenement/evenement/src/Evenement/EventEmitter.php',
'RectorPrefix20220527\\Evenement\\EventEmitterInterface' => __DIR__ . '/..' . '/evenement/evenement/src/Evenement/EventEmitterInterface.php',
'RectorPrefix20220527\\Evenement\\EventEmitterTrait' => __DIR__ . '/..' . '/evenement/evenement/src/Evenement/EventEmitterTrait.php',
@ -825,23 +813,6 @@ class ComposerStaticInitcb35e254f08652faad722828c850129e
'RectorPrefix20220527\\Helmich\\TypoScriptParser\\Tokenizer\\TokenizerInterface' => __DIR__ . '/..' . '/helmich/typo3-typoscript-parser/src/Tokenizer/TokenizerInterface.php',
'RectorPrefix20220527\\Helmich\\TypoScriptParser\\Tokenizer\\UnknownOperatorException' => __DIR__ . '/..' . '/helmich/typo3-typoscript-parser/src/Tokenizer/UnknownOperatorException.php',
'RectorPrefix20220527\\Helmich\\TypoScriptParser\\TypoScriptParserExtension' => __DIR__ . '/..' . '/helmich/typo3-typoscript-parser/src/TypoScriptParserExtension.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\BooleanDeclaration' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/Declaration/BooleanDeclaration.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\Charset' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/Declaration/Charset.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\Declaration' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/Declaration/Declaration.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\EndOfLine' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/Declaration/EndOfLine.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\Factory' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/Declaration/Factory.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\GenericDeclaration' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/Declaration/GenericDeclaration.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\IndentSize' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/Declaration/IndentSize.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\IndentStyle' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/Declaration/IndentStyle.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\InsertFinalNewline' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/Declaration/InsertFinalNewline.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\MaxLineLength' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/Declaration/MaxLineLength.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\TabWidth' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/Declaration/TabWidth.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\TrimTrailingWhitespace' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/Declaration/TrimTrailingWhitespace.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Declaration\\UnsetDeclaration' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/Declaration/UnsetDeclaration.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\EditorConfig' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/EditorConfig.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\EditorConfigFile' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/EditorConfigFile.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Exception\\InvalidValue' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/Exception/InvalidValue.php',
'RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\Section' => __DIR__ . '/..' . '/idiosyncratic/editorconfig/src/Section.php',
'RectorPrefix20220527\\MyCLabs\\Enum\\Enum' => __DIR__ . '/..' . '/myclabs/php-enum/src/Enum.php',
'RectorPrefix20220527\\MyCLabs\\Enum\\PHPUnit\\Comparator' => __DIR__ . '/..' . '/myclabs/php-enum/src/PHPUnit/Comparator.php',
'RectorPrefix20220527\\Nette\\ArgumentOutOfRangeException' => __DIR__ . '/..' . '/nette/utils/src/exceptions.php',
@ -2491,21 +2462,6 @@ class ComposerStaticInitcb35e254f08652faad722828c850129e
'Rector\\FamilyTree\\NodeAnalyzer\\ClassChildAnalyzer' => __DIR__ . '/../..' . '/packages/FamilyTree/NodeAnalyzer/ClassChildAnalyzer.php',
'Rector\\FamilyTree\\Reflection\\FamilyRelationsAnalyzer' => __DIR__ . '/../..' . '/packages/FamilyTree/Reflection/FamilyRelationsAnalyzer.php',
'Rector\\FamilyTree\\ValueObject\\PropertyType' => __DIR__ . '/../..' . '/packages/FamilyTree/ValueObject/PropertyType.php',
'Rector\\FileFormatter\\Contract\\Formatter\\FileFormatterInterface' => __DIR__ . '/../..' . '/packages/FileFormatter/Contract/Formatter/FileFormatterInterface.php',
'Rector\\FileFormatter\\EditorConfig\\EditorConfigParser' => __DIR__ . '/../..' . '/packages/FileFormatter/EditorConfig/EditorConfigParser.php',
'Rector\\FileFormatter\\Enum\\IndentType' => __DIR__ . '/../..' . '/packages/FileFormatter/Enum/IndentType.php',
'Rector\\FileFormatter\\Exception\\InvalidIndentSizeException' => __DIR__ . '/../..' . '/packages/FileFormatter/Exception/InvalidIndentSizeException.php',
'Rector\\FileFormatter\\Exception\\InvalidIndentStringException' => __DIR__ . '/../..' . '/packages/FileFormatter/Exception/InvalidIndentStringException.php',
'Rector\\FileFormatter\\Exception\\InvalidIndentStyleException' => __DIR__ . '/../..' . '/packages/FileFormatter/Exception/InvalidIndentStyleException.php',
'Rector\\FileFormatter\\Exception\\InvalidNewLineStringException' => __DIR__ . '/../..' . '/packages/FileFormatter/Exception/InvalidNewLineStringException.php',
'Rector\\FileFormatter\\Exception\\ParseIndentException' => __DIR__ . '/../..' . '/packages/FileFormatter/Exception/ParseIndentException.php',
'Rector\\FileFormatter\\FileFormatter' => __DIR__ . '/../..' . '/packages/FileFormatter/FileFormatter.php',
'Rector\\FileFormatter\\Formatter\\JsonFileFormatter' => __DIR__ . '/../..' . '/packages/FileFormatter/Formatter/JsonFileFormatter.php',
'Rector\\FileFormatter\\ValueObjectFactory\\EditorConfigConfigurationBuilder' => __DIR__ . '/../..' . '/packages/FileFormatter/ValueObjectFactory/EditorConfigConfigurationBuilder.php',
'Rector\\FileFormatter\\ValueObject\\EditorConfigConfiguration' => __DIR__ . '/../..' . '/packages/FileFormatter/ValueObject/EditorConfigConfiguration.php',
'Rector\\FileFormatter\\ValueObject\\EditorConfigOption' => __DIR__ . '/../..' . '/packages/FileFormatter/ValueObject/EditorConfigOption.php',
'Rector\\FileFormatter\\ValueObject\\Indent' => __DIR__ . '/../..' . '/packages/FileFormatter/ValueObject/Indent.php',
'Rector\\FileFormatter\\ValueObject\\NewLine' => __DIR__ . '/../..' . '/packages/FileFormatter/ValueObject/NewLine.php',
'Rector\\FileSystemRector\\Contract\\AddedFileInterface' => __DIR__ . '/../..' . '/packages/FileSystemRector/Contract/AddedFileInterface.php',
'Rector\\FileSystemRector\\Contract\\FileWithNodesInterface' => __DIR__ . '/../..' . '/packages/FileSystemRector/Contract/FileWithNodesInterface.php',
'Rector\\FileSystemRector\\Parser\\FileInfoParser' => __DIR__ . '/../..' . '/packages/FileSystemRector/Parser/FileInfoParser.php',
@ -3915,9 +3871,9 @@ class ComposerStaticInitcb35e254f08652faad722828c850129e
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitcb35e254f08652faad722828c850129e::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitcb35e254f08652faad722828c850129e::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitcb35e254f08652faad722828c850129e::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit2ab66d11b53f9eefc2121becfa7d9f0f::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit2ab66d11b53f9eefc2121becfa7d9f0f::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit2ab66d11b53f9eefc2121becfa7d9f0f::$classMap;
}, null, ClassLoader::class);
}

View File

@ -439,72 +439,6 @@
],
"install-path": "..\/doctrine\/inflector"
},
{
"name": "ergebnis\/json-printer",
"version": "3.2.0",
"version_normalized": "3.2.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/ergebnis\/json-printer.git",
"reference": "651cab2b7604a6b338d0d16749f5ea0851a68005"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/ergebnis\/json-printer\/zipball\/651cab2b7604a6b338d0d16749f5ea0851a68005",
"reference": "651cab2b7604a6b338d0d16749f5ea0851a68005",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-mbstring": "*",
"php": "^7.4 || ^8.0"
},
"require-dev": {
"ergebnis\/license": "^1.1.0",
"ergebnis\/php-cs-fixer-config": "^3.4.0",
"fakerphp\/faker": "^1.17.0",
"infection\/infection": "~0.25.5",
"phpunit\/phpunit": "^9.5.11",
"psalm\/plugin-phpunit": "~0.16.1",
"vimeo\/psalm": "^4.16.1"
},
"time": "2021-12-27T12:39:13+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"RectorPrefix20220527\\Ergebnis\\Json\\Printer\\": "src\/"
}
},
"notification-url": "https:\/\/packagist.org\/downloads\/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andreas M\u00f6ller",
"email": "am@localheinz.com"
}
],
"description": "Provides a JSON printer, allowing for flexible indentation.",
"homepage": "https:\/\/github.com\/ergebnis\/json-printer",
"keywords": [
"formatter",
"json",
"printer"
],
"support": {
"issues": "https:\/\/github.com\/ergebnis\/json-printer\/issues",
"source": "https:\/\/github.com\/ergebnis\/json-printer"
},
"funding": [
{
"url": "https:\/\/github.com\/localheinz",
"type": "github"
}
],
"install-path": "..\/ergebnis\/json-printer"
},
{
"name": "evenement\/evenement",
"version": "v3.0.1",
@ -620,58 +554,6 @@
],
"install-path": "..\/helmich\/typo3-typoscript-parser"
},
{
"name": "idiosyncratic\/editorconfig",
"version": "0.1.3",
"version_normalized": "0.1.3.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/idiosyncratic-code\/editorconfig-php.git",
"reference": "3445fa4a1e00f95630d4edc729c2effb116db19b"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/idiosyncratic-code\/editorconfig-php\/zipball\/3445fa4a1e00f95630d4edc729c2effb116db19b",
"reference": "3445fa4a1e00f95630d4edc729c2effb116db19b",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"idiosyncratic\/coding-standard": "^2.0",
"php-parallel-lint\/php-console-highlighter": "^0.5",
"php-parallel-lint\/php-parallel-lint": "^1.3",
"phploc\/phploc": "^7.0",
"phpstan\/phpstan": "^0.12",
"phpunit\/phpunit": "^9.5",
"sebastian\/phpcpd": "^6.0"
},
"time": "2021-06-02T16:24:34+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\": "src"
}
},
"notification-url": "https:\/\/packagist.org\/downloads\/",
"license": [
"ISC"
],
"authors": [
{
"name": "Jason Silkey",
"email": "jason@jasonsilkey.com"
}
],
"description": "PHP implementation of EditorConfig",
"support": {
"issues": "https:\/\/github.com\/idiosyncratic-code\/editorconfig-php\/issues",
"source": "https:\/\/github.com\/idiosyncratic-code\/editorconfig-php\/tree\/0.1.3"
},
"install-path": "..\/idiosyncratic\/editorconfig"
},
{
"name": "myclabs\/php-enum",
"version": "1.8.3",
@ -1377,27 +1259,27 @@
},
{
"name": "psr\/log",
"version": "2.0.0",
"version_normalized": "2.0.0.0",
"version": "3.0.0",
"version_normalized": "3.0.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/php-fig\/log.git",
"reference": "ef29f6d262798707a9edd554e2b82517ef3a9376"
"reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/php-fig\/log\/zipball\/ef29f6d262798707a9edd554e2b82517ef3a9376",
"reference": "ef29f6d262798707a9edd554e2b82517ef3a9376",
"url": "https:\/\/api.github.com\/repos\/php-fig\/log\/zipball\/fe5ea303b0887d5caefd3d431c3e61ad47037001",
"reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001",
"shasum": ""
},
"require": {
"php": ">=8.0.0"
},
"time": "2021-07-14T16:41:46+00:00",
"time": "2021-07-14T16:46:02+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
"dev-master": "3.x-dev"
}
},
"installation-source": "dist",
@ -1424,7 +1306,7 @@
"psr-3"
],
"support": {
"source": "https:\/\/github.com\/php-fig\/log\/tree\/2.0.0"
"source": "https:\/\/github.com\/php-fig\/log\/tree\/3.0.0"
},
"install-path": "..\/psr\/log"
},
@ -2786,12 +2668,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/sabbelasichon\/typo3-rector.git",
"reference": "a5a13630b2f0d68e9286e8adfb84c001ff3a69de"
"reference": "8f232e2f49185e111dab67f32b256553e057c897"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/sabbelasichon\/typo3-rector\/zipball\/a5a13630b2f0d68e9286e8adfb84c001ff3a69de",
"reference": "a5a13630b2f0d68e9286e8adfb84c001ff3a69de",
"url": "https:\/\/api.github.com\/repos\/sabbelasichon\/typo3-rector\/zipball\/8f232e2f49185e111dab67f32b256553e057c897",
"reference": "8f232e2f49185e111dab67f32b256553e057c897",
"shasum": ""
},
"require": {
@ -2811,7 +2693,7 @@
"phpunit\/phpunit": "^9.5",
"rector\/phpstan-rules": "^0.5",
"rector\/rector-generator": "dev-main",
"rector\/rector-src": "dev-main#ffd84e6",
"rector\/rector-src": "dev-main#cb07c30",
"symfony\/console": "^6.0",
"symplify\/coding-standard": "^10.2",
"symplify\/easy-coding-standard": "^10.2",
@ -2821,7 +2703,7 @@
"symplify\/vendor-patches": "^10.2",
"tracy\/tracy": "^2.8"
},
"time": "2022-05-27T15:24:23+00:00",
"time": "2022-05-27T16:29:27+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -1,153 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
For a full diff see [`3.2.0...main`][3.2.0...main].
## [`3.2.0`][3.2.0]
For a full diff see [`3.1.1...3.2.0`][3.1.1...3.2.0].
- Dropped support for PHP 7.2 ([#404]), by [@localheinz]
- Dropped support for PHP 7.3 ([#410]), by [@localheinz]
## [`3.1.1`][3.1.1]
For a full diff see [`3.1.0...3.1.1`][3.1.0...3.1.1].
### Changed
- Dropped support for PHP 7.1 ([#199]), by [@localheinz]
## [`3.1.0`][3.1.0]
For a full diff see [`3.0.2...3.1.0`][3.0.2...3.1.0].
### Added
- Added support for PHP 8.0 ([#172]), by [@localheinz]
## [`3.0.2`][3.0.2]
For a full diff see [`3.0.1...3.0.2`][3.0.1...3.0.2].
### Fixed
- Brought back support for PHP 7.1 ([#76]), by [@localheinz]
## [`3.0.1`][3.0.1]
For a full diff see [`3.0.0...3.0.1`][3.0.0...3.0.1].
### Fixed
- Removed an inappropriate `replace` configuration from `composer.json` ([#72]), by [@localheinz]
## [`3.0.0`][3.0.0]
For a full diff see [`2.0.1...3.0.0`][2.0.1...3.0.0].
### Changed
- Renamed vendor namespace `Localheinz` to `Ergebnis` after move to [@ergebnis] ([#67]), by [@localheinz]
Run
```
$ composer remove localheinz/json-printer
```
and
```
$ composer require ergebnis/json-printer
```
to update.
Run
```
$ find . -type f -exec sed -i '.bak' 's/Localheinz\\Json\\Printer/Ergebnis\\Json\\Printer/g' {} \;
```
to replace occurrences of `Localheinz\Json\Printer` with `Ergebnis\Json\Printer`.
Run
```
$ find -type f -name '*.bak' -delete
```
to delete backup files created in the previous step.
### Fixed
- Removed support for PHP 7.1 ([#55]), by [@localheinz]
- Required implicit dependencies `ext-json` and `ext-mbstring` explicitly ([#63]), by [@localheinz]
## [`2.0.1`][2.0.1]
For a full diff see [`2.0.0...2.0.1`][2.0.0...2.0.1].
### Fixed
- Started rejecting mixed tabs and spaces as indent ([#37]), by [@localheinz]
## [`2.0.0`][2.0.0]
For a full diff see [`1.1.0...2.0.0`][1.1.0...2.0.0].
### Changed
- Allowed specifying new-line character ([#33]), by [@localheinz]
## [`1.1.0`][1.1.0]
For a full diff see [`1.0.0...1.1.0`][1.0.0...1.1.0].
## [`1.0.0`][1.0.0]
For a full diff see [`8849fc6...1.0.0`][8849fc6...1.0.0].
[1.0.0]: https://github.com/ergebnis/json-printer/releases/tag/1.0.0
[1.1.0]: https://github.com/ergebnis/json-printer/releases/tag/1.1.0
[2.0.0]: https://github.com/ergebnis/json-printer/releases/tag/2.0.0
[2.0.1]: https://github.com/ergebnis/json-printer/releases/tag/2.0.1
[3.0.0]: https://github.com/ergebnis/json-printer/releases/tag/3.0.0
[3.0.1]: https://github.com/ergebnis/json-printer/releases/tag/3.0.1
[3.0.2]: https://github.com/ergebnis/json-printer/releases/tag/3.0.2
[3.1.0]: https://github.com/ergebnis/json-printer/releases/tag/3.1.0
[3.1.1]: https://github.com/ergebnis/json-printer/releases/tag/3.1.1
[3.2.0]: https://github.com/ergebnis/json-printer/releases/tag/3.2.0
[8849fc6...1.0.0]: https://github.com/ergebnis/json-printer/compare/8849fc6...1.0.0
[1.0.0...1.1.0]: https://github.com/ergebnis/json-printer/compare/1.0.0...1.1.0
[1.1.0...2.0.0]: https://github.com/ergebnis/json-printer/compare/1.1.0...2.0.0
[2.0.0...2.0.1]: https://github.com/ergebnis/json-printer/compare/2.0.0...2.0.1
[2.0.1...3.0.0]: https://github.com/ergebnis/json-printer/compare/2.0.1...3.0.0
[3.0.0...3.0.1]: https://github.com/ergebnis/json-printer/compare/3.0.0...3.0.1
[3.0.1...3.0.2]: https://github.com/ergebnis/json-printer/compare/3.0.1...3.0.2
[3.0.2...3.1.0]: https://github.com/ergebnis/json-printer/compare/3.0.2...3.1.0
[3.1.0...3.1.1]: https://github.com/ergebnis/json-printer/compare/3.1.0...3.1.1
[3.1.1...3.2.0]: https://github.com/ergebnis/json-printer/compare/3.1.1...3.2.0
[3.2.0...main]: https://github.com/ergebnis/json-printer/compare/3.2.0...main
[#33]: https://github.com/ergebnis/json-printer/pull/33
[#37]: https://github.com/ergebnis/json-printer/pull/37
[#55]: https://github.com/ergebnis/json-printer/pull/55
[#63]: https://github.com/ergebnis/json-printer/pull/63
[#67]: https://github.com/ergebnis/json-printer/pull/67
[#72]: https://github.com/ergebnis/json-printer/pull/72
[#76]: https://github.com/ergebnis/json-printer/pull/77
[#172]: https://github.com/ergebnis/json-printer/pull/172
[#199]: https://github.com/ergebnis/json-printer/pull/199
[#404]: https://github.com/ergebnis/json-printer/pull/404
[#410]: https://github.com/ergebnis/json-printer/pull/410
[@ergebnis]: https://github.com/ergebnis
[@localheinz]: https://github.com/localheinz

View File

@ -1,16 +0,0 @@
# The MIT License (MIT)
Copyright (c) 2018-2021 Andreas Möller
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the _Software_), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED **AS IS**, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,104 +0,0 @@
# json-printer
[![Integrate](https://github.com/ergebnis/json-printer/workflows/Integrate/badge.svg)](https://github.com/ergebnis/json-printer/actions)
[![Merge](https://github.com/ergebnis/json-printer/workflows/Merge/badge.svg)](https://github.com/ergebnis/json-printer/actions)
[![Prune](https://github.com/ergebnis/json-printer/workflows/Prune/badge.svg)](https://github.com/ergebnis/json-printer/actions)
[![Release](https://github.com/ergebnis/json-printer/workflows/Release/badge.svg)](https://github.com/ergebnis/json-printer/actions)
[![Renew](https://github.com/ergebnis/json-printer/workflows/Renew/badge.svg)](https://github.com/ergebnis/json-printer/actions)
[![Code Coverage](https://codecov.io/gh/ergebnis/json-printer/branch/main/graph/badge.svg)](https://codecov.io/gh/ergebnis/json-printer)
[![Type Coverage](https://shepherd.dev/github/ergebnis/json-printer/coverage.svg)](https://shepherd.dev/github/ergebnis/json-printer)
[![Latest Stable Version](https://poser.pugx.org/ergebnis/json-printer/v/stable)](https://packagist.org/packages/ergebnis/json-printer)
[![Total Downloads](https://poser.pugx.org/ergebnis/json-printer/downloads)](https://packagist.org/packages/ergebnis/json-printer)
Provides a JSON printer, allowing for flexible indentation.
## Installation
Run
```sh
$ composer require ergebnis/json-printer
```
## Usage
Let's assume we have a variable `$json` which contains some JSON that is not indented:
```json
{"name":"Andreas Möller","emoji":"🤓","urls":["https://localheinz.com","https://github.com/localheinz","https://twitter.com/localheinz"]}
```
or indented with 4 spaces:
```json
{
"name":"Andreas Möller",
"emoji":"🤓",
"urls":[
"https://localheinz.com",
"https://github.com/localheinz",
"https://twitter.com/localheinz"
]
}
```
but we want to indent it with 2 spaces (or tabs).
This is where `Ergebnis\Json\Printer\Printer` comes in
```php
use Ergebnis\Json\Printer\Printer;
$printer = new Printer();
$printed = $printer->print(
$json,
' '
);
```
which results in `$printed`:
```json
{
"name":"Andreas Möller",
"emoji":"🤓",
"urls":[
"https://localheinz.com",
"https://github.com/localheinz",
"https://twitter.com/localheinz"
]
}
```
:bulb: Note that this printer is only concerned with normalizing the indentation, no escaping or un-escaping occurs.
## Changelog
Please have a look at [`CHANGELOG.md`](CHANGELOG.md).
## Contributing
Please have a look at [`CONTRIBUTING.md`](.github/CONTRIBUTING.md).
## Code of Conduct
Please have a look at [`CODE_OF_CONDUCT.md`](https://github.com/ergebnis/.github/blob/main/CODE_OF_CONDUCT.md).
## License
This package is licensed using the MIT License.
Please have a look at [`LICENSE.md`](LICENSE.md).
## Credits
The [`Printer`](src/Printer.php) is adopted from [`Composer\Json\JsonFormatter`](https://github.com/composer/composer/blob/1.6.0/src/Composer/Json/JsonFormatter.php) (originally licensed under MIT by [Nils Adermann](https://github.com/naderman) and [Jordi Boggiano](https://github.com/seldaek)), who adopted it from a [blog post by Dave Perrett](https://www.daveperrett.com/articles/2008/03/11/format-json-with-php/) (originally licensed under MIT by [Dave Perrett](https://github.com/recurser)).
The [`PrinterTest`](test/Unit/PrinterTest.php) is inspired by [`Composer\Test\Json\JsonFormatterTest`](https://github.com/composer/composer/blob/1.6.0/tests/Composer/Test/Json/JsonFormatterTest.php) (originally licensed under MIT by [Nils Adermann](https://github.com/naderman) and [Jordi Boggiano](https://github.com/seldaek)), as well as [`ZendTest\Json\JsonTest`](https://github.com/zendframework/zend-json/blob/release-3.0.0/test/JsonTest.php) (originally licensed under New BSD License).
## Curious what I am building?
:mailbox_with_mail: [Subscribe to my list](https://localheinz.com/projects/), and I will occasionally send you an email to let you know what I am working on.

View File

@ -1,57 +0,0 @@
{
"name": "ergebnis\/json-printer",
"type": "library",
"description": "Provides a JSON printer, allowing for flexible indentation.",
"keywords": [
"json",
"printer",
"formatter"
],
"homepage": "https:\/\/github.com\/ergebnis\/json-printer",
"license": "MIT",
"authors": [
{
"name": "Andreas M\u00f6ller",
"email": "am@localheinz.com"
}
],
"require": {
"php": "^7.4 || ^8.0",
"ext-json": "*",
"ext-mbstring": "*"
},
"require-dev": {
"ergebnis\/license": "^1.1.0",
"ergebnis\/php-cs-fixer-config": "^3.4.0",
"fakerphp\/faker": "^1.17.0",
"infection\/infection": "~0.25.5",
"phpunit\/phpunit": "^9.5.11",
"psalm\/plugin-phpunit": "~0.16.1",
"vimeo\/psalm": "^4.16.1"
},
"config": {
"allow-plugins": {
"composer\/package-versions-deprecated": true,
"infection\/extension-installer": true
},
"platform": {
"php": "7.4.26"
},
"preferred-install": "dist",
"sort-packages": true
},
"autoload": {
"psr-4": {
"RectorPrefix20220527\\Ergebnis\\Json\\Printer\\": "src\/"
}
},
"autoload-dev": {
"psr-4": {
"RectorPrefix20220527\\Ergebnis\\Json\\Printer\\Test\\": "test\/"
}
},
"support": {
"issues": "https:\/\/github.com\/ergebnis\/json-printer\/issues",
"source": "https:\/\/github.com\/ergebnis\/json-printer"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,129 +0,0 @@
<?php
declare (strict_types=1);
/**
* Copyright (c) 2018-2021 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/json-printer
*/
namespace RectorPrefix20220527\Ergebnis\Json\Printer;
final class Printer implements \RectorPrefix20220527\Ergebnis\Json\Printer\PrinterInterface
{
/**
* This code is adopted from composer/composer (originally licensed under MIT by Nils Adermann <naderman@naderman.de>
* and Jordi Boggiano <j.boggiano@seld.be>), who adopted it from a blog post by Dave Perrett (originally licensed
* under MIT by Dave Perrett <mail@recursive-design.com>).
*
* The primary objective of the adoption is
*
* - turn static method into an instance method
* - allow to specify indent
* - allow to specify new-line character sequence
*
* If you observe closely, the options for un-escaping unicode characters and slashes have been removed. Since this
* package requires PHP 7, there is no need to implement this in user-land code.
*
* @see https://github.com/composer/composer/blob/1.6.0/src/Composer/Json/JsonFormatter.php#L25-L126
* @see https://www.daveperrett.com/articles/2008/03/11/format-json-with-php/
* @see http://php.net/manual/en/function.json-encode.php
* @see http://php.net/manual/en/json.constants.php
*
* @throws \InvalidArgumentException
*/
public function print(string $json, string $indent = ' ', string $newLine = \PHP_EOL) : string
{
if (null === \json_decode($json) && \JSON_ERROR_NONE !== \json_last_error()) {
throw new \InvalidArgumentException(\sprintf('"%s" is not valid JSON.', $json));
}
if (1 !== \preg_match('/^( +|\\t+)$/', $indent)) {
throw new \InvalidArgumentException(\sprintf('"%s" is not a valid indent.', $indent));
}
if (1 !== \preg_match('/^(?>\\r\\n|\\n|\\r)$/', $newLine)) {
throw new \InvalidArgumentException(\sprintf('"%s" is not a valid new-line character sequence.', $newLine));
}
$printed = '';
$indentLevel = 0;
$length = \mb_strlen($json);
$withinStringLiteral = \false;
$stringLiteral = '';
$noEscape = \true;
for ($i = 0; $i < $length; ++$i) {
/**
* Grab the next character in the string.
*/
$character = \mb_substr($json, $i, 1);
/**
* Are we inside a quoted string literal?
*/
if ('"' === $character && $noEscape) {
$withinStringLiteral = !$withinStringLiteral;
}
/**
* Collect characters if we are inside a quoted string literal.
*/
if ($withinStringLiteral) {
$stringLiteral .= $character;
$noEscape = '\\' === $character ? !$noEscape : \true;
continue;
}
/**
* Process string literal if we are about to leave it.
*/
if ('' !== $stringLiteral) {
$printed .= $stringLiteral . $character;
$stringLiteral = '';
continue;
}
/**
* Ignore whitespace outside of string literal.
*/
if ('' === \trim($character)) {
continue;
}
/**
* Ensure space after ":" character.
*/
if (':' === $character) {
$printed .= ': ';
continue;
}
/**
* Output a new line after "," character and and indent the next line.
*/
if (',' === $character) {
$printed .= $character . $newLine . \str_repeat($indent, $indentLevel);
continue;
}
/**
* Output a new line after "{" and "[" and indent the next line.
*/
if ('{' === $character || '[' === $character) {
++$indentLevel;
$printed .= $character . $newLine . \str_repeat($indent, $indentLevel);
continue;
}
/**
* Output a new line after "}" and "]" and indent the next line.
*/
if ('}' === $character || ']' === $character) {
--$indentLevel;
$trimmed = \rtrim($printed);
$previousNonWhitespaceCharacter = \mb_substr($trimmed, -1);
/**
* Collapse empty {} and [].
*/
if ('{' === $previousNonWhitespaceCharacter || '[' === $previousNonWhitespaceCharacter) {
$printed = $trimmed . $character;
continue;
}
$printed .= $newLine . \str_repeat($indent, $indentLevel);
}
$printed .= $character;
}
return $printed;
}
}

View File

@ -1,20 +0,0 @@
<?php
declare (strict_types=1);
/**
* Copyright (c) 2018-2021 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/json-printer
*/
namespace RectorPrefix20220527\Ergebnis\Json\Printer;
interface PrinterInterface
{
/**
* @throws \InvalidArgumentException
*/
public function print(string $json, string $indent = ' ', string $newLine = \PHP_EOL) : string;
}

View File

@ -1,29 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.1.3] - 2021-06-02
### Fixed
- Fixed issues with globbing files on Windows
## [0.1.2] - 2021-05-31
### Fixed
- Updated dependencies
- Dev dependencies now support PHP8
## [0.1.1] - 2021-05-03
### Changed
- Validation for rules is now case-insensitive
### Fixed
- Supports comments beginning with #
- Better support for curly braces in editorconfig rules
## [0.1.0] - 2019-12-04
Initial Release
### Added
- Resolves editor settings for file/path
- Prints resolved editor settings

View File

@ -1,15 +0,0 @@
ISC License
Copyright (c) 2019 Jason Silkey
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@ -1,28 +0,0 @@
# EditorConfig PHP
PHP implementation of [EditorConfig](https://editorconfig.org)
## Installation
Install with [Composer](https://getcomposer.org):
```
composer require idiosyncratic/editorconfig
```
## Usage
```php
<?php
require_once('vendor/autoload.php');
use Idiosyncratic\EditorConfig\EditorConfig;
$ec = new EditorConfig();
// $config will be an array of the declarations matching for the specified path
$config = $ec->getConfigForPath(__FILE__);
// Print matching configuration rules as string
print $ec->printConfigForPath(__FILE__) . PHP_EOL;
```

View File

@ -1,43 +0,0 @@
{
"name": "idiosyncratic\/editorconfig",
"description": "PHP implementation of EditorConfig",
"type": "library",
"license": "ISC",
"authors": [
{
"name": "Jason Silkey",
"email": "jason@jasonsilkey.com"
}
],
"require": {
"php": ">=7.3"
},
"require-dev": {
"idiosyncratic\/coding-standard": "^2.0",
"php-parallel-lint\/php-console-highlighter": "^0.5",
"php-parallel-lint\/php-parallel-lint": "^1.3",
"phploc\/phploc": "^7.0",
"phpstan\/phpstan": "^0.12",
"phpunit\/phpunit": "^9.5",
"sebastian\/phpcpd": "^6.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true,
"discard-changes": true,
"bin-dir": "bin"
},
"autoload": {
"psr-4": {
"RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"RectorPrefix20220527\\Idiosyncratic\\EditorConfig\\": "tests"
}
}
}

View File

@ -1,16 +0,0 @@
<?xml version="1.0"?>
<ruleset>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<!-- Directories to be checked -->
<file>src</file>
<rule ref="Idiosyncratic" />
</ruleset>

View File

@ -1,4 +0,0 @@
parameters:
level: 7
paths:
- src

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
verbose="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
</phpunit>

View File

@ -1,19 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue;
use function is_bool;
abstract class BooleanDeclaration extends \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Declaration
{
/**
* @inheritdoc
*/
public function validateValue($value) : void
{
if (\is_bool($value) === \false) {
throw new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue($this->getStringValue(), $this->getName());
}
}
}

View File

@ -1,26 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue;
use function in_array;
use function is_string;
use function strtolower;
final class Charset extends \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Declaration
{
public const CHARSETS = ['latin1', 'utf-8', 'utf-8-bom', 'utf-16be', 'utf-16le'];
/**
* @inheritdoc
*/
public function validateValue($value) : void
{
if (\is_string($value) === \false || \in_array(\strtolower($value), self::CHARSETS) === \false) {
throw new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue($this->getStringValue(), $this->getName());
}
}
public function getName() : string
{
return 'charset';
}
}

View File

@ -1,79 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use function in_array;
use function is_numeric;
use function sprintf;
use function strtolower;
abstract class Declaration
{
/** @var string */
private $name;
/** @var string */
private $stringValue;
/** @var mixed */
private $value;
public function __construct(string $value)
{
$typedValue = $this->getTypedValue($value);
$this->setStringValue($value);
$this->validateValue($typedValue);
$this->setValue($typedValue);
}
public function getName() : string
{
return $this->name;
}
/**
* @return mixed
*/
public final function getValue()
{
return $this->value;
}
public final function getStringValue() : string
{
return $this->stringValue;
}
/**
* @param mixed $value
*/
public function validateValue($value) : void
{
return;
}
public final function __toString() : string
{
return \sprintf('%s=%s', $this->getName(), $this->getStringValue());
}
protected function setName(string $name) : void
{
$this->name = \strtolower($name);
}
/**
* @return mixed
*/
protected function getTypedValue(string $value)
{
if (\in_array($value, ['true', 'false']) === \true) {
return $value === 'true';
}
if (\is_numeric($value) === \true && (string) (int) $value === $value) {
return (int) $value;
}
return $value;
}
protected final function setStringValue(string $value) : void
{
$this->stringValue = $value;
}
/**
* @param mixed $value
*/
protected final function setValue($value) : void
{
$this->value = $value;
}
}

View File

@ -1,26 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue;
use function in_array;
use function is_string;
use function strtolower;
final class EndOfLine extends \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Declaration
{
public const LINE_ENDINGS = ['lf', 'cr', 'crlf'];
/**
* @inheritdoc
*/
public function validateValue($value) : void
{
if (\is_string($value) === \false || \in_array(\strtolower($value), self::LINE_ENDINGS) === \false) {
throw new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue($this->getStringValue(), $this->getName());
}
}
public function getName() : string
{
return 'end_of_line';
}
}

View File

@ -1,82 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use function method_exists;
use function sprintf;
use function str_replace;
use function ucwords;
final class Factory
{
/**
* @param mixed $value
*/
public function getDeclaration(string $name, $value) : \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Declaration
{
if ($value === 'unset') {
return new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\UnsetDeclaration($name);
}
$method = \sprintf('get%s', \ucwords(\str_replace(['-', '_'], '', $name)));
if (\method_exists($this, $method) === \true) {
return $this->{$method}($value);
}
return new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\GenericDeclaration($name, $value);
}
/**
* @param mixed $value
*/
public function getIndentStyle($value) : \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\IndentStyle
{
return new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\IndentStyle($value);
}
/**
* @param mixed $value
*/
public function getCharset($value) : \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Charset
{
return new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Charset($value);
}
/**
* @param mixed $value
*/
public function getEndOfLine($value) : \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\EndOfLine
{
return new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\EndOfLine($value);
}
/**
* @param mixed $value
*/
public function getInsertFinalNewline($value) : \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\InsertFinalNewline
{
return new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\InsertFinalNewline($value);
}
/**
* @param mixed $value
*/
public function getTrimTrailingWhitespace($value) : \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\TrimTrailingWhitespace
{
return new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\TrimTrailingWhitespace($value);
}
/**
* @param mixed $value
*/
public function getIndentSize($value) : \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\IndentSize
{
return new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\IndentSize($value);
}
/**
* @param mixed $value
*/
public function getTabWidth($value) : \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\TabWidth
{
return new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\TabWidth($value);
}
/**
* @param mixed $value
*/
public function getMaxLineLength($value) : \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\MaxLineLength
{
return new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\MaxLineLength($value);
}
}

View File

@ -1,13 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
final class GenericDeclaration extends \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Declaration
{
public function __construct(string $name, string $value)
{
$this->setName($name);
parent::__construct($value);
}
}

View File

@ -1,23 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue;
use function is_int;
final class IndentSize extends \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Declaration
{
public function getName() : string
{
return 'indent_size';
}
/**
* @inheritdoc
*/
public function validateValue($value) : void
{
if ($value !== 'tab' && (\is_int($value) === \false || $value < 1 === \true)) {
throw new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue($this->getStringValue(), $this->getName());
}
}
}

View File

@ -1,25 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue;
use function in_array;
use function is_string;
use function strtolower;
final class IndentStyle extends \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Declaration
{
public function getName() : string
{
return 'indent_style';
}
/**
* @inheritdoc
*/
public function validateValue($value) : void
{
if (\is_string($value) === \false || \in_array(\strtolower($value), ['tab', 'space']) === \false) {
throw new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue($this->getStringValue(), $this->getName());
}
}
}

View File

@ -1,12 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
final class InsertFinalNewline extends \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\BooleanDeclaration
{
public function getName() : string
{
return 'insert_final_newline';
}
}

View File

@ -1,23 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue;
use function is_int;
final class MaxLineLength extends \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Declaration
{
public function getName() : string
{
return 'max_line_length';
}
/**
* @inheritdoc
*/
public function validateValue($value) : void
{
if ($value !== 'off' && (\is_int($value) === \false || $value < 1 === \true)) {
throw new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue($this->getStringValue(), $this->getName());
}
}
}

View File

@ -1,23 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue;
use function is_int;
final class TabWidth extends \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Declaration
{
public function getName() : string
{
return 'tab_width';
}
/**
* @inheritdoc
*/
public function validateValue($value) : void
{
if (\is_int($value) === \false || $value < 1 === \true) {
throw new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue($this->getStringValue(), $this->getName());
}
}
}

View File

@ -1,12 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
final class TrimTrailingWhitespace extends \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\BooleanDeclaration
{
public function getName() : string
{
return 'trim_trailing_whitespace';
}
}

View File

@ -1,20 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
final class UnsetDeclaration extends \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Declaration
{
public function __construct(string $name)
{
$this->setName($name);
parent::__construct('unset');
}
/**
* @return mixed
*/
protected function getTypedValue(string $value)
{
return null;
}
}

View File

@ -1,71 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig;
use function array_merge;
use function array_pop;
use function dirname;
use function implode;
use function is_file;
use function is_readable;
use function realpath;
use function sprintf;
use const DIRECTORY_SEPARATOR;
final class EditorConfig
{
/** @var array<string, EditorConfigFile> */
private $configFiles = [];
/**
* @return array<string, mixed>
*/
public function getConfigForPath(string $path) : array
{
$configFiles = $this->locateConfigFiles($path);
$root = \false;
$configuration = [];
$configFile = \array_pop($configFiles);
while ($configFile !== null) {
$configuration = \array_merge($configuration, $configFile->getConfigForPath($path));
$configFile = \array_pop($configFiles);
}
foreach ($configuration as $key => $declaration) {
if ($declaration->getValue() !== null) {
continue;
}
unset($configuration[$key]);
}
return $configuration;
}
public function printConfigForPath(string $path) : string
{
$config = $this->getConfigForPath($path);
return \implode("\n", $config);
}
/**
* @return array<EditorConfigFile>
*/
private function locateConfigFiles(string $path) : array
{
$files = [];
$stop = \false;
$parent = '';
while ($parent !== $path) {
$editorConfigFile = \realpath(\sprintf('%s%s.editorconfig', $path, \DIRECTORY_SEPARATOR));
if ($editorConfigFile !== \false && \is_file($editorConfigFile) && \is_readable($editorConfigFile)) {
$file = $this->getConfigFile($editorConfigFile);
$files[] = $file;
if ($file->isRoot() === \true) {
break;
}
}
$path = \dirname($path);
$parent = \dirname($path);
}
return $files;
}
private function getConfigFile(string $path) : \RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfigFile
{
return $this->configFiles[$path] ?? ($this->configFiles[$path] = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfigFile($path));
}
}

View File

@ -1,117 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Factory;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue;
use RuntimeException;
use function array_merge;
use function dirname;
use function file_get_contents;
use function implode;
use function in_array;
use function is_array;
use function is_file;
use function is_readable;
use function parse_ini_string;
use function preg_replace;
use function sprintf;
use function strpos;
use const INI_SCANNER_RAW;
final class EditorConfigFile
{
/** @var string */
private $path;
/** @var string */
private $fileContent = '';
/** @var bool */
private $isRoot = \false;
/** @var array<int, Section> */
private $sections = [];
/** @var Factory */
private $declarationFactory;
public function __construct(string $path, ?\RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Factory $declarationFactory = null)
{
$this->declarationFactory = $declarationFactory ?? new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Factory();
if (\is_file($path) === \false || \is_readable($path) === \false) {
throw new \RuntimeException(\sprintf('File %s does not exist or is not readable', $path));
}
$content = $this->cleanContent($path);
$this->path = $path;
$this->parse($content);
}
public function __toString() : string
{
$preamble = $this->isRoot() === \true ? "root=true\n" : '';
$sections = [];
foreach ($this->sections as $section) {
$sections[] = (string) $section;
}
return \sprintf('%s%s', $preamble, \implode("\n", $sections));
}
public function isRoot() : bool
{
return $this->isRoot;
}
public function getPath() : string
{
return $this->path;
}
/**
* @return array<string, mixed>
*/
public function getConfigForPath(string $path) : array
{
$configuration = [];
foreach ($this->sections as $section) {
if ($section->matches($path) === \false) {
continue;
}
$configuration = \array_merge($configuration, $section->getDeclarations());
}
return $configuration;
}
private function parse(string $content) : void
{
$this->fileContent = $content;
$content = \preg_replace('/^\\s/m', '', $this->fileContent) ?? $this->fileContent;
$parsedContent = $this->parseIniString($content);
if (isset($parsedContent['root']) === \true) {
$this->setIsRoot($parsedContent['root']);
}
foreach ($parsedContent as $glob => $declarations) {
if (\is_array($declarations) === \false) {
continue;
}
$this->sections[] = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Section($this->getGlobPrefix($glob), $glob, $declarations, $this->declarationFactory);
}
}
private function setIsRoot(string $isRoot) : void
{
if (\in_array($isRoot, ['true', 'false']) === \false) {
throw new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue('root', $isRoot);
}
$this->isRoot = $isRoot === 'true';
}
private function getGlobPrefix(string $glob) : string
{
return \strpos($glob, '/') === 0 ? \dirname($this->path) : '**/';
}
/**
* @return array<string, mixed>
*/
private function parseIniString(string $content) : array
{
$parsedContent = \parse_ini_string($content, \true, \INI_SCANNER_RAW);
return \is_array($parsedContent) === \true ? $parsedContent : [];
}
private function cleanContent(string $path) : string
{
$content = \file_get_contents($path);
if ($content === \false) {
return '';
}
return \preg_replace('/#.*$/m', '', $content) ?? $content;
}
}

View File

@ -1,14 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception;
use DomainException;
use function sprintf;
class InvalidValue extends \DomainException
{
public function __construct(string $declaration, string $value)
{
parent::__construct(\sprintf('%s is not a valid value for \'%s\'', $declaration, $value));
}
}

View File

@ -1,109 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig;
use ErrorException;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Factory;
use function array_key_exists;
use function debug_backtrace;
use function explode;
use function fnmatch;
use function implode;
use function preg_match;
use function preg_match_all;
use function sprintf;
use function str_replace;
use const PREG_SET_ORDER;
final class Section
{
/** @var string */
private $globPrefix;
/** @var string */
private $glob;
/** @var array<string, mixed> */
private $declarations = [];
/** @var Factory */
private $declarationFactory;
/**
* @param array<string, mixed> $declarations
*/
public function __construct(string $globPrefix, string $glob, array $declarations, \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Factory $declarationFactory)
{
$this->globPrefix = $globPrefix;
$this->glob = $glob;
$this->declarationFactory = $declarationFactory;
$this->setDeclarations($declarations);
}
public function __toString() : string
{
return \sprintf("[%s]\n%s\n", $this->glob, \implode("\n", $this->getDeclarations()));
}
/**
* @return array<string, mixed>
*/
public function getDeclarations() : array
{
return $this->declarations;
}
public function matches(string $path) : bool
{
// normalize path to unix-style directory separator,
// because the glob pattern assumes linux-style directory separators
$path = \str_replace('\\', '/', $path);
if (\preg_match('#{(.*)}#', $this->glob) === 1) {
return $this->matchesWithCurlBracesExpansion($path);
}
$pattern = \sprintf('%s%s', $this->globPrefix, $this->glob);
return \fnmatch($pattern, $path);
}
/**
* @param array<string, mixed> $declarations
*/
private function setDeclarations(array $declarations) : void
{
foreach ($declarations as $name => $value) {
$this->setDeclaration($name, $value);
}
}
/**
* @param mixed $value
*/
private function setDeclaration(string $name, $value) : void
{
$declaration = $this->declarationFactory->getDeclaration($name, $value);
$this->declarations[$declaration->getName()] = $declaration;
}
/**
* @return mixed
*/
public function __get(string $property)
{
if (isset($this->declarations[$property]) === \true) {
return $this->declarations[$property];
}
$trace = \debug_backtrace();
throw new \ErrorException(\sprintf('Undefined property: %s in %s on line %s', $property, $trace[0]['file'], $trace[0]['line']));
}
public function __isset(string $property) : bool
{
return \array_key_exists($property, $this->declarations);
}
private function matchesWithCurlBracesExpansion(string $path) : bool
{
\preg_match_all('#(?<prefix>.*){(?<subpattern>.*)}#', $this->glob, $matches, \PREG_SET_ORDER);
foreach ($matches as $match) {
if (\array_key_exists('subpattern', $match) === \false) {
continue;
}
$subPatterns = \explode(',', $match['subpattern']);
foreach ($subPatterns as $subPattern) {
$pattern = \sprintf('%s%s', $this->globPrefix, $match['prefix'] . $subPattern);
if (\fnmatch($pattern, $path)) {
return \true;
}
}
}
return \false;
}
}

View File

@ -1,25 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue;
use RectorPrefix20220527\PHPUnit\Framework\TestCase;
use RuntimeException;
class CharsetTest extends \RectorPrefix20220527\PHPUnit\Framework\TestCase
{
public function testValidValues()
{
foreach (\RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Charset::CHARSETS as $charset) {
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Charset($charset);
$this->assertEquals(\sprintf('charset=%s', $charset), (string) $declaration);
}
}
public function testInvalidValue()
{
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Charset('true');
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Charset('spaces');
}
}

View File

@ -1,25 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use DomainException;
use RectorPrefix20220527\PHPUnit\Framework\TestCase;
use RuntimeException;
class EndOfLineTest extends \RectorPrefix20220527\PHPUnit\Framework\TestCase
{
public function testValidValues()
{
foreach (\RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\EndOfLine::LINE_ENDINGS as $eol) {
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\EndOfLine($eol);
$this->assertEquals(\sprintf('end_of_line=%s', $eol), (string) $declaration);
}
}
public function testInvalidValues()
{
$this->expectException(\DomainException::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\EndOfLine('true');
$this->expectException(\DomainException::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\EndOfLine('spaces');
}
}

View File

@ -1,32 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use DomainException;
use RectorPrefix20220527\PHPUnit\Framework\TestCase;
use RuntimeException;
class FactoryTest extends \RectorPrefix20220527\PHPUnit\Framework\TestCase
{
public function testOfficialDeclarations()
{
$declarations = ['indent_style' => 'space', 'indent_size' => '4', 'tab_width' => '4', 'end_of_line' => 'lf', 'charset' => 'utf-8', 'trim_trailing_whitespace' => 'true', 'insert_final_newline' => 'false', 'max_line_length' => 'off'];
$factory = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Factory();
foreach ($declarations as $key => $value) {
$declaration = $factory->getDeclaration($key, $value);
$this->assertEquals($key, $declaration->getName());
}
}
public function testUnsetDeclaration()
{
$factory = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Factory();
$indentSize = $factory->getDeclaration('indent_size', 'unset');
$this->assertInstanceOf(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\UnsetDeclaration::class, $indentSize);
}
public function testUnknownDeclaration()
{
$factory = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Factory();
$justification = $factory->getDeclaration('justification', 'left');
$this->assertInstanceOf(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\GenericDeclaration::class, $justification);
}
}

View File

@ -1,37 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use RectorPrefix20220527\PHPUnit\Framework\TestCase;
class GenericDeclarationTest extends \RectorPrefix20220527\PHPUnit\Framework\TestCase
{
public function testGetName() : void
{
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\GenericDeclaration('declaration', 'string');
$this->assertEquals('declaration', $declaration->getName());
}
public function testGetValue() : void
{
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\GenericDeclaration('declaration', 'string');
$this->assertIsString($declaration->getValue());
$this->assertEquals('string', $declaration->getValue());
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\GenericDeclaration('declaration', '1');
$this->assertIsInt($declaration->getValue());
$this->assertSame(1, $declaration->getValue());
$this->assertSame('1', $declaration->getStringValue());
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\GenericDeclaration('declaration', 'true');
$this->assertIsBool($declaration->getValue());
$this->assertTrue($declaration->getValue());
$this->assertSame('true', $declaration->getStringValue());
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\GenericDeclaration('declaration', '1.1');
$this->assertIsString($declaration->getValue());
$this->assertSame('1.1', $declaration->getValue());
$this->assertSame('1.1', $declaration->getStringValue());
}
public function testToString() : void
{
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\GenericDeclaration('declaration', 'string');
$this->assertEquals('declaration=string', (string) $declaration);
}
}

View File

@ -1,34 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue;
use RectorPrefix20220527\PHPUnit\Framework\TestCase;
use RuntimeException;
class IndentSizeTest extends \RectorPrefix20220527\PHPUnit\Framework\TestCase
{
public function testValidValues()
{
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\IndentSize('tab');
$this->assertEquals('indent_size=tab', (string) $declaration);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\IndentSize('4');
$this->assertEquals('indent_size=4', (string) $declaration);
$this->assertSame(4, $declaration->getValue());
}
public function testInvalidValueType()
{
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\IndentSize('true');
}
public function testInvalidValueValue()
{
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\IndentSize('four');
}
public function testInvalidNegativeIntegerValue()
{
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\IndentSize('-1');
}
}

View File

@ -1,27 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue;
use RectorPrefix20220527\PHPUnit\Framework\TestCase;
use RuntimeException;
class IndentStyleTest extends \RectorPrefix20220527\PHPUnit\Framework\TestCase
{
public function testValidValues()
{
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\IndentStyle('tab');
$this->assertEquals('indent_style', $declaration->getName());
$this->assertEquals('tab', $declaration->getValue());
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\IndentStyle('space');
$this->assertEquals('indent_style', $declaration->getName());
$this->assertEquals('space', $declaration->getValue());
}
public function testInvalidValues()
{
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\IndentStyle('true');
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\IndentStyle('spaces');
}
}

View File

@ -1,25 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue;
use RectorPrefix20220527\PHPUnit\Framework\TestCase;
use RuntimeException;
class InsertFinalNewlineTest extends \RectorPrefix20220527\PHPUnit\Framework\TestCase
{
public function testValidValues()
{
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\InsertFinalNewline('false');
$this->assertEquals('insert_final_newline=false', (string) $declaration);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\InsertFinalNewline('true');
$this->assertEquals('insert_final_newline=true', (string) $declaration);
}
public function testInvalidValues()
{
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\InsertFinalNewline('4');
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\InsertFinalNewline('four');
}
}

View File

@ -1,27 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue;
use RectorPrefix20220527\PHPUnit\Framework\TestCase;
class MaxLineLengthTest extends \RectorPrefix20220527\PHPUnit\Framework\TestCase
{
public function testValidValues()
{
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\MaxLineLength('off');
$this->assertEquals('max_line_length=off', (string) $declaration);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\MaxLineLength('4');
$this->assertEquals('max_line_length=4', (string) $declaration);
$this->assertSame(4, $declaration->getValue());
}
public function testInvalidValues()
{
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\MaxLineLength('true');
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\MaxLineLength('four');
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\MaxLineLength('-1');
}
}

View File

@ -1,25 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue;
use RectorPrefix20220527\PHPUnit\Framework\TestCase;
class TabWidthTest extends \RectorPrefix20220527\PHPUnit\Framework\TestCase
{
public function testValidValues()
{
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\TabWidth('4');
$this->assertEquals('tab_width=4', (string) $declaration);
$this->assertSame(4, $declaration->getValue());
}
public function testInvalidValues()
{
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\TabWidth('true');
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\TabWidth('four');
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\TabWidth('-1');
}
}

View File

@ -1,28 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use DomainException;
use RectorPrefix20220527\PHPUnit\Framework\TestCase;
use RuntimeException;
class TrimTrailingWhitespaceTest extends \RectorPrefix20220527\PHPUnit\Framework\TestCase
{
public function testValidValues()
{
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\TrimTrailingWhitespace('false');
$this->assertEquals('trim_trailing_whitespace=false', (string) $declaration);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\TrimTrailingWhitespace('true');
$this->assertEquals('trim_trailing_whitespace=true', (string) $declaration);
}
public function testInvalidIntValue()
{
$this->expectException(\DomainException::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\TrimTrailingWhitespace('4');
}
public function testInvalidStringValue()
{
$this->expectException(\DomainException::class);
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\TrimTrailingWhitespace('four');
}
}

View File

@ -1,19 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration;
use DomainException;
use ErrorException;
use RectorPrefix20220527\PHPUnit\Framework\TestCase;
use RuntimeException;
class UnsetDeclarationTest extends \RectorPrefix20220527\PHPUnit\Framework\TestCase
{
public function testDeclaration()
{
$declaration = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\UnsetDeclaration('indent_style');
$this->assertEquals('indent_style', $declaration->getName());
$this->assertNull($declaration->getValue());
$this->assertEquals('indent_style=unset', (string) $declaration);
}
}

View File

@ -1,70 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue;
use RectorPrefix20220527\PHPUnit\Framework\TestCase;
use RuntimeException;
class EditorConfigFileTest extends \RectorPrefix20220527\PHPUnit\Framework\TestCase
{
public function testParseEditorConfigFile() : void
{
$path = __DIR__ . '/data/editorconfig';
$file = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfigFile($path);
$this->assertInstanceOf(\RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfigFile::class, $file);
$this->assertFalse($file->isRoot());
$this->assertEquals($path, $file->getPath());
}
public function testGetPath() : void
{
$path = __DIR__ . '/data/editorconfig';
$file = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfigFile($path);
$this->assertEquals($path, $file->getPath());
}
public function testEmptyFile() : void
{
$path = __DIR__ . '/data/empty_editorconfig';
$file = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfigFile($path);
$this->assertEquals('', \trim((string) $file));
}
public function testRootFile() : void
{
$path = __DIR__ . '/data/root_editorconfig';
$file = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfigFile($path);
$this->assertTrue($file->isRoot());
$this->assertTrue(\strpos((string) $file, 'root=true') === 0);
}
public function testInvalidRootValue() : void
{
$path = __DIR__ . '/data/invalid_root_editorconfig';
$this->expectException(\RectorPrefix20220527\Idiosyncratic\EditorConfig\Exception\InvalidValue::class);
$file = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfigFile($path);
}
public function testFileDoesNotExist() : void
{
$this->expectException(\RuntimeException::class);
$file = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfigFile(__DIR__);
}
public function testEmptyIndentSize() : void
{
$path = __DIR__ . '/data/editorconfig';
$file = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfigFile($path);
$config = $file->getConfigForPath(__DIR__);
$this->assertFalse(isset($config['indent_size']));
}
/**
* @dataProvider configForPath
*/
public function testGetConfigForPath(string $pathToFile, int $expectedIndentSize) : void
{
$path = __DIR__ . '/data/editorconfig';
$file = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfigFile($path);
$config = $file->getConfigForPath($pathToFile);
$this->assertEquals($expectedIndentSize, $config['indent_size']->getValue());
}
public function configForPath() : array
{
return ['This .php file has an indentation of 4' => [__FILE__, 4], 'The test.json file has an indentation of 2' => [__DIR__ . '/data/test.json', 2], 'The test.yml has an indentation of 98' => [__DIR__ . '/data/test.yml', 98], 'The test.js has an indentation of 27' => [__DIR__ . '/data/lib/test.js', 27]];
}
}

View File

@ -1,18 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig;
use RectorPrefix20220527\PHPUnit\Framework\TestCase;
use RuntimeException;
class EditorConfigTest extends \RectorPrefix20220527\PHPUnit\Framework\TestCase
{
public function testResolvingConfigForPath() : void
{
$ec = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\EditorConfig();
$config = $ec->getConfigForPath(__FILE__);
$this->assertEquals(4, $config['indent_size']->getValue());
$config = $ec->printConfigForPath(__DIR__ . '/data/testfile.php');
$this->assertFalse(\strpos($config, 'indent_size=4'));
}
}

View File

@ -1,29 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20220527\Idiosyncratic\EditorConfig;
use RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Factory;
use ErrorException;
use RectorPrefix20220527\PHPUnit\Framework\TestCase;
class SectionTest extends \RectorPrefix20220527\PHPUnit\Framework\TestCase
{
public function testGetDeclaration() : void
{
$section = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Section('**/', '*.php', ['indent_size' => '4', 'indent_style' => 'space'], new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Factory());
$this->assertEquals('space', $section->indent_style->getValue());
$this->assertEquals(4, $section->indent_size->getValue());
$this->assertFalse(isset($section->tab_width));
}
public function testMatchingWindowsPath() : void
{
$section = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Section('**/', '*.php', ['indent_size' => '4', 'indent_style' => 'space'], new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Factory());
$this->assertTrue($section->matches('my\\composer.php'));
}
public function testGetMissingDeclaration() : void
{
$section = new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Section('**/', '*.php', ['indent_size' => '4', 'indent_style' => 'space'], new \RectorPrefix20220527\Idiosyncratic\EditorConfig\Declaration\Factory());
$this->expectException(\ErrorException::class);
$section->tab_width;
}
}

View File

@ -1,27 +0,0 @@
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = space
[*.php]
indent_size = 4
[*.md]
trim_trailing_whitespace = false
[*.{yaml,js,json,json.dist,feature}]
indent_size = 2
# Indentation override for all JS under lib directory
[lib/**.js]
indent_style = space
indent_size = 27
# Matches the exact files either package.json or travis.yml
[{package.json,test.yml}]
indent_style = space
indent_size = 98
#[*.some]

View File

@ -1,2 +0,0 @@
[*]
somekey[something]=somevalue

View File

@ -1,14 +0,0 @@
root=yes
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = space
indent_size = 4
[*.md]
trim_trailing_whitespace = false
[*.{yaml,yml,js,json,json.dist,feature}]
indent_size = 2

View File

@ -1,14 +0,0 @@
root=true
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = space
indent_size = 4
[*.md]
trim_trailing_whitespace = false
[*.{yaml,yml,js,json,json.dist,feature}]
indent_size = 2

View File

@ -1,5 +0,0 @@
<?php
namespace RectorPrefix20220527;
return [];

View File

@ -24,7 +24,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
"dev-master": "3.x-dev"
}
}
}

View File

@ -14,5 +14,5 @@ interface LoggerAwareInterface
*
* @return void
*/
public function setLogger(\RectorPrefix20220527\Psr\Log\LoggerInterface $logger);
public function setLogger(\RectorPrefix20220527\Psr\Log\LoggerInterface $logger) : void;
}

View File

@ -18,7 +18,7 @@ trait LoggerAwareTrait
*
* @param LoggerInterface $logger
*/
public function setLogger(\RectorPrefix20220527\Psr\Log\LoggerInterface $logger)
public function setLogger(\RectorPrefix20220527\Psr\Log\LoggerInterface $logger) : void
{
$this->logger = $logger;
}

View File

@ -27,7 +27,7 @@ interface LoggerInterface
*
* @return void
*/
public function emergency($message, array $context = []);
public function emergency($message, array $context = []) : void;
/**
* Action must be taken immediately.
*
@ -39,7 +39,7 @@ interface LoggerInterface
*
* @return void
*/
public function alert($message, array $context = []);
public function alert($message, array $context = []) : void;
/**
* Critical conditions.
*
@ -50,7 +50,7 @@ interface LoggerInterface
*
* @return void
*/
public function critical($message, array $context = []);
public function critical($message, array $context = []) : void;
/**
* Runtime errors that do not require immediate action but should typically
* be logged and monitored.
@ -60,7 +60,7 @@ interface LoggerInterface
*
* @return void
*/
public function error($message, array $context = []);
public function error($message, array $context = []) : void;
/**
* Exceptional occurrences that are not errors.
*
@ -72,7 +72,7 @@ interface LoggerInterface
*
* @return void
*/
public function warning($message, array $context = []);
public function warning($message, array $context = []) : void;
/**
* Normal but significant events.
*
@ -81,7 +81,7 @@ interface LoggerInterface
*
* @return void
*/
public function notice($message, array $context = []);
public function notice($message, array $context = []) : void;
/**
* Interesting events.
*
@ -92,7 +92,7 @@ interface LoggerInterface
*
* @return void
*/
public function info($message, array $context = []);
public function info($message, array $context = []) : void;
/**
* Detailed debug information.
*
@ -101,7 +101,7 @@ interface LoggerInterface
*
* @return void
*/
public function debug($message, array $context = []);
public function debug($message, array $context = []) : void;
/**
* Logs with an arbitrary level.
*
@ -113,5 +113,5 @@ interface LoggerInterface
*
* @throws \Psr\Log\InvalidArgumentException
*/
public function log($level, $message, array $context = []);
public function log($level, $message, array $context = []) : void;
}

View File

@ -20,7 +20,7 @@ trait LoggerTrait
*
* @return void
*/
public function emergency($message, array $context = [])
public function emergency($message, array $context = []) : void
{
$this->log(\RectorPrefix20220527\Psr\Log\LogLevel::EMERGENCY, $message, $context);
}
@ -35,7 +35,7 @@ trait LoggerTrait
*
* @return void
*/
public function alert($message, array $context = [])
public function alert($message, array $context = []) : void
{
$this->log(\RectorPrefix20220527\Psr\Log\LogLevel::ALERT, $message, $context);
}
@ -49,7 +49,7 @@ trait LoggerTrait
*
* @return void
*/
public function critical($message, array $context = [])
public function critical($message, array $context = []) : void
{
$this->log(\RectorPrefix20220527\Psr\Log\LogLevel::CRITICAL, $message, $context);
}
@ -62,7 +62,7 @@ trait LoggerTrait
*
* @return void
*/
public function error($message, array $context = [])
public function error($message, array $context = []) : void
{
$this->log(\RectorPrefix20220527\Psr\Log\LogLevel::ERROR, $message, $context);
}
@ -77,7 +77,7 @@ trait LoggerTrait
*
* @return void
*/
public function warning($message, array $context = [])
public function warning($message, array $context = []) : void
{
$this->log(\RectorPrefix20220527\Psr\Log\LogLevel::WARNING, $message, $context);
}
@ -89,7 +89,7 @@ trait LoggerTrait
*
* @return void
*/
public function notice($message, array $context = [])
public function notice($message, array $context = []) : void
{
$this->log(\RectorPrefix20220527\Psr\Log\LogLevel::NOTICE, $message, $context);
}
@ -103,7 +103,7 @@ trait LoggerTrait
*
* @return void
*/
public function info($message, array $context = [])
public function info($message, array $context = []) : void
{
$this->log(\RectorPrefix20220527\Psr\Log\LogLevel::INFO, $message, $context);
}
@ -115,7 +115,7 @@ trait LoggerTrait
*
* @return void
*/
public function debug($message, array $context = [])
public function debug($message, array $context = []) : void
{
$this->log(\RectorPrefix20220527\Psr\Log\LogLevel::DEBUG, $message, $context);
}
@ -130,5 +130,5 @@ trait LoggerTrait
*
* @throws \Psr\Log\InvalidArgumentException
*/
public abstract function log($level, $message, array $context = []);
public abstract function log($level, $message, array $context = []) : void;
}

View File

@ -23,7 +23,7 @@ class NullLogger extends \RectorPrefix20220527\Psr\Log\AbstractLogger
*
* @throws \Psr\Log\InvalidArgumentException
*/
public function log($level, $message, array $context = [])
public function log($level, $message, array $context = []) : void
{
// noop
}

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 43ca394'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 4a907ed'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 784271e'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5853b39'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5f84d90'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e544f2a'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 28a6025'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 6e0ca50'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main a5a1363'));
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 43ca394'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 4a907ed'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 784271e'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5853b39'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5f84d90'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e544f2a'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 28a6025'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 6e0ca50'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 8f232e2'));
private function __construct()
{
}

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20220527\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitcb35e254f08652faad722828c850129e', false) && !interface_exists('ComposerAutoloaderInitcb35e254f08652faad722828c850129e', false) && !trait_exists('ComposerAutoloaderInitcb35e254f08652faad722828c850129e', false)) {
spl_autoload_call('RectorPrefix20220527\ComposerAutoloaderInitcb35e254f08652faad722828c850129e');
if (!class_exists('ComposerAutoloaderInit2ab66d11b53f9eefc2121becfa7d9f0f', false) && !interface_exists('ComposerAutoloaderInit2ab66d11b53f9eefc2121becfa7d9f0f', false) && !trait_exists('ComposerAutoloaderInit2ab66d11b53f9eefc2121becfa7d9f0f', false)) {
spl_autoload_call('RectorPrefix20220527\ComposerAutoloaderInit2ab66d11b53f9eefc2121becfa7d9f0f');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20220527\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20220527\print_node(...func_get_args());
}
}
if (!function_exists('composerRequirecb35e254f08652faad722828c850129e')) {
function composerRequirecb35e254f08652faad722828c850129e() {
return \RectorPrefix20220527\composerRequirecb35e254f08652faad722828c850129e(...func_get_args());
if (!function_exists('composerRequire2ab66d11b53f9eefc2121becfa7d9f0f')) {
function composerRequire2ab66d11b53f9eefc2121becfa7d9f0f() {
return \RectorPrefix20220527\composerRequire2ab66d11b53f9eefc2121becfa7d9f0f(...func_get_args());
}
}
if (!function_exists('scanPath')) {

View File

@ -30,7 +30,7 @@
"phpunit\/phpunit": "^9.5",
"rector\/phpstan-rules": "^0.5",
"rector\/rector-generator": "dev-main",
"rector\/rector-src": "dev-main#ffd84e6",
"rector\/rector-src": "dev-main#cb07c30",
"symfony\/console": "^6.0",
"symplify\/coding-standard": "^10.2",
"symplify\/easy-coding-standard": "^10.2",

View File

@ -12,6 +12,7 @@ use RectorPrefix20220527\Helmich\TypoScriptParser\Parser\Printer\PrettyPrinterCo
use Helmich\TypoScriptParser\Parser\Traverser\Traverser;
use RectorPrefix20220527\Helmich\TypoScriptParser\Parser\Traverser\Visitor;
use RectorPrefix20220527\Helmich\TypoScriptParser\Tokenizer\TokenizerException;
use RectorPrefix20220527\Nette\Utils\Strings;
use Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory;
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector;
use Rector\Core\Console\Output\RectorOutputStyle;
@ -20,9 +21,6 @@ use Rector\Core\ValueObject\Application\File;
use Rector\Core\ValueObject\Configuration;
use Rector\Core\ValueObject\Error\SystemError;
use Rector\Core\ValueObject\Reporting\FileDiff;
use Rector\FileFormatter\EditorConfig\EditorConfigParser;
use Rector\FileFormatter\ValueObject\Indent;
use Rector\FileFormatter\ValueObjectFactory\EditorConfigConfigurationBuilder;
use Rector\FileSystemRector\ValueObject\AddedFileWithContent;
use Rector\Parallel\ValueObject\Bridge;
use Ssch\TYPO3Rector\Contract\FileProcessor\TypoScript\ConvertToPhpFileInterface;
@ -70,11 +68,6 @@ final class TypoScriptFileProcessor implements \Ssch\TYPO3Rector\Contract\Proces
* @var \Rector\Core\Provider\CurrentFileProvider
*/
private $currentFileProvider;
/**
* @readonly
* @var \Rector\FileFormatter\EditorConfig\EditorConfigParser
*/
private $editorConfigParser;
/**
* @readonly
* @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector
@ -109,13 +102,12 @@ final class TypoScriptFileProcessor implements \Ssch\TYPO3Rector\Contract\Proces
* @param TypoScriptRectorInterface[] $typoScriptRectors
* @param TypoScriptPostRectorInterface[] $typoScriptPostRectors
*/
public function __construct(\RectorPrefix20220527\Helmich\TypoScriptParser\Parser\ParserInterface $typoscriptParser, \RectorPrefix20220527\Symfony\Component\Console\Output\BufferedOutput $output, \RectorPrefix20220527\Helmich\TypoScriptParser\Parser\Printer\ASTPrinterInterface $typoscriptPrinter, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\FileFormatter\EditorConfig\EditorConfigParser $editorConfigParser, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \Rector\Core\Console\Output\RectorOutputStyle $rectorOutputStyle, \Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory $fileDiffFactory, \Ssch\TYPO3Rector\FileProcessor\TypoScript\Collector\RemoveTypoScriptStatementCollector $removeTypoScriptStatementCollector, array $typoScriptRectors = [], array $typoScriptPostRectors = [])
public function __construct(\RectorPrefix20220527\Helmich\TypoScriptParser\Parser\ParserInterface $typoscriptParser, \RectorPrefix20220527\Symfony\Component\Console\Output\BufferedOutput $output, \RectorPrefix20220527\Helmich\TypoScriptParser\Parser\Printer\ASTPrinterInterface $typoscriptPrinter, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \Rector\Core\Console\Output\RectorOutputStyle $rectorOutputStyle, \Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory $fileDiffFactory, \Ssch\TYPO3Rector\FileProcessor\TypoScript\Collector\RemoveTypoScriptStatementCollector $removeTypoScriptStatementCollector, array $typoScriptRectors = [], array $typoScriptPostRectors = [])
{
$this->typoscriptParser = $typoscriptParser;
$this->output = $output;
$this->typoscriptPrinter = $typoscriptPrinter;
$this->currentFileProvider = $currentFileProvider;
$this->editorConfigParser = $editorConfigParser;
$this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector;
$this->rectorOutputStyle = $rectorOutputStyle;
$this->fileDiffFactory = $fileDiffFactory;
@ -174,22 +166,23 @@ final class TypoScriptFileProcessor implements \Ssch\TYPO3Rector\Contract\Proces
if ([] === $typoscriptRectorsWithChange) {
return;
}
$editorConfigConfigurationBuilder = new \Rector\FileFormatter\ValueObjectFactory\EditorConfigConfigurationBuilder();
$editorConfigConfigurationBuilder->withIndent(\Rector\FileFormatter\ValueObject\Indent::createSpaceWithSize(4));
$editorConfiguration = $this->editorConfigParser->extractConfigurationForFile($file, $editorConfigConfigurationBuilder);
// keep original json format
$tabMatches = \RectorPrefix20220527\Nette\Utils\Strings::match($file->getFileContent(), "#^\n#");
$indentStyle = $tabMatches ? 'tab' : 'space';
$prettyPrinterConfiguration = \RectorPrefix20220527\Helmich\TypoScriptParser\Parser\Printer\PrettyPrinterConfiguration::create();
$prettyPrinterConfiguration = $prettyPrinterConfiguration->withEmptyLineBreaks();
if ('tab' === $editorConfiguration->getIndentStyle()) {
if ('tab' === $indentStyle) {
$prettyPrinterConfiguration = $prettyPrinterConfiguration->withTabs();
} else {
$prettyPrinterConfiguration = $prettyPrinterConfiguration->withSpaceIndentation($editorConfiguration->getIndentSize());
// default indent
$prettyPrinterConfiguration = $prettyPrinterConfiguration->withSpaceIndentation(4);
}
$prettyPrinterConfiguration = $prettyPrinterConfiguration->withClosingGlobalStatement();
$this->typoscriptPrinter->setPrettyPrinterConfiguration($prettyPrinterConfiguration);
$printStatements = $this->filterRemovedStatements($originalStatements, $file);
$this->typoscriptPrinter->printStatements($printStatements, $this->output);
$newTypoScriptContent = $this->applyTypoScriptPostRectors($this->output->fetch());
$typoScriptContent = \rtrim($newTypoScriptContent) . $editorConfiguration->getNewLine();
$typoScriptContent = \rtrim($newTypoScriptContent) . "\n";
$oldFileContents = $file->getFileContent();
$file->changeFileContent($typoScriptContent);
$this->fileDiffs[] = $this->fileDiffFactory->createFileDiff($file, $oldFileContents, $file->getFileContent());