Skip to content

Commit 57b3db1

Browse files
authored
Add php 8 and symfony 6 support (#48)
1 parent 6d063f6 commit 57b3db1

Some content is hidden

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

41 files changed

+415
-511
lines changed

.github/workflows/test-application.yaml

+19-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,26 @@ jobs:
3131
dependency-versions: 'highest'
3232
tools: 'composer:v2'
3333
env:
34-
SYMFONY_DEPRECATIONS_HELPER: weak
34+
SYMFONY_DEPRECATIONS_HELPER: disabled
3535

36+
- php-version: '8.0'
37+
lint: true
38+
dependency-versions: 'highest'
39+
tools: 'composer:v2'
40+
env:
41+
SYMFONY_DEPRECATIONS_HELPER: disabled
42+
- php-version: '8.1'
43+
lint: true
44+
dependency-versions: 'highest'
45+
tools: 'composer:v2'
46+
env:
47+
SYMFONY_DEPRECATIONS_HELPER: disabled
48+
- php-version: '8.2'
49+
lint: true
50+
dependency-versions: 'highest'
51+
tools: 'composer:v2'
52+
env:
53+
SYMFONY_DEPRECATIONS_HELPER: weak
3654
services:
3755
mysql:
3856
image: mysql:5.7

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ Tests/Application/var
3232
Tests/Application/.env.test.local
3333

3434
# php-cs-fixer
35-
.php_cs.cache
35+
.php-cs-fixer.cache
3636
php-cs-fixer

.php-cs-fixer.dist.php

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
$header = <<<EOF
4+
This file is part of Sulu.
5+
6+
(c) Sulu GmbH
7+
8+
This source file is subject to the MIT license that is bundled
9+
with this source code in the file LICENSE.
10+
EOF;
11+
12+
$finder = PhpCsFixer\Finder::create()
13+
->exclude(['var/cache', 'tests/Resources/cache', 'node_modules'])
14+
->in(__DIR__);
15+
16+
$config = new PhpCsFixer\Config();
17+
$config->setRiskyAllowed(true)
18+
->setRules([
19+
'@Symfony' => true,
20+
'array_syntax' => ['syntax' => 'short'],
21+
'class_definition' => false,
22+
'concat_space' => ['spacing' => 'one'],
23+
'function_declaration' => ['closure_function_spacing' => 'none'],
24+
'header_comment' => ['header' => $header],
25+
'native_constant_invocation' => true,
26+
'native_function_casing' => true,
27+
'native_function_invocation' => ['include' => ['@internal']],
28+
'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false],
29+
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true, 'remove_inheritdoc' => true],
30+
'ordered_imports' => true,
31+
'phpdoc_align' => ['align' => 'left'],
32+
'phpdoc_types_order' => false,
33+
'single_line_throw' => false,
34+
'single_line_comment_spacing' => false,
35+
'phpdoc_to_comment' => [
36+
'ignored_tags' => ['todo', 'var'],
37+
],
38+
'phpdoc_separation' => [
39+
'groups' => [
40+
['Serializer\\*', 'VirtualProperty', 'Accessor', 'Type', 'Groups', 'Expose', 'Exclude', 'SerializedName', 'Inline', 'ExclusionPolicy'],
41+
],
42+
],
43+
'get_class_to_class_keyword' => false, // should be enabled as soon as support for php < 8 is dropped
44+
'nullable_type_declaration_for_default_null_value' => true,
45+
'no_null_property_initialization' => false,
46+
])
47+
->setFinder($finder);
48+
49+
return $config;

.php_cs.dist

-28
This file was deleted.

Admin/CommentAdmin.php

+9-10
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
*/
2828
class CommentAdmin extends Admin
2929
{
30-
const COMMENT_SECURITY_CONTEXT = 'sulu.comment.comments';
31-
const COMMENT_LIST_VIEW = 'sulu_comment.comments.list';
32-
const COMMENT_EDIT_FORM_VIEW = 'sulu_comment.comments.edit_form';
33-
const COMMENT_EDIT_FORM_DETAILS_VIEW = 'sulu_comment.comments.edit_form.details';
30+
public const COMMENT_SECURITY_CONTEXT = 'sulu.comment.comments';
31+
public const COMMENT_LIST_VIEW = 'sulu_comment.comments.list';
32+
public const COMMENT_EDIT_FORM_VIEW = 'sulu_comment.comments.edit_form';
33+
public const COMMENT_EDIT_FORM_DETAILS_VIEW = 'sulu_comment.comments.edit_form.details';
3434

35-
const THREAD_SECURITY_CONTEXT = 'sulu.comment.threads';
36-
const THREAD_LIST_VIEW = 'sulu_comment.threads.list';
37-
const THREAD_EDIT_FORM_VIEW = 'sulu_comment.threads.edit_form';
38-
const THREAD_EDIT_FORM_DETAILS_VIEW = 'sulu_comment.threads.edit_form.details';
35+
public const THREAD_SECURITY_CONTEXT = 'sulu.comment.threads';
36+
public const THREAD_LIST_VIEW = 'sulu_comment.threads.list';
37+
public const THREAD_EDIT_FORM_VIEW = 'sulu_comment.threads.edit_form';
38+
public const THREAD_EDIT_FORM_DETAILS_VIEW = 'sulu_comment.threads.edit_form.details';
3939

4040
/**
4141
* @var ViewBuilderFactoryInterface
@@ -96,8 +96,7 @@ public function configureViews(ViewCollection $viewCollection): void
9696
new ToolbarAction('sulu_admin.delete'),
9797
];
9898

99-
/** @var array $commentFormToolbarActions */
100-
$commentFormToolbarActions = array_merge($formToolbarActions, [
99+
$commentFormToolbarActions = \array_merge($formToolbarActions, [
101100
new TogglerToolbarAction(
102101
$this->translator->trans('sulu_admin.publish', [], 'admin'),
103102
'published',

Controller/CommentController.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,26 @@ public function cgetAction(Request $request): Response
105105
if ($threadType) {
106106
$listBuilder->in(
107107
$fieldDescriptors['threadType'],
108-
array_filter(explode(',', $threadType))
108+
\array_filter(\explode(',', $threadType))
109109
);
110110

111111
$request->query->remove('threadType');
112112
}
113113

114+
/** @var string $filterValue */
114115
foreach ($request->query->all() as $filterKey => $filterValue) {
115116
if (isset($fieldDescriptors[$filterKey])) {
116117
$listBuilder->where($fieldDescriptors[$filterKey], $filterValue);
117118
}
118119
}
119120

121+
/** @var string $route */
122+
$route = $request->attributes->get('_route');
120123
$results = $listBuilder->execute();
121124
$list = new ListRepresentation(
122125
$results,
123126
'comments',
124-
$request->attributes->get('_route'),
127+
$route,
125128
$request->query->all(),
126129
$listBuilder->getCurrentPage(),
127130
$listBuilder->getLimit(),
@@ -149,7 +152,9 @@ public function putAction(int $id, Request $request): Response
149152
throw new EntityNotFoundException(CommentInterface::class, $id);
150153
}
151154

152-
$comment->setMessage($request->request->get('message'));
155+
/** @var string $message */
156+
$message = $request->request->get('message');
157+
$comment->setMessage($message);
153158

154159
$this->commentManager->update($comment);
155160
$this->entityManager->flush();
@@ -163,8 +168,8 @@ public function cdeleteAction(Request $request): Response
163168
$ids = $request->query->get('ids', '');
164169

165170
/** @var int[] $ids */
166-
$ids = array_filter(explode(',', $ids));
167-
if (0 === count($ids)) {
171+
$ids = \array_filter(\explode(',', $ids));
172+
if (0 === \count($ids)) {
168173
return $this->handleView($this->view(null, 204));
169174
}
170175

Controller/ThreadController.php

+11-5
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,26 @@ public function cgetAction(Request $request): Response
9696
$fieldDescriptors = $this->fieldDescriptorFactory->getFieldDescriptors('threads');
9797
$this->restHelper->initializeListBuilder($listBuilder, $fieldDescriptors);
9898

99+
/** @var string $filterValue */
99100
foreach ($request->query->all() as $filterKey => $filterValue) {
100101
if (isset($fieldDescriptors[$filterKey])) {
101102
$listBuilder->where($fieldDescriptors[$filterKey], $filterValue);
102103
}
103104
}
104105

106+
/** @var string $typeParameter */
105107
$typeParameter = $request->get('types');
106108
if ($typeParameter) {
107-
$listBuilder->in($fieldDescriptors['type'], array_filter(explode(',', $typeParameter)));
109+
$listBuilder->in($fieldDescriptors['type'], \array_filter(\explode(',', $typeParameter)));
108110
}
109111

110112
$items = $listBuilder->execute();
113+
/** @var string $route */
114+
$route = $request->attributes->get('_route');
111115
$list = new ListRepresentation(
112116
$items,
113117
'threads',
114-
$request->attributes->get('_route'),
118+
$route,
115119
$request->query->all(),
116120
$listBuilder->getCurrentPage(),
117121
$listBuilder->getLimit(),
@@ -139,7 +143,9 @@ public function putAction(int $id, Request $request): Response
139143
throw new EntityNotFoundException(ThreadInterface::class, $id);
140144
}
141145

142-
$thread->setTitle($request->request->get('title'));
146+
/** @var string $title */
147+
$title = $request->request->get('title');
148+
$thread->setTitle($title);
143149

144150
$this->commentManager->updateThread($thread);
145151
$this->entityManager->flush();
@@ -153,8 +159,8 @@ public function cdeleteAction(Request $request): Response
153159
$ids = $request->query->get('ids', '');
154160

155161
/** @var int[] $ids */
156-
$ids = array_filter(explode(',', $ids));
157-
if (0 === count($ids)) {
162+
$ids = \array_filter(\explode(',', $ids));
163+
if (0 === \count($ids)) {
158164
return $this->handleView($this->view(null, 204));
159165
}
160166

0 commit comments

Comments
 (0)