Skip to content

Latest commit

 

History

History
95 lines (72 loc) · 2.54 KB

UPGRADE.md

File metadata and controls

95 lines (72 loc) · 2.54 KB

UPGRADE FROM 2.x to 3.0

  • The checkstyle and junit reporter now try to use absolute path rather than relative path.
  • In debug mode, the report now contains both the identifier and the message of the error.
  • The position of TrailingCommaMultiLineRule error changed.
  • The position of TrailingCommaSingleLineRule error changed.
  • TwigCsFixer\Command\TwigCsFixerCommand class moved to TwigCsFixer\Console\Command folder.
  • TwigCsFixer\Report\Reporter\ReporterInterface now require a getName method.

If you never implemented a custom rule, nothing else changed. Otherwise, ...

AbstractRule

- $this->isTokenMatching($token, $type, $value)
+ $token->isTokenMatching($type, $value)
- $this->findNext($type, $tokens, $start)
+ $tokens->findNext($type, $start)

- $this->findNext($type, $tokens, $start, true)
+ $tokens->findNext($type, $start, null, true)
- $this->findPrevious($type, $tokens, $start)
+ $tokens->findPrevious($type, $start)

- $this->findPrevious($type, $tokens, $start, true)
+ $tokens->findPrevious($type, $start, null, true)
- protected function process(int $tokenPosition, array $tokens): void;
+ protected function process(int $tokenIndex, Tokens $tokens): ?int;

AbstractSpacingRule

- protected function getSpaceAfter(int $tokenPosition, array $tokens): ?int;
+ protected function getSpaceAfter(int $tokenIndex, Tokens $tokens): ?int;
- protected function getSpaceBefore(int $tokenPosition, array $tokens): ?int;
+ protected function getSpaceBefore(int $tokenIndex, Tokens $tokens): ?int;

RuleInterface

- public function lintFile(array $tokens, Report $report, array $ignoredViolations = []): void;
+ public function lintFile(Tokens $tokens, Report $report): void;

FixableRuleInterface

- public function fixFile(array $tokens, FixerInterface $fixer, array $ignoredViolations = []): void;
+ public function fixFile(Tokens $tokens, FixerInterface $fixer): void;

TokenizerInterface

- /**
-   * @return array{list<Token>, list<ViolationId>}
-   */
-  public function tokenize(Source $source): array;
+  public function tokenize(Source $source): Tokens;

Token

The Token::NAME_TYPE has been split in four:

  • Token::FILTER_NAME_TYPE
  • Token::FUNCTION_NAME_TYPE
  • Token::TEST_NAME_TYPE
  • Token::NAME_TYPE
- $token->getPosition();
+ $token->getLinePosition();

Directory

- (new Directory($dir))->getRelativePathTo($file);
+ FileHelper::getRelativePath($file, $dir);