Skip to content

Commit bd6fad2

Browse files
author
zhoutianliang
committed
update symfony to ^7.0
1 parent 57a75d1 commit bd6fad2

File tree

12 files changed

+78
-105
lines changed

12 files changed

+78
-105
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33

44
/_connector
55
/Resources/public
6+
.phpunit.result.cache
7+
.idea

Authentication/Authentication.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Authentication implements AuthenticationInterface
2121
/**
2222
* @var ContainerInterface
2323
*/
24-
protected $container;
24+
protected ContainerInterface $container;
2525

2626
/**
2727
* {@inheritdoc}
@@ -36,7 +36,7 @@ public function authenticate(): bool
3636
*
3737
* @param ContainerInterface|null $container A ContainerInterface instance or null
3838
*/
39-
public function setContainer(ContainerInterface $container = null)
39+
public function setContainer(ContainerInterface $container = null): void
4040
{
4141
$this->container = $container;
4242
}

Authentication/AuthenticationInterface.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@
1111

1212
namespace CKSource\Bundle\CKFinderBundle\Authentication;
1313

14-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
15-
1614
/**
1715
* Interface for the CKFinder authentication service.
1816
*/
19-
interface AuthenticationInterface extends ContainerAwareInterface
17+
interface AuthenticationInterface
2018
{
2119
/**
2220
* @return bool `true` if the current user was successfully authenticated within CKFinder.
2321
*/
24-
public function authenticate();
22+
public function authenticate(): bool;
2523
}

Command/CKFinderDownloadCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
*/
2727
class CKFinderDownloadCommand extends Command
2828
{
29-
const LATEST_VERSION = '3.6.1';
29+
const LATEST_VERSION = '3.7.0';
3030

3131
/**
3232
* {@inheritdoc}
3333
*/
34-
protected function configure()
34+
protected function configure(): void
3535
{
3636
$this->setName('ckfinder:download')
3737
->setDescription('Downloads the CKFinder distribution package and extracts it to CKSourceCKFinderBundle.');
@@ -42,7 +42,7 @@ protected function configure()
4242
*
4343
* @return string
4444
*/
45-
protected function buildPackageUrl()
45+
protected function buildPackageUrl(): string
4646
{
4747
$packageVersion = self::LATEST_VERSION;
4848

@@ -52,7 +52,7 @@ protected function buildPackageUrl()
5252
/**
5353
* {@inheritdoc}
5454
*/
55-
protected function execute(InputInterface $input, OutputInterface $output)
55+
protected function execute(InputInterface $input, OutputInterface $output): int
5656
{
5757
$targetPublicPath = realpath(__DIR__ . '/../Resources/public');
5858

Config/Definition/VariableArrayNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class VariableArrayNode extends VariableNode
2828
*
2929
* @var array
3030
*/
31-
protected $requiredKeys = array();
31+
protected array $requiredKeys = array();
3232

3333
/**
3434
* @param string $name
@@ -44,7 +44,7 @@ public function __construct($name, NodeInterface $parent = null, array $required
4444
/**
4545
* {@inheritdoc}
4646
*/
47-
protected function validateType($value)
47+
protected function validateType($value): void
4848
{
4949
if (!is_array($value)) {
5050
$ex = new InvalidTypeException(sprintf(

DependencyInjection/Configuration.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,10 @@ class Configuration implements ConfigurationInterface
2424
/**
2525
* {@inheritdoc}
2626
*/
27-
public function getConfigTreeBuilder()
27+
public function getConfigTreeBuilder(): TreeBuilder
2828
{
29-
if (method_exists(TreeBuilder::class, 'getRootNode')) {
30-
$treeBuilder = new TreeBuilder('ckfinder');
31-
$rootNode = $treeBuilder->getRootNode();
32-
} else {
33-
$treeBuilder = new TreeBuilder();
34-
$rootNode = $treeBuilder->root('ckfinder');
35-
}
29+
$treeBuilder = new TreeBuilder('ckfinder');
30+
$rootNode = $treeBuilder->getRootNode();
3631

3732
$rootNode->append($this->addConnectorNode());
3833

@@ -46,13 +41,8 @@ public function getConfigTreeBuilder()
4641
*/
4742
public function addConnectorNode()
4843
{
49-
if (method_exists(TreeBuilder::class, 'getRootNode')) {
50-
$treeBuilder = new TreeBuilder('connector');
51-
$connectorNode = $treeBuilder->getRootNode();
52-
} else {
53-
$treeBuilder = new TreeBuilder();
54-
$connectorNode = $treeBuilder->root('connector');
55-
}
44+
$treeBuilder = new TreeBuilder('connector');
45+
$connectorNode = $treeBuilder->getRootNode();
5646

5747
$connectorNode
5848
->children()

Factory/ConnectorFactory.php

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,32 @@
33
namespace CKSource\Bundle\CKFinderBundle\Factory;
44

55
use CKSource\Bundle\CKFinderBundle\Authentication\AuthenticationInterface;
6-
use CKSource\Bundle\CKFinderBundle\Polyfill\CommandResolver;
76
use CKSource\CKFinder\CKFinder;
8-
use Symfony\Component\HttpKernel\HttpKernel;
9-
use Symfony\Component\HttpKernel\Kernel;
107

118
class ConnectorFactory
129
{
1310
/**
1411
* @var array
1512
*/
16-
protected $connectorConfig;
13+
protected array $connectorConfig;
1714

1815
/**
1916
* @var AuthenticationInterface
2017
*/
21-
protected $authenticationService;
18+
protected AuthenticationInterface $authenticationService;
2219

2320
/**
24-
* @var CKFinder
21+
* @var ?CKFinder
2522
*/
26-
protected $connectorInstance;
23+
protected ?CKFinder $connectorInstance = null;
2724

2825
/**
2926
* ConnectorFactory constructor.
3027
*
31-
* @param $connectorConfig
32-
* @param $authenticationService
28+
* @param array $connectorConfig
29+
* @param AuthenticationInterface $authenticationService
3330
*/
34-
public function __construct($connectorConfig, $authenticationService)
31+
public function __construct(array $connectorConfig, AuthenticationInterface $authenticationService)
3532
{
3633
$this->connectorConfig = $connectorConfig;
3734
$this->authenticationService = $authenticationService;
@@ -40,7 +37,7 @@ public function __construct($connectorConfig, $authenticationService)
4037
/**
4138
* @return CKFinder
4239
*/
43-
public function getConnector()
40+
public function getConnector(): CKFinder
4441
{
4542
if ($this->connectorInstance) {
4643
return $this->connectorInstance;
@@ -50,36 +47,8 @@ public function getConnector()
5047

5148
$connector['authentication'] = $this->authenticationService;
5249

53-
if (Kernel::MAJOR_VERSION === 4) {
54-
$this->setupForV4Kernel($connector);
55-
}
56-
5750
$this->connectorInstance = $connector;
5851

5952
return $connector;
6053
}
61-
62-
/**
63-
* Prepares the internal CKFinder's DI container to use the version 4+ of HttpKernel.
64-
*
65-
* @param \CKSource\CKFinder\CKFinder $ckfinder
66-
*/
67-
protected function setupForV4Kernel($ckfinder)
68-
{
69-
$ckfinder['resolver'] = function () use ($ckfinder) {
70-
$commandResolver = new CommandResolver($ckfinder);
71-
$commandResolver->setCommandsNamespace(CKFinder::COMMANDS_NAMESPACE);
72-
$commandResolver->setPluginsNamespace(CKFinder::PLUGINS_NAMESPACE);
73-
return $commandResolver;
74-
};
75-
76-
$ckfinder['kernel'] = function () use ($ckfinder) {
77-
return new HttpKernel(
78-
$ckfinder['dispatcher'],
79-
$ckfinder['resolver'],
80-
$ckfinder['request_stack'],
81-
$ckfinder['resolver']
82-
);
83-
};
84-
}
8554
}

Polyfill/CommandResolver.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
namespace CKSource\Bundle\CKFinderBundle\Polyfill;
44

5+
use Symfony\Component\HttpFoundation\Request;
56
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
67

78
/**
89
* Class CommandResolver
910
*
1011
* @deprecated
1112
*/
12-
class CommandResolver extends \CKSource\CKFinder\CommandResolver implements ArgumentResolverInterface {}
13+
class CommandResolver extends \CKSource\CKFinder\CommandResolver implements ArgumentResolverInterface {
14+
public function getArguments(Request $request, callable $controller, ?\ReflectionFunctionAbstract $reflector = null): array
15+
{
16+
// TODO: Implement getArguments() method.
17+
return [];
18+
}
19+
}

Tests/Config/Definition/VariableArrayNodeTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,8 @@ public function testNormalizeThrowsExceptionIfValueIsNotArray(): void
3737
*/
3838
public function testMerge(): void
3939
{
40-
if (method_exists(TreeBuilder::class, 'getRootNode')) {
41-
$builder = new TreeBuilder('root');
42-
$rootNode = $builder->getRootNode();
43-
} else {
44-
$builder = new TreeBuilder();
45-
$rootNode = $builder->root('root');
46-
}
40+
$builder = new TreeBuilder('root');
41+
$rootNode = $builder->getRootNode();
4742

4843
$tree = $rootNode
4944
->children()

Tests/Fixtures/Authentication/CustomAuthentication.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,27 @@
1919
*/
2020
class CustomAuthentication implements AuthenticationInterface
2121
{
22-
protected $authenticated = false;
22+
23+
/**
24+
* @var ContainerInterface
25+
*/
26+
protected ContainerInterface $container;
27+
28+
29+
protected bool $authenticated = false;
2330

2431
/**
2532
* @param bool $authenticated
2633
*/
27-
public function setAuthenticated($authenticated)
34+
public function setAuthenticated(bool $authenticated): void
2835
{
29-
$this->authenticated = (bool) $authenticated;
36+
$this->authenticated = $authenticated;
3037
}
3138

3239
/**
3340
* @return bool
3441
*/
35-
public function authenticate()
42+
public function authenticate(): bool
3643
{
3744
return $this->authenticated;
3845
}
@@ -42,8 +49,9 @@ public function authenticate()
4249
*
4350
* @param ContainerInterface|null $container A ContainerInterface instance or null
4451
*/
45-
public function setContainer(ContainerInterface $container = null)
52+
public function setContainer(ContainerInterface $container = null): void
4653
{
4754
// stub
55+
$this->container = $container;
4856
}
4957
}

0 commit comments

Comments
 (0)