Skip to content

Commit 921c713

Browse files
committed
modernize
1 parent d997f63 commit 921c713

34 files changed

+337
-824
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Changelog
55
-----
66

77
* Support Symfony 6
8+
* Use DateTimeInterface instead of DateTime.
89
* Adjust to doctrine and twig BC breaks. If you extended classes or customized services, check for old `Twig_*` classes or `Doctrine\Common\Persistence` namespace.
910
* Drop support for old Symfony versions
1011
* Drop support for old PHP versions

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"symfony/security-core": "^6.4"
2020
},
2121
"require-dev": {
22+
"ext-dom": "*",
2223
"jackalope/jackalope-doctrine-dbal": "^1.3 || ^2.0",
2324
"mockery/mockery": "^1.4.1",
2425
"symfony-cmf/routing-bundle": "dev-sf7 as 3.1.0",

src/CmfCoreBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class CmfCoreBundle extends Bundle
1919
{
20-
public function build(ContainerBuilder $container)
20+
public function build(ContainerBuilder $container): void
2121
{
2222
$container->addCompilerPass(new AddPublishedVotersPass());
2323
}

src/DependencyInjection/CmfCoreExtension.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class CmfCoreExtension extends Extension implements PrependExtensionInterface
2929
*
3030
* {@inheritdoc}
3131
*/
32-
public function prepend(ContainerBuilder $container)
32+
public function prepend(ContainerBuilder $container): void
3333
{
3434
// process the configuration of CmfCoreExtension
3535
$configs = $container->getExtensionConfig($this->getAlias());
@@ -243,10 +243,7 @@ public function prepend(ContainerBuilder $container)
243243
}
244244
}
245245

246-
/**
247-
* {@inheritdoc}
248-
*/
249-
public function load(array $configs, ContainerBuilder $container)
246+
public function load(array $configs, ContainerBuilder $container): void
250247
{
251248
$config = $this->processConfiguration(new Configuration(), $configs);
252249

@@ -283,7 +280,7 @@ public function load(array $configs, ContainerBuilder $container)
283280
/**
284281
* Setup the cmf_core_checkbox_url_label form type if the routing bundle is there.
285282
*/
286-
public function setupFormTypes(ContainerBuilder $container, LoaderInterface $loader)
283+
public function setupFormTypes(ContainerBuilder $container, LoaderInterface $loader): void
287284
{
288285
$bundles = $container->getParameter('kernel.bundles');
289286
if (isset($bundles['CmfRoutingBundle'])) {
@@ -302,7 +299,7 @@ public function setupFormTypes(ContainerBuilder $container, LoaderInterface $loa
302299
*
303300
* @throws InvalidConfigurationException
304301
*/
305-
private function loadPublishWorkflow($config, XmlFileLoader $loader, ContainerBuilder $container)
302+
private function loadPublishWorkflow($config, XmlFileLoader $loader, ContainerBuilder $container): void
306303
{
307304
$bundles = $container->getParameter('kernel.bundles');
308305

@@ -336,18 +333,12 @@ private function loadPublishWorkflow($config, XmlFileLoader $loader, ContainerBu
336333
}
337334
}
338335

339-
/**
340-
* {@inheritdoc}
341-
*/
342-
public function getXsdValidationBasePath()
336+
public function getXsdValidationBasePath(): bool|string
343337
{
344338
return __DIR__.'/../Resources/config/schema';
345339
}
346340

347-
/**
348-
* {@inheritdoc}
349-
*/
350-
public function getNamespace()
341+
public function getNamespace(): string
351342
{
352343
return 'http://cmf.symfony.com/schema/dic/core';
353344
}

src/DependencyInjection/Compiler/AddPublishedVotersPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AddPublishedVotersPass implements CompilerPassInterface
3131
*
3232
* {@inheritdoc}
3333
*/
34-
public function process(ContainerBuilder $container)
34+
public function process(ContainerBuilder $container): void
3535
{
3636
if (!$container->hasDefinition('cmf_core.publish_workflow.access_decision_manager')) {
3737
return;

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616

1717
class Configuration implements ConfigurationInterface
1818
{
19-
/**
20-
* {@inheritdoc}
21-
*/
22-
public function getConfigTreeBuilder()
19+
public function getConfigTreeBuilder(): TreeBuilder
2320
{
2421
$treeBuilder = new TreeBuilder('cmf_core');
2522
$rootNode = $treeBuilder->getRootNode();

src/Doctrine/Phpcr/NonTranslatableMetadataListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class NonTranslatableMetadataListener implements EventSubscriber
2626
/**
2727
* @return array
2828
*/
29-
public function getSubscribedEvents()
29+
public function getSubscribedEvents(): array
3030
{
3131
return [
3232
'loadClassMetadata',
@@ -37,7 +37,7 @@ public function getSubscribedEvents()
3737
* Handle the load class metadata event: remove translated attribute from
3838
* fields and remove the locale mapping if present.
3939
*/
40-
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
40+
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void
4141
{
4242
/** @var ClassMetadata $meta */
4343
$meta = $eventArgs->getClassMetadata();

src/Doctrine/Phpcr/TranslatableMetadataListener.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,15 @@
2323
*/
2424
class TranslatableMetadataListener implements EventSubscriber
2525
{
26-
/**
27-
* @var string
28-
*/
29-
private $translationStrategy;
30-
31-
/**
32-
* @param string $translationStrategy
33-
*/
34-
public function __construct($translationStrategy)
35-
{
36-
$this->translationStrategy = $translationStrategy;
26+
public function __construct(
27+
private string $translationStrategy
28+
) {
3729
}
3830

3931
/**
4032
* @return array
4133
*/
42-
public function getSubscribedEvents()
34+
public function getSubscribedEvents(): array
4335
{
4436
return [
4537
'loadClassMetadata',
@@ -49,7 +41,7 @@ public function getSubscribedEvents()
4941
/**
5042
* Handle the load class metadata event: set the translation strategy.
5143
*/
52-
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
44+
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void
5345
{
5446
/** @var ClassMetadata $meta */
5547
$meta = $eventArgs->getClassMetadata();

src/EventListener/PublishWorkflowListener.php

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,47 +26,29 @@
2626
*/
2727
class PublishWorkflowListener implements EventSubscriberInterface
2828
{
29-
/**
30-
* @var PublishWorkflowChecker
31-
*/
32-
protected $publishWorkflowChecker;
33-
34-
/**
35-
* The attribute to check with the workflow checker, typically VIEW or VIEW_ANONYMOUS.
36-
*
37-
* @var string
38-
*/
39-
private $publishWorkflowPermission;
40-
41-
/**
42-
* @param string $attribute the attribute name to check
43-
*/
44-
public function __construct(PublishWorkflowChecker $publishWorkflowChecker, $attribute = PublishWorkflowChecker::VIEW_ATTRIBUTE)
29+
public function __construct(
30+
private PublishWorkflowChecker $publishWorkflowChecker,
31+
/**
32+
* The attribute to check with the workflow checker, typically VIEW or VIEW_ANONYMOUS.
33+
*/
34+
private string $publishWorkflowPermission = PublishWorkflowChecker::VIEW_ATTRIBUTE)
4535
{
46-
$this->publishWorkflowChecker = $publishWorkflowChecker;
47-
$this->publishWorkflowPermission = $attribute;
4836
}
4937

50-
/**
51-
* @return string
52-
*/
53-
public function getPublishWorkflowPermission()
38+
public function getPublishWorkflowPermission(): string
5439
{
5540
return $this->publishWorkflowPermission;
5641
}
5742

58-
/**
59-
* @param string $attribute specify what permission to check, typically VIEW or VIEW_ANONYMOUS
60-
*/
61-
public function setPublishWorkflowPermission($attribute)
43+
public function setPublishWorkflowPermission(string $attribute): void
6244
{
6345
$this->publishWorkflowPermission = $attribute;
6446
}
6547

6648
/**
6749
* Handling the request event.
6850
*/
69-
public function onKernelRequest(RequestEvent $event)
51+
public function onKernelRequest(RequestEvent $event): void
7052
{
7153
$request = $event->getRequest();
7254

@@ -83,10 +65,8 @@ public function onKernelRequest(RequestEvent $event)
8365

8466
/**
8567
* We are only interested in request events.
86-
*
87-
* @return array
8868
*/
89-
public static function getSubscribedEvents()
69+
public static function getSubscribedEvents(): array
9070
{
9171
return [
9272
KernelEvents::REQUEST => [['onKernelRequest', 1]],

src/Form/Type/CheckboxUrlLabelFormType.php

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,60 +34,46 @@
3434
*/
3535
class CheckboxUrlLabelFormType extends AbstractType
3636
{
37-
/**
38-
* @var RouterInterface
39-
*/
40-
protected $router;
41-
42-
public function __construct(RouterInterface $router)
43-
{
44-
$this->router = $router;
37+
public function __construct(
38+
private RouterInterface $router
39+
) {
4540
}
4641

4742
/**
4843
* {@inheritdoc}
4944
*/
50-
public function buildView(FormView $view, FormInterface $form, array $options)
45+
public function buildView(FormView $view, FormInterface $form, array $options): void
5146
{
5247
$routes = $options['routes'];
5348
$paths = [];
5449
foreach ($routes as $key => $route) {
55-
$name = isset($route['name']) ? $route['name'] : '';
56-
$parameters = isset($route['parameters']) ? $route['parameters'] : [];
57-
$referenceType = isset($route['referenceType']) ? $route['referenceType'] : UrlGeneratorInterface::ABSOLUTE_PATH;
50+
$name = $route['name'] ?? '';
51+
$parameters = $route['parameters'] ?? [];
52+
$referenceType = $route['referenceType'] ?? UrlGeneratorInterface::ABSOLUTE_PATH;
5853
$paths[$key] = $this->router->generate($name, $parameters, $referenceType);
5954
}
6055
$view->vars['paths'] = $paths;
6156
parent::buildView($view, $form, $options);
6257
}
6358

64-
public function configureOptions(OptionsResolver $resolver)
59+
public function configureOptions(OptionsResolver $resolver): void
6560
{
6661
$resolver->setDefaults([
6762
'routes' => [],
6863
]);
6964
}
7065

71-
/**
72-
* {@inheritdoc}
73-
*/
74-
public function getName()
66+
public function getName(): string
7567
{
7668
return $this->getBlockPrefix();
7769
}
7870

79-
/**
80-
* {@inheritdoc}
81-
*/
82-
public function getBlockPrefix()
71+
public function getBlockPrefix(): string
8372
{
8473
return 'cmf_core_checkbox_url_label';
8574
}
8675

87-
/**
88-
* {@inheritdoc}
89-
*/
90-
public function getParent()
76+
public function getParent(): ?string
9177
{
9278
return CheckboxType::class;
9379
}

0 commit comments

Comments
 (0)