Skip to content

Commit 26cee4d

Browse files
committed
cleanup code for new symfony versions
1 parent d00ae5a commit 26cee4d

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ Changelog
44
5.x
55
===
66

7+
5.0.1
8+
-----
9+
10+
* Cleanup PHP 8.1 language features.
11+
* Simplify configuration code.
12+
713
5.0.0
814
-----
915

1016
* Drop support for Symfony < 6.4
17+
* Drop support for PHP < 8.1
1118
* The default framework configuration no longer enables validation attributes.
1219
* The PHPCR-ODM additional namespace is expected to use attributes rather than annotations.
1320

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
},
1616
"require-dev": {
1717
"doctrine/doctrine-bundle": "^1.8 || ^2.0",
18+
"doctrine/phpcr-odm": "^2.0",
1819
"doctrine/phpcr-bundle": "^3.0",
20+
"jackalope/jackalope-doctrine-dbal": "^2.0",
1921
"symfony/console": "^6.4 || ^7.0",
2022
"symfony/dependency-injection": "^6.4 || ^7.0",
2123
"symfony/doctrine-bridge": "^6.4 || ^7.0",

src/DependencyInjection/Compiler/TestContainerPass.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,16 @@
2020
class TestContainerPass implements CompilerPassInterface
2121
{
2222
/**
23-
* An array of service id's which should be public in a test scenario.
24-
*
25-
* @var array
23+
* @var string[] Service id's which should be public in a test scenario.
2624
*/
27-
private $services = [];
25+
private array $services;
2826

2927
public function __construct(array $services = [])
3028
{
3129
$this->services = $services;
3230
}
3331

34-
public function process(ContainerBuilder $container)
32+
public function process(ContainerBuilder $container): void
3533
{
3634
foreach ($container->getDefinitions() as $id => $definition) {
3735
if (\in_array($id, $this->services, true)) {

src/Functional/BaseTestCase.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,12 @@ protected function getFrameworkBundleClient(): KernelBrowser
113113
*
114114
* @see self::getDbManager
115115
*/
116-
protected function db($type)
116+
protected function db(string $type): PhpcrDecorator|PHPCR|ORM
117117
{
118118
return $this->getDbManager($type);
119119
}
120120

121-
/**
122-
* @return ORM|PHPCR
123-
*/
124-
protected function getDbManager(string $type)
121+
protected function getDbManager(string $type): PhpcrDecorator|PHPCR|ORM
125122
{
126123
if (isset($this->dbManagers[$type])) {
127124
return $this->dbManagers[$type];

src/Functional/DbManager/PHPCR.php

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

2424
class PHPCR
2525
{
26-
protected $container;
26+
protected ContainerInterface $container;
2727

2828
protected ?DocumentManager $om = null;
2929

src/HttpKernel/TestKernel.php

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@
3232
*/
3333
abstract class TestKernel extends Kernel
3434
{
35-
protected $bundleSets = [];
35+
protected array $bundleSets = [];
3636

37-
protected $requiredBundles = [];
37+
protected array $requiredBundles = [];
3838

3939
/**
4040
* Register commonly needed bundle sets and then
4141
* after initializing the parent kernel, let the
4242
* concrete kernel configure itself using the abstracvt
4343
* configure() command.
4444
*/
45-
public function __construct($env, $debug)
45+
public function __construct(string $env, bool $debug)
4646
{
4747
$defaultBundles = [
4848
FrameworkBundle::class,
@@ -72,23 +72,25 @@ public function __construct($env, $debug)
7272
* $this->addBundle(new MyBundle);
7373
* $this->addBundles(array(new Bundle1, new Bundle2));
7474
*/
75-
abstract protected function configure();
75+
abstract protected function configure(): void;
7676

7777
/**
7878
* Register a set of bundles with the given name.
7979
*
8080
* This method does not add the bundles to the kernel,
8181
* it just makes a set available.
8282
*/
83-
public function registerBundleSet($name, $bundles)
83+
public function registerBundleSet(string $name, array $bundles): void
8484
{
8585
$this->bundleSets[$name] = $bundles;
8686
}
8787

8888
/**
8989
* The bundles in the named sets will be added to the Kernel.
90+
*
91+
* @param string[] $names
9092
*/
91-
public function requireBundleSets(array $names)
93+
public function requireBundleSets(array $names): void
9294
{
9395
foreach ($names as $name) {
9496
$this->requireBundleSet($name);
@@ -102,7 +104,7 @@ public function requireBundleSets(array $names)
102104
* This enables us to declare pre-defined bundle sets without
103105
* worrying if the bundle is actually present or not.
104106
*/
105-
public function requireBundleSet($name)
107+
public function requireBundleSet(string $name): void
106108
{
107109
if (!isset($this->bundleSets[$name])) {
108110
throw new \InvalidArgumentException(sprintf(
@@ -127,7 +129,7 @@ public function requireBundleSet($name)
127129
/**
128130
* Add concrete bundles to the kernel.
129131
*/
130-
public function addBundles(array $bundles)
132+
public function addBundles(array $bundles): void
131133
{
132134
foreach ($bundles as $bundle) {
133135
$this->addBundle($bundle);
@@ -137,7 +139,7 @@ public function addBundles(array $bundles)
137139
/**
138140
* Add a concrete bundle to the kernel.
139141
*/
140-
public function addBundle(BundleInterface $bundle)
142+
public function addBundle(BundleInterface $bundle): void
141143
{
142144
$this->requiredBundles[] = $bundle;
143145
}
@@ -153,28 +155,22 @@ public function registerBundles(): iterable
153155
}
154156

155157
/**
156-
* Returns the KernelDir of the CHILD class,
158+
* Returns the project directory of the CHILD class,
157159
* i.e. the concrete implementation in the bundles
158160
* src/ directory (or wherever).
159161
*/
160-
public function getKernelDir()
161-
{
162-
return $this->getProjectDir();
163-
}
164-
165162
public function getProjectDir(): string
166163
{
167164
$refl = new \ReflectionClass($this);
168165
$fname = $refl->getFileName();
169-
$kernelDir = \dirname($fname);
170166

171-
return $kernelDir;
167+
return \dirname($fname);
172168
}
173169

174170
public function getCacheDir(): string
175171
{
176172
return implode('/', [
177-
$this->getKernelDir(),
173+
$this->getProjectDir(),
178174
'var',
179175
'cache',
180176
]);
@@ -192,7 +188,7 @@ public function getLogDir(): string
192188
/**
193189
* Registers the bundles defined in config/bundles.php.
194190
*/
195-
protected function registerConfiguredBundles()
191+
protected function registerConfiguredBundles(): void
196192
{
197193
$bundleFilePath = $this->getKernelDir().'/config/bundles.php';
198194
if (!file_exists($bundleFilePath)) {

0 commit comments

Comments
 (0)