Skip to content

Commit

Permalink
Update dependencies and use latest version of devanoxltd/revive-action
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-chetan committed Jun 10, 2024
1 parent 66c74be commit e76bb14
Show file tree
Hide file tree
Showing 12 changed files with 1,054 additions and 380 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ jobs:
run: composer install

- name: Add dev dependencies
run: composer require --dev nunomaduro/larastan pestphp/pest
run: composer require --dev larastan/larastan pestphp/pest

- name: Run Revive
run: ./builds/revive lint --using="tlint,phpcodesniffer,phpcsfixer,pint"

- name: Run PHPStan
run: vendor/bin/phpstan
if: matrix.php == '8.2'
if: matrix.php == '8.3'

- name: Run Pest
run: vendor/bin/pest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/vendor
.phpunit.result.cache
.phpunit.cache
.idea
.DS_Store
.env
1 change: 0 additions & 1 deletion app/Support/PhpCodeSniffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ private function resetConfig(string $tool): void
define('PHP_CODESNIFFER_CBF', $tool === 'runPHPCBF');
}

// @phpstan-ignore-next-line
invade(new Config)->overriddenDefaults = [];
}

Expand Down
36 changes: 30 additions & 6 deletions app/Support/TLint.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\OutputInterface;
use Tighten\TLint\Commands\BaseCommand;
use Tighten\TLint\Commands\FormatCommand;
use Tighten\TLint\Commands\LintCommand;

Expand All @@ -28,6 +29,22 @@ public function fix(): int
private function process(string $command): int
{
$tlintCommand = $command === 'lint' ? new LintCommand : new FormatCommand;
$success = $this->executeCommand($tlintCommand);

if ($success && $tlintCommand instanceof FormatCommand) {
$this->success('Checking for any remaining issues after fixing...');
if (! $this->executeCommand(new LintCommand)) {
$this->failure('Some issues could not be fixed automatically.');

return Command::FAILURE;
}
}

return $success ? Command::SUCCESS : Command::FAILURE;
}

private function executeCommand(BaseCommand $tlintCommand): bool
{
$tlintCommand->config->excluded = [
...$tlintCommand->config->excluded ??
[],
Expand All @@ -38,14 +55,21 @@ private function process(string $command): int
$application->add($tlintCommand);
$application->setAutoExit(false);

$success = collect($this->reviveConfig->get('paths'))->map(function ($path) use ($application, $command) {
$path = '"' . str_replace('\\', '\\\\', $path) . '"';

return $application->run(new StringInput("{$command} {$path}"), app()->get(OutputInterface::class));
})
return collect($this->reviveConfig->get('paths'))
->map(fn ($path) => $this->executeCommandOnPath($path, $application))
->filter()
->isEmpty();
}

return $success ? Command::SUCCESS : Command::FAILURE;
private function executeCommandOnPath(string $path, Application $application): int
{
$path = '"' . str_replace('\\', '\\\\', $path) . '"';

$command = $application->has('lint') ? 'lint' : 'format';

return $application->run(
new StringInput("{$command} {$path}"),
app()->get(OutputInterface::class)
);
}
}
Binary file added builds/revive.phar
Binary file not shown.
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@
],
"require": {
"php": "^8.2",
"larastan/larastan": "^v2.9.5",
"larastan/larastan": "^v2.9.7",
"mrchetan/php_standard": "^4.0.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^v3.54.0",
"laravel-zero/framework": "^v11.0.1",
"laravel/pint": "^v1.15.2",
"nunomaduro/termwind": "^v2.0.1",
"pestphp/pest": "^v2.34.7",
"rector/rector": "^1.0.4",
"spatie/invade": "^1.1.1",
"tightenco/tlint": "^v9.3.0"
"friendsofphp/php-cs-fixer": "^v3.58",
"laravel-zero/framework": "^v11.0",
"laravel/pint": "^v1.16",
"nunomaduro/termwind": "^v2.0",
"pestphp/pest": "^v2.34",
"rector/rector": "^1.1",
"spatie/invade": "^1.1",
"tightenco/tlint": "^v9.3"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit e76bb14

Please sign in to comment.