Skip to content

Commit

Permalink
Merge pull request #124 from tighten/adc/phpcbf-return-1
Browse files Browse the repository at this point in the history
Update the return value of PHPCS if errors detected
  • Loading branch information
driftingly authored Oct 17, 2023
2 parents ab03003 + 09bc6b0 commit f12a138
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 196 deletions.
10 changes: 5 additions & 5 deletions app/Fixer/ClassNotation/CustomOrderedClassElementsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function configure(array $configuration): void
$lastPosition = is_countable($this->configuration['order']) ? count($this->configuration['order']) : 0;

foreach ($this->typePosition as &$pos) {
if (null === $pos) {
if ($pos === null) {
$pos = $lastPosition;
}

Expand Down Expand Up @@ -259,7 +259,7 @@ protected function applyFix(SplFileInfo $file, Tokens $tokens): void
$i = $tokens->getNextTokenOfKind($i, ['{']);
$elements = $this->getElements($tokens, $i);

if (0 === count($elements)) {
if (count($elements) === 0) {
continue;
}

Expand Down Expand Up @@ -395,7 +395,7 @@ private function getElements(Tokens $tokens, int $startIndex): array
$element['type'] = $type;
}

if ('property' === $element['type']) {
if ($element['type'] === 'property') {
$element['name'] = $tokens[$i]->getContent();
} elseif (in_array($element['type'], ['use_trait', 'case', 'constant', 'method', 'magic', 'construct', 'destruct'], true)) {
$element['name'] = $tokens[$tokens->getNextMeaningfulToken($i)]->getContent();
Expand Down Expand Up @@ -520,7 +520,7 @@ private function sortElements(array $elements): array
if (isset($this->typePosition[$type])) {
$element['position'] = $this->typePosition[$type];

if ('phpunit' === $type) {
if ($type === 'phpunit') {
$element['position'] += $phpunitPositions[$element['name']];
}

Expand Down Expand Up @@ -590,7 +590,7 @@ private function sortGroupElements(array $a, array $b): int
{
$selectedSortAlgorithm = $this->configuration['sort_algorithm'];

if (self::SORT_ALPHA === $selectedSortAlgorithm) {
if ($selectedSortAlgorithm === self::SORT_ALPHA) {
return strcasecmp($a['name'], $b['name']);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Support/PhpCodeSniffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function fix(): int
$this->failure('PHP Code_Sniffer found errors that cannot be fixed automatically.');
}

return $fix;
return $fix || $lint ? 1 : 0;
}

/**
Expand Down
Binary file modified builds/duster
Binary file not shown.
Loading

0 comments on commit f12a138

Please sign in to comment.