Skip to content

Commit 856b7e6

Browse files
committed
Fix found warnings and deprecations
Those were found by test coverage.
1 parent 879d0ab commit 856b7e6

6 files changed

Lines changed: 22 additions & 23 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
run: composer require --no-progress --no-interaction --optimize-autoloader "typo3/cms-core:${{ matrix.typo3-version }}"
128128

129129
- name: PHPUnit Tests
130-
run: ./vendor/bin/phpunit --testdox --coverage-cobertura coverage/coverage.cobertura.xml
130+
run: ./vendor/bin/phpunit --testdox --display-all-issues --coverage-cobertura coverage/coverage.cobertura.xml
131131

132132
- name: Code Coverage Report
133133
uses: irongut/CodeCoverageSummary@v1.3.0

Classes/DataProvider/AbstractDataProvider.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,9 @@
3232
*/
3333
abstract class AbstractDataProvider implements DataProviderInterface
3434
{
35-
/**
36-
* @var array
37-
*/
38-
protected $settings;
35+
protected array $settings;
3936

40-
41-
public function __construct($settings)
37+
public function __construct(array $settings)
4238
{
4339
$this->settings = $settings;
4440
}

Classes/DataProvider/TyposcriptDataProvider.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@
2929

3030
class TyposcriptDataProvider extends AbstractDataProvider
3131
{
32-
/**
33-
* Entry point
34-
*
35-
* @return array
36-
*/
3732
public function provide()
3833
{
39-
return is_array($this->settings['variables']) ? $this->settings['variables'] : [];
34+
if (
35+
array_key_exists('variables', $this->settings)
36+
&& is_array($this->settings['variables'])
37+
) {
38+
return $this->settings['variables'];
39+
}
40+
41+
return [];
4042
}
4143
}

Classes/Engine/HandlebarsEngine.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __construct(array $settings)
7171
$this->template = $settings['template'] ?? $settings['templatePath'] ?? null;
7272
$this->dataProviders = $settings['dataProviders'] ?? [];
7373
$this->additionalData = $settings['additionalData'] ?? [];
74-
$this->tempPath = Environment::getProjectPath() . '/' . $settings['tempPath'];
74+
$this->tempPath = Environment::getProjectPath() . '/' . ($settings['tempPath'] ?? '');
7575
}
7676

7777
/**
@@ -179,7 +179,7 @@ protected function getPartialCode($cx, $name): string
179179
{
180180
$partialContent = '';
181181
$partialFileNameAndPath = $this->getPartialPathAndFileName($name);
182-
if (file_exists($partialFileNameAndPath)) {
182+
if (is_string($partialFileNameAndPath) && file_exists($partialFileNameAndPath)) {
183183
return file_get_contents($partialFileNameAndPath);
184184
}
185185
return $partialContent;

Classes/View/HandlebarsView.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public function render(?string $templateFileName = null): string
5757
protected function getContextVariables(): array
5858
{
5959
return [
60-
'extensionKey' => strtolower($this->renderingContext->getExtensionKey()),
61-
'controllerName' => strtolower($this->renderingContext->getControllerName()),
62-
'actionName' => strtolower($this->renderingContext->getActionName()),
60+
'extensionKey' => strtolower($this->renderingContext->getExtensionKey() ?? ''),
61+
'controllerName' => strtolower($this->renderingContext->getControllerName() ?? ''),
62+
'actionName' => strtolower($this->renderingContext->getActionName() ?? ''),
6363
];
6464
}
6565

Classes/ViewHelpers/RenderViewHelper.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Visol\Handlebars\ViewHelpers;
44

5+
use Psr\Http\Message\ServerRequestInterface;
56
use TYPO3\CMS\Core\Utility\GeneralUtility;
67
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
78
use Visol\Handlebars\Rendering\HandlebarsContext;
@@ -70,17 +71,17 @@ public function initializeArguments(): void
7071
$this->registerArgument('settings', 'array', '', false, []);
7172
$this->registerArgument('data', 'array', '', false, []);
7273
}
73-
74+
7475
public function render(): string
7576
{
7677
$template = $this->arguments['template'];
7778
$settings = $this->arguments['settings'];
7879
$data = $this->arguments['data'];
79-
80+
8081
$handlebarsView = GeneralUtility::makeInstance(HandlebarsView::class);
8182
$handlebarsRenderingContext = GeneralUtility::makeInstance(
8283
HandlebarsContext::class,
83-
$this->renderingContext->getRequest()
84+
$this->renderingContext->getAttribute(ServerRequestInterface::class)
8485
);
8586
$handlebarsView->setRenderingContext($handlebarsRenderingContext);
8687

@@ -89,9 +90,9 @@ public function render(): string
8990
} else {
9091
$settings = [];
9192
}
92-
93+
9394
$settings = array_replace_recursive($settings, [
94-
'templatesRootPath' => $settings['templatesRootPath'],
95+
'templatesRootPath' => $settings['templatesRootPath'] ?? null,
9596
'template' => $template,
9697
'additionalData' => $data
9798
]);

0 commit comments

Comments
 (0)