Skip to content

Commit 3e5746a

Browse files
committed
Fix compat for PHP 8.4
1 parent b03fc51 commit 3e5746a

15 files changed

Lines changed: 110 additions & 32 deletions

phpunit.xml.dist

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
5-
bootstrap="vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php"
6-
verbose="true"
7-
colors="true">
8-
<testsuites>
9-
<testsuite name="unit">
10-
<directory suffix="Test.php">tests</directory>
11-
</testsuite>
12-
</testsuites>
13-
<coverage processUncoveredFiles="true">
14-
<include>
15-
<directory suffix=".php">src</directory>
16-
</include>
17-
</coverage>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
4+
bootstrap="tests/bootstrap.php"
5+
cacheResultFile=".phpunit.result.cache"
6+
executionOrder="depends,defects"
7+
forceCoversAnnotation="true"
8+
beStrictAboutCoversAnnotation="true"
9+
beStrictAboutOutputDuringTests="false"
10+
beStrictAboutTodoAnnotatedTests="true"
11+
convertDeprecationsToExceptions="true"
12+
failOnRisky="true"
13+
failOnWarning="true"
14+
verbose="true">
15+
<testsuites>
16+
<testsuite name="default">
17+
<directory>tests</directory>
18+
</testsuite>
19+
</testsuites>
20+
21+
<coverage cacheDirectory=".phpunit.cache/code-coverage"
22+
processUncoveredFiles="true">
23+
<include>
24+
<directory suffix=".php">src</directory>
25+
</include>
26+
</coverage>
1827
</phpunit>

src/View/View.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function render(array $context = []): string;
6363
*
6464
* @return string Rendered HTML content.
6565
*/
66-
public function section(string $view, array $context = [], $type = null): string;
66+
public function section(string $view, ?array $context = null, ?string $type = null): string;
6767

6868
/**
6969
* Get the entire array of contextual data.

src/View/View/AbstractView.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ abstract class AbstractView implements View
8787
* @param ViewBuilder $viewBuilder View builder instance to use.
8888
* @param array $context Initial context to use.
8989
*/
90-
public function __construct(string $uri, Engine $engine, ViewBuilder $viewBuilder = null, array $context = [])
90+
public function __construct(string $uri, Engine $engine, ?ViewBuilder $viewBuilder = null, array $context = [])
9191
{
9292
$this->_uri_ = $uri;
9393
$this->_engine_ = $engine;
@@ -138,7 +138,7 @@ public function render(array $context = [], bool $echo = false): string
138138
* @throws FailedToProcessConfigException If the Config could not be processed.
139139
* @throws FailedToInstantiateView If the View could not be instantiated.
140140
*/
141-
public function section(string $view, array $context = null, $type = null): string
141+
public function section(string $view, ?array $context = null, ?string $type = null): string
142142
{
143143
$context = (null === $context)
144144
? $this->_context_

src/View/View/BaseView.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* @package BrightNucleus\View\View
2020
* @author Alain Schlesser <alain.schlesser@gmail.com>
2121
*/
22+
#[\AllowDynamicProperties]
2223
class BaseView extends AbstractView
2324
{
2425

src/View/View/BaseViewFinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class BaseViewFinder extends AbstractFinder implements ViewFinder
3838
* @return View View that was found.
3939
* @throws FailedToInstantiateFindable If the Findable could not be instantiated.
4040
*/
41-
public function find(array $criteria, Engine $engine = null): View
41+
public function find(array $criteria, ?Engine $engine = null): View
4242
{
4343
$uri = $criteria[0];
4444

src/View/View/NullView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function render(array $context = [], bool $echo = false): string
6666
*
6767
* @return string Rendered HTML content.
6868
*/
69-
public function section(string $view, array $context = [], $type = null): string
69+
public function section(string $view, ?array $context = null, ?string $type = null): string
7070
{
7171
return '';
7272
}

src/View/View/ViewFinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ interface ViewFinder extends Finder
4141
*
4242
* @return View View that was found.
4343
*/
44-
public function find(array $criteria, Engine $engine = null): View;
44+
public function find(array $criteria, ?Engine $engine = null): View;
4545

4646
/**
4747
* Get the NullObject.

src/View/ViewBuilder.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ class ViewBuilder
8686
* @throws FailedToProcessConfigException If the config could not be processed.
8787
*/
8888
public function __construct(
89-
ConfigInterface $config = null,
90-
ViewFinder $viewFinder = null,
91-
EngineFinder $engineFinder = null
89+
?ConfigInterface $config = null,
90+
?ViewFinder $viewFinder = null,
91+
?EngineFinder $engineFinder = null
9292
) {
9393
$this->processConfig($this->getConfig($config));
9494
$this->viewFinder = $viewFinder ?? $this->getViewFinder();
@@ -107,7 +107,7 @@ public function __construct(
107107
* @return View Instance of the requested view.
108108
* @throws FailedToInstantiateView If the view could not be instantiated.
109109
*/
110-
public function create(string $view, $type = null): View
110+
public function create(string $view, ?string $type = null): View
111111
{
112112
if (!array_key_exists($view, $this->viewPathCache)) {
113113
$uri = $this->scanLocations([$view]);
@@ -287,7 +287,7 @@ protected function getFinder($key)
287287
* @return View Resolved View object.
288288
* @throws FailedToInstantiateView If the view type could not be resolved.
289289
*/
290-
protected function resolveType($type, string $uri, Engine $engine = null): View
290+
protected function resolveType($type, string $uri, ?Engine $engine = null): View
291291
{
292292
$configKey = [static::VIEW_FINDER_KEY, 'Views', $type];
293293

@@ -332,6 +332,6 @@ protected function getConfig($config = []): ConfigInterface
332332
? ConfigFactory::createFromArray(array_merge_recursive($defaults->getArrayCopy(), $config->getArrayCopy()))
333333
: $defaults;
334334

335-
return $config->getSubConfig('BrightNucleus\View');
335+
return $config->getSubConfig('BrightNucleus\\View');
336336
}
337337
}

src/Views.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public static function getViewBuilder()
7979
* @return ViewBuilder Instance of the ViewBuilder.
8080
* @throws FailedToProcessConfigException If the Config could not be processed.
8181
*/
82-
public static function instantiateViewBuilder(ConfigInterface $config = null)
82+
public static function instantiateViewBuilder(?ConfigInterface $config = null)
8383
{
8484
return static::$viewBuilder = new ViewBuilder($config);
8585
}
@@ -95,7 +95,7 @@ public static function instantiateViewBuilder(ConfigInterface $config = null)
9595
* @return View Instance of the requested view.
9696
* @throws FailedToProcessConfigException If the Config could not be processed.
9797
*/
98-
public static function create($view, $type = null)
98+
public static function create(string $view, ?string $type = null)
9999
{
100100
$viewBuilder = static::getViewBuilder();
101101

@@ -114,7 +114,7 @@ public static function create($view, $type = null)
114114
* @return string Rendered HTML content.
115115
* @throws FailedToProcessConfigException If the Config could not be processed.
116116
*/
117-
public static function render($view, array $context = [], $type = null)
117+
public static function render($view, array $context = [], ?string $type = null)
118118
{
119119
$viewBuilder = static::getViewBuilder();
120120
$viewObject = $viewBuilder->create($view, $type);

tests/FilesystemLocationTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class FilesystemLocationTest extends TestCase
2828

2929
/**
3030
* @dataProvider fileSystemLocationDataProvider
31+
* @covers \BrightNucleus\View\Location\FilesystemLocation::getURI
32+
* @covers \BrightNucleus\View\Location\FilesystemLocation::getURIs
33+
* @covers \BrightNucleus\View\Location\FilesystemLocation::__construct
3134
*
3235
* @param string $path
3336
* @param array $extensions

0 commit comments

Comments
 (0)