Skip to content

Commit

Permalink
feat: add php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Mar 6, 2024
1 parent 01f55ba commit ef4c3de
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/devcontainer export-ignore
/.github export-ignore
/phpstan.neon export-ignore
/README.md export-ignore
/README.md export-ignore
/.php-cs-fixer.cache export-ignore
15 changes: 15 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,18 @@ jobs:

- name: Run PHPStan
run: vendor/bin/phpstan
cs-fixer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

- name: Install dependencies
run: composer install

- name: Run PHP CS Fixer
run: vendor/bin/php-cs-fixer fix --dry-run --diff
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor
/composer.lock
/composer.lock
/.php-cs-fixer.cache
13 changes: 13 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

$config = new PhpCsFixer\Config();
return $config
->setRiskyAllowed(true)
->setRules([
'@PER-CS2.0' => true,
'@PER-CS2.0:risky' => true,
])
->setFinder(PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
)
;
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"require-dev": {
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-symfony": "^1.3",
"phpstan/extension-installer": "^1.3"
"phpstan/extension-installer": "^1.3",
"friendsofphp/php-cs-fixer": "^3.51"
},
"config": {
"allow-plugins": {
Expand Down
3 changes: 1 addition & 2 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

declare(strict_types=1);


namespace Frosh\SentryBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
Expand All @@ -23,4 +22,4 @@ public function getConfigTreeBuilder()

return $treeBuilder;
}
}
}
6 changes: 2 additions & 4 deletions src/Integration/UseShopwareExceptionIgnores.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ class UseShopwareExceptionIgnores implements IntegrationInterface
/**
* @param array<string, array{log_level: string}> $exceptions
*/
public function __construct(private readonly array $exceptions)
{
}
public function __construct(private readonly array $exceptions) {}

public function setupOnce(): void
{
$exceptions = $this->exceptions;

Scope::addGlobalEventProcessor(function (Event $event) use($exceptions): ?Event {
Scope::addGlobalEventProcessor(function (Event $event) use ($exceptions): ?Event {
$eventExceptions = $event->getExceptions()[0] ?? null;

if ($eventExceptions === null) {
Expand Down
5 changes: 1 addition & 4 deletions src/Listener/FixRequestUrlListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
*/
class FixRequestUrlListener
{
public function __construct(private readonly HubInterface $hub)
{

}
public function __construct(private readonly HubInterface $hub) {}

public function __invoke(RequestEvent $event): void
{
Expand Down
1 change: 1 addition & 0 deletions src/Listener/SalesChannelContextListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Shopware\Core\System\SalesChannel\Event\SalesChannelContextCreatedEvent;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Contracts\Service\ResetInterface;

use function Sentry\configureScope;

class SalesChannelContextListener implements ResetInterface
Expand Down
7 changes: 3 additions & 4 deletions src/Subscriber/ScheduledTaskSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Sentry\CheckInStatus;
use Sentry\MonitorSchedule;

use function Sentry\captureCheckIn;

class ScheduledTaskSubscriber implements EventSubscriberInterface
Expand All @@ -34,9 +35,7 @@ class ScheduledTaskSubscriber implements EventSubscriberInterface
public function __construct(
private readonly EntityRepository $scheduledTaskRepository,
private readonly bool $reportScheduledTasks
)
{
}
) {}

public static function getSubscribedEvents(): array
{
Expand Down Expand Up @@ -147,4 +146,4 @@ private function fetchScheduledTaskCollection(): void

$this->scheduledTaskCollection = $this->scheduledTaskRepository->search($criteria, $context)->getEntities();
}
}
}

0 comments on commit ef4c3de

Please sign in to comment.