Skip to content

Commit

Permalink
Fix: PhpCodeSniffer issue and remove @codingStandardsIgnoreLine fro…
Browse files Browse the repository at this point in the history
…m the code
  • Loading branch information
mr-chetan committed Jul 18, 2024
1 parent f5058f9 commit ee62f18
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 38 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
/banner.png export-ignore
/box.json export-ignore
/composer.lock export-ignore
/composer-dev.json export-ignore
/composer-dev.lock export-ignore
/CONTRIBUTING.md export-ignore
/revive export-ignore
/phpstan.neon export-ignore
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/HuskyHooksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function runCommands(array $commands): void
}
}

$process->run(function ($type, $line) { // @codingStandardsIgnoreLine
$process->run(function ($type, $line) {
$this->output->write(' ' . $line);
});
}
Expand Down
11 changes: 3 additions & 8 deletions app/Fixer/ClassNotation/CustomControllerOrderFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public function getPriority(): int
public function isControllerClass(Tokens $tokens, int $index): bool
{
if (! $tokens[$index]->isGivenKind(T_NAMESPACE)) {
$errorMessage = 'No "T_NAMESPACE" at given index %d, got "%s".';
throw new LogicException(sprintf($errorMessage, $index, $tokens[$index]->getName()));
throw new LogicException(sprintf('No "T_NAMESPACE" at given index %d, got "%s".', $index, $tokens[$index]->getName()));
}

$extendsIndex = $tokens->getNextTokenOfKind($index, ['{', [T_EXTENDS]]);
Expand All @@ -39,9 +38,7 @@ public function isControllerClass(Tokens $tokens, int $index): bool
}

$namespace = [];
while ($tokens->getNextMeaningfulToken($index) !== null) {
$index = $tokens->getNextMeaningfulToken($index);

while (null !== $index = $tokens->getNextMeaningfulToken($index)) {
if ($tokens[$index]->equals(';')) {
break; // end of namespace
}
Expand All @@ -55,9 +52,7 @@ public function isControllerClass(Tokens $tokens, int $index): bool

$index = $extendsIndex;

while ($tokens->getNextMeaningfulToken($index) !== null) {
$index = $tokens->getNextMeaningfulToken($index);

while (null !== $index = $tokens->getNextMeaningfulToken($index)) {
if ($tokens[$index]->equals('{')) {
break; // end of class signature
}
Expand Down
6 changes: 3 additions & 3 deletions app/Fixer/ClassNotation/CustomOrderedClassElementsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ protected function configurePostNormalisation(): void
}
}

protected function applyFix(SplFileInfo $file, Tokens $tokens): void // @codingStandardsIgnoreLine
protected function applyFix(SplFileInfo $file, Tokens $tokens): void
{
for ($i = 1, $count = $tokens->count(); $i < $count; $i++) {
if (! $tokens[$i]->isClassy()) {
Expand Down Expand Up @@ -543,7 +543,7 @@ private function findElementEnd(Tokens $tokens, int $index): int
$index = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $index);
}

for (++$index; $tokens[$index]->isWhitespace(" \t") || $tokens[$index]->isComment(); $index++); // @codingStandardsIgnoreLine
for (++$index; $tokens[$index]->isWhitespace(" \t") || $tokens[$index]->isComment(); $index++);

$index--;

Expand Down Expand Up @@ -622,7 +622,7 @@ private function sortElements(array $elements): array
* @param array{element: _ClassElement, position: int} $b
* @return -1|0|1
*/
fn (array $a, array $b): int => ($a['position'] === $b['position']) ? $this->sortGroupElements($a['element'], $b['element']) : $a['position'] <=> $b['position'], // @codingStandardsIgnoreLine
fn (array $a, array $b): int => ($a['position'] === $b['position']) ? $this->sortGroupElements($a['element'], $b['element']) : $a['position'] <=> $b['position'],
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Support/ConfiguresForLintOrFix.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function configure(): void
name: 'using',
shortcut: 'u',
mode: InputOption::VALUE_REQUIRED,
description: 'Lint/fix using specified (comma separated) tools: tlint,phpcodesniffer,phpcsfixer,pint', // @codingStandardsIgnoreLine
description: 'Lint/fix using specified (comma separated) tools: tlint,phpcodesniffer,phpcsfixer,pint',
),
new InputOption(
name: 'dirty',
Expand Down
2 changes: 1 addition & 1 deletion app/Support/PhpCodeSniffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private function getConfigFile(): string
file_exists(Project::path() . '/phpcs.xml') => Project::path() . '/phpcs.xml',
file_exists(Project::path() . '/.phpcs.xml.dist') => Project::path() . '/.phpcs.xml.dist',
file_exists(Project::path() . '/phpcs.xml.dist') => Project::path() . '/phpcs.xml.dist',
file_exists(Project::path() . '/vendor/mrchetan/php_standard/ruleset.xml') => Project::path() . '/vendor/mrchetan/php_standard/ruleset.xml', // @codingStandardsIgnoreLine
file_exists(Project::path() . '/vendor/mrchetan/php_standard/ruleset.xml') => Project::path() . '/vendor/mrchetan/php_standard/ruleset.xml',
default => 'Devanox',
};
}
Expand Down
2 changes: 1 addition & 1 deletion app/Support/PhpCsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private function includeConfig(): ConfigInterface
$config = include $this->getConfigFilePath();

if (! $config instanceof ConfigInterface) {
throw new InvalidConfigurationException("The PHP CS Fixer config file does not return a 'PhpCsFixer\ConfigInterface' instance."); // @codingStandardsIgnoreLine
throw new InvalidConfigurationException("The PHP CS Fixer config file does not return a 'PhpCsFixer\ConfigInterface' instance.");
}

return $config;
Expand Down
4 changes: 1 addition & 3 deletions app/Support/UserScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ private function process(): int
$output = app()->get(OutputInterface::class);

try {
// @codingStandardsIgnoreLine
$process->run(fn ($type, $buffer) => $output->write($buffer));

return $process->getExitCode();
} catch (ProcessTimedOutException $e) {
$error = '<br />You can overwrite this timeout with the processTimeout key in your revive.json file.';
$this->failure($e->getMessage() . $error);
$this->failure($e->getMessage() . '<br />You can overwrite this timeout with the processTimeout key in your revive.json file.');

return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion composer-dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"require": {
"php": "^8.2",
"larastan/larastan": "^2.9",
"mrchetan/php_standard": "^4.0"
"mrchetan/php_standard": "^4.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.59",
Expand Down
16 changes: 8 additions & 8 deletions composer-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "4e7fa30f662bf7ac63a01e1788ea7760",
"content-hash": "da8bda8473d1392e8b38a9024cd9befb",
"packages": [
{
"name": "brick/math",
Expand Down Expand Up @@ -1719,20 +1719,20 @@
},
{
"name": "mrchetan/php_standard",
"version": "4.0.4",
"version": "4.1.1",
"source": {
"type": "git",
"url": "https://github.com/mrchetan/PHPStandard.git",
"reference": "39f6b4f899bf91481871c05ba955d4b6bcb048b7"
"reference": "fc6e7f1c014e8fd74147e564481d283ccff1224a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mrchetan/PHPStandard/zipball/39f6b4f899bf91481871c05ba955d4b6bcb048b7",
"reference": "39f6b4f899bf91481871c05ba955d4b6bcb048b7",
"url": "https://api.github.com/repos/mrchetan/PHPStandard/zipball/fc6e7f1c014e8fd74147e564481d283ccff1224a",
"reference": "fc6e7f1c014e8fd74147e564481d283ccff1224a",
"shasum": ""
},
"require": {
"squizlabs/php_codesniffer": "^3.7"
"squizlabs/php_codesniffer": "^3.10"
},
"type": "php-code-sniffer",
"notification-url": "https://packagist.org/downloads/",
Expand All @@ -1748,15 +1748,15 @@
"description": "PHP coding standard to be followed",
"support": {
"issues": "https://github.com/mrchetan/PHPStandard/issues",
"source": "https://github.com/mrchetan/PHPStandard/tree/4.0.4"
"source": "https://github.com/mrchetan/PHPStandard/tree/4.1.1"
},
"funding": [
{
"url": "https://github.com/mr-chetan",
"type": "github"
}
],
"time": "2023-08-02T16:08:06+00:00"
"time": "2024-07-18T08:10:21+00:00"
},
{
"name": "nesbot/carbon",
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"require": {
"php": "^8.2",
"larastan/larastan": "^2.9",
"mrchetan/php_standard": "^4.0"
"mrchetan/php_standard": "^4.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.59",
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion revive.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"lint": {
"PHP Version": ["php", "-v"],
"PHPStan Version": ["./vendor/bin/phpstan", "-V"],
"PHPStan": ["./vendor/bin/phpstan", "analyse"]
"PHPStan": ["./vendor/bin/phpstan", "analyse"],
"Pest Version": ["./vendor/bin/pest", "--version"],
"Pest": ["./vendor/bin/pest"]
}
}
}
2 changes: 1 addition & 1 deletion standards/pint.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"classes_opening_brace": "next_line_unless_newline_at_signature_end",
"anonymous_classes_opening_brace": "next_line_unless_newline_at_signature_end",
"allow_single_line_empty_anonymous_classes": true,
"allow_single_line_anonymous_functions": true
"allow_single_line_anonymous_functions": false
},
"explicit_string_variable": true,
"global_namespace_import": {
Expand Down

0 comments on commit ee62f18

Please sign in to comment.