Add bootstrapping code to linting/static analysis.

This commit is contained in:
Buster Neece 2022-11-16 01:46:16 -06:00
parent dac19b11b7
commit ec61c234f6
No known key found for this signature in database
GPG Key ID: F1D2E64A0005E80E
11 changed files with 36 additions and 19 deletions

View File

@ -63,7 +63,7 @@ return static function (CallableEventDispatcherInterface $dispatcher) {
$app = $event->getApp();
// Load app-specific route configuration.
$container = $app->getContainer();
$container = $event->getContainer();
/** @var Environment $environment */
$environment = $container->get(Environment::class);
@ -90,8 +90,8 @@ return static function (CallableEventDispatcherInterface $dispatcher) {
$app->addRoutingMiddleware();
// Redirects and updates that should happen before system middleware.
$app->add(new Middleware\RemoveSlashes);
$app->add(new Middleware\ApplyXForwardedProto);
$app->add(new Middleware\RemoveSlashes());
$app->add(new Middleware\ApplyXForwardedProto());
// Use PSR-7 compatible sessions.
$app->add(Middleware\InjectSession::class);

View File

@ -1,4 +1,5 @@
<?php
/**
* Administrative dashboard configuration.
*/

View File

@ -1,4 +1,5 @@
<?php
/**
* Administrative dashboard configuration.
*/

View File

@ -1,4 +1,5 @@
<?php
// An array of message queue types and the DI classes responsible for handling them.
use App\Message;
use App\Radio\Backend\Liquidsoap;

View File

@ -14,7 +14,7 @@ return static function (RouteCollectorProxy $group) {
->setName('api:stations:index')
->add(new Middleware\RateLimit('api', 5, 2));
$group->get('/nowplaying', Controller\Api\NowPlayingAction::class . ':indexAction');
$group->get('/nowplaying', Controller\Api\NowPlayingController::class . ':getAction');
$group->map(
['GET', 'POST'],

View File

@ -1,4 +1,5 @@
<?php
/**
* PHP-DI Services
*/
@ -133,7 +134,7 @@ return [
Doctrine\DBAL\Types\Type::addType('carbon_immutable', Carbon\Doctrine\CarbonImmutableType::class);
}
$eventManager = new Doctrine\Common\EventManager;
$eventManager = new Doctrine\Common\EventManager();
$eventManager->addEventSubscriber($eventRequiresRestart);
$eventManager->addEventSubscriber($eventAuditLog);
$eventManager->addEventSubscriber($eventChangeTracking);
@ -159,7 +160,6 @@ return [
Environment $environment,
Psr\Log\LoggerInterface $logger
) {
/** @var Symfony\Contracts\Cache\CacheInterface $cacheInterface */
if ($environment->isTesting()) {
$cacheInterface = new Symfony\Component\Cache\Adapter\ArrayAdapter();
} else {
@ -268,7 +268,7 @@ return [
$proxyCache = new Symfony\Component\Cache\Adapter\ProxyAdapter($psr6Cache, 'annotations.');
return new Doctrine\Common\Annotations\PsrCachedReader(
new Doctrine\Common\Annotations\AnnotationReader,
new Doctrine\Common\Annotations\AnnotationReader(),
$proxyCache,
!$settings->isProduction()
);
@ -289,7 +289,7 @@ return [
new Symfony\Component\Serializer\Normalizer\ObjectNormalizer($classMetaFactory),
];
$encoders = [
new Symfony\Component\Serializer\Encoder\JsonEncoder,
new Symfony\Component\Serializer\Encoder\JsonEncoder(),
];
return new Symfony\Component\Serializer\Serializer($normalizers, $encoders);
@ -302,7 +302,9 @@ return [
) {
$builder = new Symfony\Component\Validator\ValidatorBuilder();
$builder->setConstraintValidatorFactory($constraintValidatorFactory);
$builder->enableAnnotationMapping($reader);
$builder->enableAnnotationMapping();
$builder->setDoctrineAnnotationReader($reader);
return $builder->getValidator();
},
@ -386,7 +388,7 @@ return [
// Mail functionality
Symfony\Component\Mailer\Transport\TransportInterface::class => static function (
App\Entity\Repository\SettingsRepository $settingsRepo,
Azura\SlimCallableEventDispatcher\CallableEventDispatcherInterface $eventDispatcher,
Psr\EventDispatcher\EventDispatcherInterface $eventDispatcher,
Monolog\Logger $logger
) {
$settings = $settingsRepo->readSettings();
@ -433,7 +435,7 @@ return [
Symfony\Component\Mailer\Mailer::class => static function (
Symfony\Component\Mailer\Transport\TransportInterface $transport,
Symfony\Component\Messenger\MessageBus $messageBus,
Azura\SlimCallableEventDispatcher\CallableEventDispatcherInterface $eventDispatcher
Psr\EventDispatcher\EventDispatcherInterface $eventDispatcher
) {
return new Symfony\Component\Mailer\Mailer(
$transport,
@ -481,11 +483,6 @@ return [
);
},
App\Assets::class => static fn(Environment $env) => new App\Assets(
$env,
require __DIR__ . '/assets.php'
),
App\Webhook\ConnectorLocator::class => static fn(ContainerInterface $di) => new App\Webhook\ConnectorLocator(
$di,
require __DIR__ . '/webhooks.php'

View File

@ -1,4 +1,5 @@
<?php
/**
* Webhook Configuration
*/

View File

@ -2,7 +2,11 @@
<ruleset name="AzuraCast">
<description>The AzuraCast PHP coding standard.</description>
<file>bin</file>
<file>config</file>
<file>src</file>
<file>templates</file>
<file>web</file>
<exclude-pattern>src/Tests/*$</exclude-pattern>

View File

@ -8,10 +8,15 @@ parameters:
checkMissingIterableValueType: false
paths:
- src
- bin
- config
- src
- templates
- web
excludePaths:
- config/routes.dev.php
bootstrapFiles:
- ./util/phpstan.php

View File

@ -63,7 +63,7 @@ final class AppFactory
}
$eventDispatcher = $container->get(EventDispatcherInterface::class);
$eventDispatcher->dispatch(new Event\BuildRoutes($app));
$eventDispatcher->dispatch(new Event\BuildRoutes($app, $container));
return $app;
}

View File

@ -4,13 +4,15 @@ declare(strict_types=1);
namespace App\Event;
use Psr\Container\ContainerInterface;
use Slim\App;
use Symfony\Contracts\EventDispatcher\Event;
final class BuildRoutes extends Event
{
public function __construct(
private readonly App $app
private readonly App $app,
private readonly ContainerInterface $container
) {
}
@ -18,4 +20,9 @@ final class BuildRoutes extends Event
{
return $this->app;
}
public function getContainer(): ContainerInterface
{
return $this->container;
}
}