Skip to content

Commit b5a9f06

Browse files
authored
feat: update codely coding standard (#367)
1 parent 805b6ff commit b5a9f06

File tree

249 files changed

+4856
-4877
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+4856
-4877
lines changed

apps/backoffice/backend/config/bundles.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
declare(strict_types=1);
44

55
return [
6-
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
7-
FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true],
8-
// WouterJ\EloquentBundle\WouterJEloquentBundle::class => ['test' => true]
6+
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
7+
FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true],
8+
// WouterJ\EloquentBundle\WouterJEloquentBundle::class => ['test' => true]
99
];

apps/backoffice/backend/public/index.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
require dirname(__DIR__) . '/../../bootstrap.php';
1010

1111
if ($_SERVER['APP_DEBUG']) {
12-
umask(0000);
12+
umask(0000);
1313

14-
Debug::enable();
14+
Debug::enable();
1515
}
1616

1717
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
18-
Request::setTrustedProxies(
19-
explode(',', $trustedProxies),
20-
Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO
21-
);
18+
Request::setTrustedProxies(
19+
explode(',', $trustedProxies),
20+
Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO
21+
);
2222
}
2323

2424
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
25-
Request::setTrustedHosts([$trustedHosts]);
25+
Request::setTrustedHosts([$trustedHosts]);
2626
}
2727

2828
$kernel = new BackofficeBackendKernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);

apps/backoffice/backend/src/BackofficeBackendKernel.php

+29-29
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,33 @@
1414

1515
class BackofficeBackendKernel extends Kernel
1616
{
17-
use MicroKernelTrait;
18-
19-
private const CONFIG_EXTS = '.{xml,yaml}';
20-
21-
public function registerBundles(): iterable
22-
{
23-
$contents = require $this->getProjectDir() . '/config/bundles.php';
24-
foreach ($contents as $class => $envs) {
25-
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
26-
yield new $class();
27-
}
28-
}
29-
}
30-
31-
public function getProjectDir(): string
32-
{
33-
return dirname(__DIR__);
34-
}
35-
36-
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
37-
{
38-
$container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php'));
39-
$container->setParameter('container.dumper.inline_class_loader', true);
40-
$confDir = $this->getProjectDir() . '/config';
41-
42-
$loader->load($confDir . '/services' . self::CONFIG_EXTS, 'glob');
43-
$loader->load($confDir . '/services_' . $this->environment . self::CONFIG_EXTS, 'glob');
44-
$loader->load($confDir . '/services/*' . self::CONFIG_EXTS, 'glob');
45-
}
17+
use MicroKernelTrait;
18+
19+
private const CONFIG_EXTS = '.{xml,yaml}';
20+
21+
public function registerBundles(): iterable
22+
{
23+
$contents = require $this->getProjectDir() . '/config/bundles.php';
24+
foreach ($contents as $class => $envs) {
25+
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
26+
yield new $class();
27+
}
28+
}
29+
}
30+
31+
public function getProjectDir(): string
32+
{
33+
return dirname(__DIR__);
34+
}
35+
36+
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
37+
{
38+
$container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php'));
39+
$container->setParameter('container.dumper.inline_class_loader', true);
40+
$confDir = $this->getProjectDir() . '/config';
41+
42+
$loader->load($confDir . '/services' . self::CONFIG_EXTS, 'glob');
43+
$loader->load($confDir . '/services_' . $this->environment . self::CONFIG_EXTS, 'glob');
44+
$loader->load($confDir . '/services/*' . self::CONFIG_EXTS, 'glob');
45+
}
4646
}

apps/backoffice/backend/src/Controller/Courses/CoursesGetController.php

+33-33
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,37 @@
1515

1616
final readonly class CoursesGetController
1717
{
18-
public function __construct(private QueryBus $queryBus) {}
19-
20-
public function __invoke(Request $request): JsonResponse
21-
{
22-
$orderBy = $request->query->get('order_by');
23-
$order = $request->query->get('order');
24-
$limit = $request->query->get('limit');
25-
$offset = $request->query->get('offset');
26-
27-
/** @var BackofficeCoursesResponse $response */
28-
$response = $this->queryBus->ask(
29-
new SearchBackofficeCoursesByCriteriaQuery(
30-
(array) $request->query->get('filters'),
31-
$orderBy,
32-
$order,
33-
$limit === null ? null : (int) $limit,
34-
$offset === null ? null : (int) $offset
35-
)
36-
);
37-
38-
return new JsonResponse(
39-
map(
40-
fn (BackofficeCourseResponse $course): array => [
41-
'id' => $course->id(),
42-
'name' => $course->name(),
43-
'duration' => $course->duration(),
44-
],
45-
$response->courses()
46-
),
47-
200,
48-
['Access-Control-Allow-Origin' => '*']
49-
);
50-
}
18+
public function __construct(private QueryBus $queryBus) {}
19+
20+
public function __invoke(Request $request): JsonResponse
21+
{
22+
$orderBy = $request->query->get('order_by');
23+
$order = $request->query->get('order');
24+
$limit = $request->query->get('limit');
25+
$offset = $request->query->get('offset');
26+
27+
/** @var BackofficeCoursesResponse $response */
28+
$response = $this->queryBus->ask(
29+
new SearchBackofficeCoursesByCriteriaQuery(
30+
(array) $request->query->get('filters'),
31+
$orderBy,
32+
$order,
33+
$limit === null ? null : (int) $limit,
34+
$offset === null ? null : (int) $offset
35+
)
36+
);
37+
38+
return new JsonResponse(
39+
map(
40+
fn (BackofficeCourseResponse $course): array => [
41+
'id' => $course->id(),
42+
'name' => $course->name(),
43+
'duration' => $course->duration(),
44+
],
45+
$response->courses()
46+
),
47+
200,
48+
['Access-Control-Allow-Origin' => '*']
49+
);
50+
}
5151
}

apps/backoffice/backend/src/Controller/HealthCheck/HealthCheckGetController.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
final class HealthCheckGetController
1111
{
12-
public function __invoke(Request $request): JsonResponse
13-
{
14-
return new JsonResponse(
15-
[
16-
'backoffice-backend' => 'ok',
17-
]
18-
);
19-
}
12+
public function __invoke(Request $request): JsonResponse
13+
{
14+
return new JsonResponse(
15+
[
16+
'backoffice-backend' => 'ok',
17+
]
18+
);
19+
}
2020
}

apps/backoffice/backend/src/Controller/Metrics/MetricsController.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
final readonly class MetricsController
1313
{
14-
public function __construct(private PrometheusMonitor $monitor) {}
14+
public function __construct(private PrometheusMonitor $monitor) {}
1515

16-
public function __invoke(Request $request): Response
17-
{
18-
$renderer = new RenderTextFormat();
19-
$result = $renderer->render($this->monitor->registry()->getMetricFamilySamples());
16+
public function __invoke(Request $request): Response
17+
{
18+
$renderer = new RenderTextFormat();
19+
$result = $renderer->render($this->monitor->registry()->getMetricFamilySamples());
2020

21-
return new Response($result, 200, ['Content-Type' => RenderTextFormat::MIME_TYPE]);
22-
}
21+
return new Response($result, 200, ['Content-Type' => RenderTextFormat::MIME_TYPE]);
22+
}
2323
}

apps/backoffice/frontend/config/bundles.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
declare(strict_types=1);
44

55
return [
6-
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
7-
FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true],
8-
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
9-
// WouterJ\EloquentBundle\WouterJEloquentBundle::class => ['test' => true]
6+
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
7+
FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true],
8+
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
9+
// WouterJ\EloquentBundle\WouterJEloquentBundle::class => ['test' => true]
1010
];

apps/backoffice/frontend/public/index.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
require dirname(__DIR__) . '/../../bootstrap.php';
1010

1111
if ($_SERVER['APP_DEBUG']) {
12-
umask(0000);
12+
umask(0000);
1313

14-
Debug::enable();
14+
Debug::enable();
1515
}
1616

1717
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
18-
Request::setTrustedProxies(
19-
explode(',', $trustedProxies),
20-
Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO
21-
);
18+
Request::setTrustedProxies(
19+
explode(',', $trustedProxies),
20+
Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO
21+
);
2222
}
2323

2424
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
25-
Request::setTrustedHosts([$trustedHosts]);
25+
Request::setTrustedHosts([$trustedHosts]);
2626
}
2727

2828
$kernel = new BackofficeFrontendKernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);

apps/backoffice/frontend/src/BackofficeFrontendKernel.php

+29-29
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,33 @@
1414

1515
class BackofficeFrontendKernel extends Kernel
1616
{
17-
use MicroKernelTrait;
18-
19-
private const CONFIG_EXTS = '.{xml,yaml}';
20-
21-
public function registerBundles(): iterable
22-
{
23-
$contents = require $this->getProjectDir() . '/config/bundles.php';
24-
foreach ($contents as $class => $envs) {
25-
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
26-
yield new $class();
27-
}
28-
}
29-
}
30-
31-
public function getProjectDir(): string
32-
{
33-
return dirname(__DIR__);
34-
}
35-
36-
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
37-
{
38-
$container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php'));
39-
$container->setParameter('container.dumper.inline_class_loader', true);
40-
$confDir = $this->getProjectDir() . '/config';
41-
42-
$loader->load($confDir . '/services' . self::CONFIG_EXTS, 'glob');
43-
$loader->load($confDir . '/services_' . $this->environment . self::CONFIG_EXTS, 'glob');
44-
$loader->load($confDir . '/services/*' . self::CONFIG_EXTS, 'glob');
45-
}
17+
use MicroKernelTrait;
18+
19+
private const CONFIG_EXTS = '.{xml,yaml}';
20+
21+
public function registerBundles(): iterable
22+
{
23+
$contents = require $this->getProjectDir() . '/config/bundles.php';
24+
foreach ($contents as $class => $envs) {
25+
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
26+
yield new $class();
27+
}
28+
}
29+
}
30+
31+
public function getProjectDir(): string
32+
{
33+
return dirname(__DIR__);
34+
}
35+
36+
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
37+
{
38+
$container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php'));
39+
$container->setParameter('container.dumper.inline_class_loader', true);
40+
$confDir = $this->getProjectDir() . '/config';
41+
42+
$loader->load($confDir . '/services' . self::CONFIG_EXTS, 'glob');
43+
$loader->load($confDir . '/services_' . $this->environment . self::CONFIG_EXTS, 'glob');
44+
$loader->load($confDir . '/services/*' . self::CONFIG_EXTS, 'glob');
45+
}
4646
}

apps/backoffice/frontend/src/Command/ImportCoursesToElasticsearchCommand.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212

1313
final class ImportCoursesToElasticsearchCommand extends Command
1414
{
15-
public function __construct(
16-
private readonly MySqlBackofficeCourseRepository $mySqlRepository,
17-
private readonly ElasticsearchBackofficeCourseRepository $elasticRepository
18-
) {
19-
parent::__construct();
20-
}
15+
public function __construct(
16+
private readonly MySqlBackofficeCourseRepository $mySqlRepository,
17+
private readonly ElasticsearchBackofficeCourseRepository $elasticRepository
18+
) {
19+
parent::__construct();
20+
}
2121

22-
public function execute(InputInterface $input, OutputInterface $output): int
23-
{
24-
$courses = $this->mySqlRepository->searchAll();
22+
public function execute(InputInterface $input, OutputInterface $output): int
23+
{
24+
$courses = $this->mySqlRepository->searchAll();
2525

26-
foreach ($courses as $course) {
27-
$this->elasticRepository->save($course);
28-
}
26+
foreach ($courses as $course) {
27+
$this->elasticRepository->save($course);
28+
}
2929

30-
return 0;
31-
}
30+
return 0;
31+
}
3232
}

apps/backoffice/frontend/src/Controller/Courses/CoursesGetWebController.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@
1313

1414
final class CoursesGetWebController extends WebController
1515
{
16-
public function __invoke(Request $request): Response
17-
{
18-
/** @var CoursesCounterResponse $coursesCounterResponse */
19-
$coursesCounterResponse = $this->ask(new FindCoursesCounterQuery());
16+
public function __invoke(Request $request): Response
17+
{
18+
/** @var CoursesCounterResponse $coursesCounterResponse */
19+
$coursesCounterResponse = $this->ask(new FindCoursesCounterQuery());
2020

21-
return $this->render(
22-
'pages/courses/courses.html.twig',
23-
[
24-
'title' => 'Courses',
25-
'description' => 'Courses CodelyTV - Backoffice',
26-
'courses_counter' => $coursesCounterResponse->total(),
27-
'new_course_id' => SimpleUuid::random()->value(),
28-
]
29-
);
30-
}
21+
return $this->render(
22+
'pages/courses/courses.html.twig',
23+
[
24+
'title' => 'Courses',
25+
'description' => 'Courses CodelyTV - Backoffice',
26+
'courses_counter' => $coursesCounterResponse->total(),
27+
'new_course_id' => SimpleUuid::random()->value(),
28+
]
29+
);
30+
}
3131

32-
protected function exceptions(): array
33-
{
34-
return [];
35-
}
32+
protected function exceptions(): array
33+
{
34+
return [];
35+
}
3636
}

0 commit comments

Comments
 (0)