Skip to content

Commit

Permalink
[1.x] PHP-CS-Fixer v3.56.0 compatibility (#308)
Browse files Browse the repository at this point in the history
* Bump dependencies

* Fix Tests

* Fix phpstan issues
  • Loading branch information
Jubeki authored Nov 25, 2024
1 parent 57bbd54 commit 46d37d6
Show file tree
Hide file tree
Showing 5 changed files with 358 additions and 350 deletions.
22 changes: 11 additions & 11 deletions app/Output/Concerns/InteractsWithSymbols.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Output\Concerns;

use PhpCsFixer\Error\Error;
use PhpCsFixer\FixerFileProcessedEvent;
use PhpCsFixer\Runner\Event\FileProcessed;

/**
* @property \Symfony\Component\Console\Input\InputInterface $input
Expand All @@ -17,15 +17,15 @@ trait InteractsWithSymbols
* @var array<int, array<int|string, array<string, string>|string>>
*/
protected $statuses = [
FixerFileProcessedEvent::STATUS_INVALID => ['symbol' => '!', 'format' => '<options=bold;fg=red>%s</>'],
FixerFileProcessedEvent::STATUS_SKIPPED => ['symbol' => '.', 'format' => '<fg=gray>%s</>'],
FixerFileProcessedEvent::STATUS_NO_CHANGES => ['symbol' => '.', 'format' => '<fg=gray>%s</>'],
FixerFileProcessedEvent::STATUS_FIXED => [
FileProcessed::STATUS_INVALID => ['symbol' => '!', 'format' => '<options=bold;fg=red>%s</>'],
FileProcessed::STATUS_SKIPPED => ['symbol' => '.', 'format' => '<fg=gray>%s</>'],
FileProcessed::STATUS_NO_CHANGES => ['symbol' => '.', 'format' => '<fg=gray>%s</>'],
FileProcessed::STATUS_FIXED => [
['symbol' => '', 'format' => '<options=bold;fg=red>%s</>'],
['symbol' => '', 'format' => '<options=bold;fg=green>%s</>'],
],
FixerFileProcessedEvent::STATUS_EXCEPTION => ['symbol' => '!', 'format' => '<options=bold;fg=red>%s</>'],
FixerFileProcessedEvent::STATUS_LINT => ['symbol' => '!', 'format' => '<options=bold;fg=red>%s</>'],
FileProcessed::STATUS_EXCEPTION => ['symbol' => '!', 'format' => '<options=bold;fg=red>%s</>'],
FileProcessed::STATUS_LINT => ['symbol' => '!', 'format' => '<options=bold;fg=red>%s</>'],
];

/**
Expand Down Expand Up @@ -60,10 +60,10 @@ public function getSymbol($status)
protected function getSymbolFromErrorType($type)
{
$status = match ($type) {
Error::TYPE_INVALID => FixerFileProcessedEvent::STATUS_INVALID,
Error::TYPE_EXCEPTION => FixerFileProcessedEvent::STATUS_EXCEPTION,
Error::TYPE_LINT => FixerFileProcessedEvent::STATUS_LINT,
default => FixerFileProcessedEvent::STATUS_INVALID,
Error::TYPE_INVALID => FileProcessed::STATUS_INVALID,
Error::TYPE_EXCEPTION => FileProcessed::STATUS_EXCEPTION,
Error::TYPE_LINT => FileProcessed::STATUS_LINT,
default => FileProcessed::STATUS_INVALID,
};

return $this->getSymbol($status);
Expand Down
8 changes: 4 additions & 4 deletions app/Output/ProgressOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Output;

use App\Output\Concerns\InteractsWithSymbols;
use PhpCsFixer\FixerFileProcessedEvent;
use PhpCsFixer\Runner\Event\FileProcessed;
use Symfony\Component\Console\Terminal;

class ProgressOutput
Expand Down Expand Up @@ -47,7 +47,7 @@ public function __construct(
*/
public function subscribe()
{
$this->dispatcher->addListener(FixerFileProcessedEvent::NAME, [$this, 'handle']);
$this->dispatcher->addListener(FileProcessed::NAME, [$this, 'handle']);
}

/**
Expand All @@ -57,13 +57,13 @@ public function subscribe()
*/
public function unsubscribe()
{
$this->dispatcher->removeListener(FixerFileProcessedEvent::NAME, [$this, 'handle']);
$this->dispatcher->removeListener(FileProcessed::NAME, [$this, 'handle']);
}

/**
* Handle the given processed file event.
*
* @param \PhpCsFixer\FixerFileProcessedEvent $event
* @param \PhpCsFixer\Runner\Event\FileProcessed $event
* @return void
*/
public function handle($event)
Expand Down
9 changes: 5 additions & 4 deletions app/Output/SummaryOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use App\Output\Concerns\InteractsWithSymbols;
use App\Project;
use App\ValueObjects\Issue;
use PhpCsFixer\FixerFileProcessedEvent;
use PhpCsFixer\Runner\Event\FileProcessed;

use function Termwind\render;
use function Termwind\renderUsing;
Expand Down Expand Up @@ -89,17 +89,18 @@ public function handle($summary, $totalFiles)
*
* @param string $path
* @param \PhpCsFixer\Console\Report\FixReport\ReportSummary $summary
* @return \Illuminate\Support\Collection<int, Issue>
* @return \Illuminate\Support\Collection<int, \App\ValueObjects\Issue>
*/
public function getIssues($path, $summary)
{
$issues = collect($summary->getChanged())
->map(fn ($information, $file) => new Issue(
$path,
$file,
$this->getSymbol(FixerFileProcessedEvent::STATUS_FIXED),
$this->getSymbol(FileProcessed::STATUS_FIXED),
$information,
));
))
->values();

return $issues->merge(
collect(
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
"ext-xml": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.64.0",
"illuminate/view": "^10.48.20",
"larastan/larastan": "^2.9.8",
"friendsofphp/php-cs-fixer": "^3.65.0",
"illuminate/view": "^10.48.24",
"larastan/larastan": "^2.9.11",
"laravel-zero/framework": "^10.4.0",
"mockery/mockery": "^1.6.12",
"nunomaduro/termwind": "^1.15.1",
"pestphp/pest": "^2.35.1"
"nunomaduro/termwind": "^1.17.0",
"pestphp/pest": "^2.36.0"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 46d37d6

Please sign in to comment.