Skip to content

Commit

Permalink
fix: PSR-12 space_before_parenthesis
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp committed May 23, 2024
1 parent e6085ed commit dce9aa0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/ConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ final class ConfigBuilder
{
private Config $config;

private function __construct(private readonly RuleSet $ruleSet)
{
$this->config = new Config($ruleSet->name());
$this->config
->setRiskyAllowed($ruleSet->allowRisky())
->setUsingCache($ruleSet->useCache())
;
}

public static function createFromRuleSet(RuleSet $ruleSet): self
{
return new self($ruleSet);
Expand Down Expand Up @@ -62,18 +71,19 @@ public function addFiles(array $files): self
return $this;
}

public function getConfig(): ConfigInterface
/**
* @param list<string> $files
*/
public function exclude(array $files): self

Check warning on line 77 in src/ConfigBuilder.php

View check run for this annotation

Codecov / codecov/patch

src/ConfigBuilder.php#L77

Added line #L77 was not covered by tests
{
return $this->config->setRules($this->ruleSet->rules());
$this->getFinder()->exclude($files);

Check warning on line 79 in src/ConfigBuilder.php

View check run for this annotation

Codecov / codecov/patch

src/ConfigBuilder.php#L79

Added line #L79 was not covered by tests

return $this;

Check warning on line 81 in src/ConfigBuilder.php

View check run for this annotation

Codecov / codecov/patch

src/ConfigBuilder.php#L81

Added line #L81 was not covered by tests
}

private function __construct(private readonly RuleSet $ruleSet)
public function getConfig(): ConfigInterface
{
$this->config = new Config($ruleSet->name());
$this->config
->setRiskyAllowed($ruleSet->allowRisky())
->setUsingCache($ruleSet->useCache())
;
return $this->config->setRules($this->ruleSet->rules());
}

private function getFinder(): Finder
Expand Down
3 changes: 3 additions & 0 deletions src/RuleSets/DefaultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ public function rules(): array
'self_static_accessor' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'class_definition' => [
'space_before_parenthesis' => false,
],

/*
* @PhpCsFixer:risky
Expand Down
7 changes: 7 additions & 0 deletions src/RuleSets/ExtendedPERSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ public function rules(): array
*/
'@PER-CS2.0' => true,

/*
* @PER-CS2.0 Overrides
*/
'class_definition' => [
'space_before_parenthesis' => false,

Check warning on line 50 in src/RuleSets/ExtendedPERSet.php

View check run for this annotation

Codecov / codecov/patch

src/RuleSets/ExtendedPERSet.php#L49-L50

Added lines #L49 - L50 were not covered by tests
],

/*
* @Symfony
*/
Expand Down

0 comments on commit dce9aa0

Please sign in to comment.