Skip to content

Commit

Permalink
[BUGFIX] Return self to properly support code completion
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbertsoft committed Aug 1, 2022
1 parent 16dc313 commit 50f3e14
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/CsFixerConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
namespace TYPO3\CodingStandards;

use PhpCsFixer\Config;
use PhpCsFixer\ConfigInterface;
use PhpCsFixer\Finder;

class CsFixerConfig extends Config
{
Expand Down Expand Up @@ -101,13 +99,14 @@ public function __construct(string $name = 'TYPO3')
parent::__construct($name);
}

public static function create(): ConfigInterface
public static function create(): self
{
$config = (new self())
$config = new self();
$config
->setRiskyAllowed(true)
->setRules(self::$typo3Rules);
->setRules(self::$typo3Rules)
;

/** @var Finder */
$finder = $config->getFinder();
$finder->exclude(['vendor', 'typo3temp', 'var', '.build']);

Expand All @@ -117,16 +116,18 @@ public static function create(): ConfigInterface
/**
* @param array<string, mixed> $rules
*/
public function addRules(array $rules): ConfigInterface
public function addRules(array $rules): self
{
$rules = array_replace_recursive($this->getRules(), $rules);
return $this->setRules($rules);
$this->setRules($rules);

return $this;
}

public function setHeader(
string $header = 'This file is part of the TYPO3 CMS project.',
bool $replaceAll = false
): ConfigInterface {
): self {
if (!$replaceAll) {
$header = str_replace('{header}', $header, self::$defaultHeader);
}
Expand All @@ -137,6 +138,8 @@ public function setHeader(
'location' => 'after_declare_strict',
'separate' => 'both',
];
return $this->setRules($rules);
$this->setRules($rules);

return $this;
}
}

0 comments on commit 50f3e14

Please sign in to comment.