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 6 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
7 changes: 5 additions & 2 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
EOF;

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

return PhpCsFixer\Config::create()
$config = new PhpCsFixer\Config();
$config->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
Expand All @@ -26,3 +27,5 @@
'phpdoc_types_order' => false,
])
->setFinder($finder);

return $config;
18 changes: 9 additions & 9 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';

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 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';

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
6 changes: 4 additions & 2 deletions Controller/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,17 @@ public function cgetAction(Request $request): Response

foreach ($request->query->all() as $filterKey => $filterValue) {
if (isset($fieldDescriptors[$filterKey])) {
$listBuilder->where($fieldDescriptors[$filterKey], $filterValue);
$listBuilder->where($fieldDescriptors[$filterKey], (string) $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
7 changes: 5 additions & 2 deletions Controller/ThreadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,23 @@ public function cgetAction(Request $request): Response

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

/** @var string $typeParameter */
$typeParameter = $request->get('types');
if ($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
4 changes: 2 additions & 2 deletions Controller/WebsiteCommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public function cgetCommentsAction(string $threadId, Request $request): Response
{
list($type, $entityId) = $this->getThreadIdParts($threadId);

$limit = $request->query->getInt('limit') ?? 10;
$offset = $request->query->getInt('offset') ?? 0;
$limit = $request->query->getInt('limit', 10);
$offset = $request->query->getInt('offset', 0);

$pageSize = $request->get('pageSize');
if ($pageSize) {
Expand Down
3 changes: 0 additions & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('sulu_comment');
Expand Down
10 changes: 2 additions & 8 deletions DependencyInjection/SuluCommentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ class SuluCommentExtension extends Extension implements PrependExtensionInterfac
{
use PersistenceExtensionTrait;

/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
public function prepend(ContainerBuilder $container): void
{
if ($container->hasExtension('jms_serializer')) {
$container->prependExtensionConfig(
Expand Down Expand Up @@ -79,10 +76,7 @@ public function prepend(ContainerBuilder $container)
}
}

/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
Expand Down
2 changes: 1 addition & 1 deletion Entity/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function getParent(): ?CommentInterface
return $this->parent;
}

public function setParent(?CommentInterface $parent = null): CommentInterface
public function setParent(CommentInterface $parent = null): CommentInterface
{
$this->parent = $parent;

Expand Down
4 changes: 2 additions & 2 deletions Entity/CommentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

interface CommentInterface
{
const STATE_UNPUBLISHED = 0;
public const STATE_UNPUBLISHED = 0;

const STATE_PUBLISHED = 1;
public const STATE_PUBLISHED = 1;

public function getId(): int;

Expand Down
20 changes: 10 additions & 10 deletions Events/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@

final class Events
{
const PRE_PERSIST_EVENT = 'sulu_comment.pre_persist';
public const PRE_PERSIST_EVENT = 'sulu_comment.pre_persist';

const POST_PERSIST_EVENT = 'sulu_comment.post_persist';
public const POST_PERSIST_EVENT = 'sulu_comment.post_persist';

const PRE_DELETE_EVENT = 'sulu_comment.pre_delete';
public const PRE_DELETE_EVENT = 'sulu_comment.pre_delete';

const POST_DELETE_EVENT = 'sulu_comment.post_delete';
public const POST_DELETE_EVENT = 'sulu_comment.post_delete';

const PRE_UPDATE_EVENT = 'sulu_comment.pre_update';
public const PRE_UPDATE_EVENT = 'sulu_comment.pre_update';

const PUBLISH_EVENT = 'sulu_comment.publish';
public const PUBLISH_EVENT = 'sulu_comment.publish';

const UNPUBLISH_EVENT = 'sulu_comment.unpublish';
public const UNPUBLISH_EVENT = 'sulu_comment.unpublish';

const THREAD_PRE_UPDATE_EVENT = 'sulu_comment.thread.pre_update';
public const THREAD_PRE_UPDATE_EVENT = 'sulu_comment.thread.pre_update';

const THREAD_PRE_DELETE_EVENT = 'sulu_comment.thread.pre_delete';
public const THREAD_PRE_DELETE_EVENT = 'sulu_comment.thread.pre_delete';

const THREAD_POST_DELETE_EVENT = 'sulu_comment.thread.post_delete';
public const THREAD_POST_DELETE_EVENT = 'sulu_comment.thread.post_delete';

/**
* Private constructor.
Expand Down
2 changes: 1 addition & 1 deletion Form/Type/CommentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder->add('submit', SubmitType::class);
}

public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setRequired('threadId');
$resolver->setDefault('referrer', null);
Expand Down
2 changes: 1 addition & 1 deletion Manager/CommentManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function addComment(
string $type,
string $entityId,
CommentInterface $comment,
?string $threadTitle = null
string $threadTitle = null
Prokyonn marked this conversation as resolved.
Show resolved Hide resolved
): ThreadInterface;

public function update(CommentInterface $comment): CommentInterface;
Expand Down
5 changes: 1 addition & 4 deletions SuluCommentBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ class SuluCommentBundle extends Bundle
{
use PersistenceBundleTrait;

/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container)
public function build(ContainerBuilder $container): void
{
$this->buildPersistence(
[
Expand Down
2 changes: 1 addition & 1 deletion Tests/Application/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
APP_ENV=test
DATABASE_URL=mysql://root@localhost:3306/su_comment_test
DATABASE_URL=mysql://root@127.0.0.1:3306/su_comment_test
10 changes: 8 additions & 2 deletions Tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

class Kernel extends SuluTestKernel
{
public function registerBundles()
public function registerBundles(): iterable
{
$bundles = parent::registerBundles();
$bundles[] = new SuluCommentBundle();
Expand All @@ -38,9 +38,15 @@ public function registerContainerConfiguration(LoaderInterface $loader)

$context = $this->getContext();
$loader->load(__DIR__ . '/config/config_' . $context . '.yml');

if (\version_compare(Kernel::VERSION, '6.0.0', '>=')) {
$loader->load(__DIR__ . '/config/security-6.yml');
} else {
$loader->load(__DIR__ . '/config/security-5-4.yml');
}
}

protected function getKernelParameters()
protected function getKernelParameters(): array
{
$parameters = parent::getKernelParameters();

Expand Down
2 changes: 1 addition & 1 deletion Tests/Application/bin/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);
// umask(0000);

set_time_limit(0);

Expand Down
2 changes: 1 addition & 1 deletion Tests/Application/config/config_admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ parameters:
database.url: '%env(resolve:DATABASE_URL)%'

framework:
router: { resource: "%kernel.root_dir%/config/routing_admin.yml" }
router: { resource: "%kernel.project_dir%/config/routing_admin.yml" }

doctrine:
orm:
Expand Down
6 changes: 1 addition & 5 deletions Tests/Application/config/config_website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ parameters:
database.url: '%env(resolve:DATABASE_URL)%'

framework:
router: { resource: "%kernel.root_dir%/config/routing_website.yml" }
router: { resource: "%kernel.project_dir%/config/routing_website.yml" }

security:
access_decision_manager:
strategy: affirmative

encoders:
Prokyonn marked this conversation as resolved.
Show resolved Hide resolved
Sulu\Bundle\SecurityBundle\Entity\User: plaintext

providers:
testprovider:
id: test_user_provider
Expand All @@ -22,7 +19,6 @@ security:
firewalls:
test:
http_basic: ~
anonymous: ~

sulu_test:
enable_test_user_provider: true
Expand Down
3 changes: 3 additions & 0 deletions Tests/Application/config/security-5-4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
security:
encoders:
Sulu\Bundle\SecurityBundle\Entity\User: plaintext
3 changes: 3 additions & 0 deletions Tests/Application/config/security-6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
security:
password_hashers:
Sulu\Bundle\SecurityBundle\Entity\User: plaintext
Loading
Loading