Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add php 8 and symfony 6 support #48

Merged
merged 10 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,26 @@ jobs:
dependency-versions: 'highest'
tools: 'composer:v2'
env:
SYMFONY_DEPRECATIONS_HELPER: weak
SYMFONY_DEPRECATIONS_HELPER: disabled

- php-version: '8.0'
Prokyonn marked this conversation as resolved.
Show resolved Hide resolved
lint: true
dependency-versions: 'highest'
tools: 'composer:v2'
env:
SYMFONY_DEPRECATIONS_HELPER: disabled
- php-version: '8.1'
lint: true
dependency-versions: 'highest'
tools: 'composer:v2'
env:
SYMFONY_DEPRECATIONS_HELPER: disabled
- php-version: '8.2'
lint: true
dependency-versions: 'highest'
tools: 'composer:v2'
env:
SYMFONY_DEPRECATIONS_HELPER: weak
services:
mysql:
image: mysql:5.7
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ Tests/Application/var
Tests/Application/.env.test.local

# php-cs-fixer
.php_cs.cache
.php-cs-fixer.cache
php-cs-fixer
49 changes: 49 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

$header = <<<EOF
This file is part of Sulu.

(c) Sulu GmbH

This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
EOF;

$finder = PhpCsFixer\Finder::create()
->exclude(['var/cache', 'tests/Resources/cache', 'node_modules'])
->in(__DIR__);

$config = new PhpCsFixer\Config();
$config->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
'class_definition' => false,
'concat_space' => ['spacing' => 'one'],
'function_declaration' => ['closure_function_spacing' => 'none'],
'header_comment' => ['header' => $header],
'native_constant_invocation' => true,
'native_function_casing' => true,
'native_function_invocation' => ['include' => ['@internal']],
'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false],
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true, 'remove_inheritdoc' => true],
'ordered_imports' => true,
'phpdoc_align' => ['align' => 'left'],
'phpdoc_types_order' => false,
'single_line_throw' => false,
'single_line_comment_spacing' => false,
'phpdoc_to_comment' => [
'ignored_tags' => ['todo', 'var'],
],
'phpdoc_separation' => [
'groups' => [
['Serializer\\*', 'VirtualProperty', 'Accessor', 'Type', 'Groups', 'Expose', 'Exclude', 'SerializedName', 'Inline', 'ExclusionPolicy'],
],
],
'get_class_to_class_keyword' => false, // should be enabled as soon as support for php < 8 is dropped
'nullable_type_declaration_for_default_null_value' => true,
'no_null_property_initialization' => false,
])
->setFinder($finder);

return $config;
28 changes: 0 additions & 28 deletions .php_cs.dist

This file was deleted.

19 changes: 9 additions & 10 deletions Admin/CommentAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
*/
class CommentAdmin extends Admin
{
const COMMENT_SECURITY_CONTEXT = 'sulu.comment.comments';
const COMMENT_LIST_VIEW = 'sulu_comment.comments.list';
const COMMENT_EDIT_FORM_VIEW = 'sulu_comment.comments.edit_form';
const COMMENT_EDIT_FORM_DETAILS_VIEW = 'sulu_comment.comments.edit_form.details';
public const COMMENT_SECURITY_CONTEXT = 'sulu.comment.comments';
public const COMMENT_LIST_VIEW = 'sulu_comment.comments.list';
public const COMMENT_EDIT_FORM_VIEW = 'sulu_comment.comments.edit_form';
public const COMMENT_EDIT_FORM_DETAILS_VIEW = 'sulu_comment.comments.edit_form.details';

const THREAD_SECURITY_CONTEXT = 'sulu.comment.threads';
const THREAD_LIST_VIEW = 'sulu_comment.threads.list';
const THREAD_EDIT_FORM_VIEW = 'sulu_comment.threads.edit_form';
const THREAD_EDIT_FORM_DETAILS_VIEW = 'sulu_comment.threads.edit_form.details';
public const THREAD_SECURITY_CONTEXT = 'sulu.comment.threads';
public const THREAD_LIST_VIEW = 'sulu_comment.threads.list';
public const THREAD_EDIT_FORM_VIEW = 'sulu_comment.threads.edit_form';
public const THREAD_EDIT_FORM_DETAILS_VIEW = 'sulu_comment.threads.edit_form.details';

/**
* @var ViewBuilderFactoryInterface
Expand Down Expand Up @@ -96,8 +96,7 @@ public function configureViews(ViewCollection $viewCollection): void
new ToolbarAction('sulu_admin.delete'),
];

/** @var array $commentFormToolbarActions */
$commentFormToolbarActions = array_merge($formToolbarActions, [
$commentFormToolbarActions = \array_merge($formToolbarActions, [
new TogglerToolbarAction(
$this->translator->trans('sulu_admin.publish', [], 'admin'),
'published',
Expand Down
15 changes: 10 additions & 5 deletions Controller/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,26 @@ public function cgetAction(Request $request): Response
if ($threadType) {
$listBuilder->in(
$fieldDescriptors['threadType'],
array_filter(explode(',', $threadType))
\array_filter(\explode(',', $threadType))
);

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

/** @var string $filterValue */
foreach ($request->query->all() as $filterKey => $filterValue) {
if (isset($fieldDescriptors[$filterKey])) {
$listBuilder->where($fieldDescriptors[$filterKey], $filterValue);
}
}

/** @var string $route */
$route = $request->attributes->get('_route');
$results = $listBuilder->execute();
$list = new ListRepresentation(
$results,
'comments',
$request->attributes->get('_route'),
$route,
$request->query->all(),
$listBuilder->getCurrentPage(),
$listBuilder->getLimit(),
Expand Down Expand Up @@ -149,7 +152,9 @@ public function putAction(int $id, Request $request): Response
throw new EntityNotFoundException(CommentInterface::class, $id);
}

$comment->setMessage($request->request->get('message'));
/** @var string $message */
$message = $request->request->get('message');
$comment->setMessage($message);

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

/** @var int[] $ids */
$ids = array_filter(explode(',', $ids));
if (0 === count($ids)) {
$ids = \array_filter(\explode(',', $ids));
if (0 === \count($ids)) {
return $this->handleView($this->view(null, 204));
}

Expand Down
16 changes: 11 additions & 5 deletions Controller/ThreadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,26 @@ public function cgetAction(Request $request): Response
$fieldDescriptors = $this->fieldDescriptorFactory->getFieldDescriptors('threads');
$this->restHelper->initializeListBuilder($listBuilder, $fieldDescriptors);

/** @var string $filterValue */
foreach ($request->query->all() as $filterKey => $filterValue) {
if (isset($fieldDescriptors[$filterKey])) {
$listBuilder->where($fieldDescriptors[$filterKey], $filterValue);
}
}

/** @var string $typeParameter */
$typeParameter = $request->get('types');
if ($typeParameter) {
$listBuilder->in($fieldDescriptors['type'], array_filter(explode(',', $typeParameter)));
$listBuilder->in($fieldDescriptors['type'], \array_filter(\explode(',', $typeParameter)));
}

$items = $listBuilder->execute();
/** @var string $route */
$route = $request->attributes->get('_route');
$list = new ListRepresentation(
$items,
'threads',
$request->attributes->get('_route'),
$route,
$request->query->all(),
$listBuilder->getCurrentPage(),
$listBuilder->getLimit(),
Expand Down Expand Up @@ -139,7 +143,9 @@ public function putAction(int $id, Request $request): Response
throw new EntityNotFoundException(ThreadInterface::class, $id);
}

$thread->setTitle($request->request->get('title'));
/** @var string $title */
$title = $request->request->get('title');
$thread->setTitle($title);

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

/** @var int[] $ids */
$ids = array_filter(explode(',', $ids));
if (0 === count($ids)) {
$ids = \array_filter(\explode(',', $ids));
if (0 === \count($ids)) {
return $this->handleView($this->view(null, 204));
}

Expand Down
Loading
Loading