Skip to content

Commit

Permalink
[TASK] Make PHPStan ignore not existing classes in TYPO3 12
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbltr committed Feb 7, 2025
1 parent 45d8b61 commit be90518
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Classes/Plugins/ResultlistPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
*/
class ResultlistPlugin extends PluginBase
{
// @phpstan-ignore-next-line
private ?ViewFactoryInterface $viewFactory;

// TODO: Inject ViewFactoryInterface once TYPO3 v13 is the minimum requirement
Expand All @@ -47,6 +48,7 @@ class ResultlistPlugin extends PluginBase
public function __construct()
{
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) {
// @phpstan-ignore-next-line
$this->viewFactory = GeneralUtility::makeInstance(ViewFactoryInterface::class);
}
}
Expand Down Expand Up @@ -83,12 +85,14 @@ public function main(string $content, array $conf, ServerRequestInterface $reque

// Initialize the view
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) {
// @phpstan-ignore-next-line
$viewFactoryData = new ViewFactoryData(
templateRootPaths: $this->conf['view']['templateRootPaths'],
partialRootPaths: $this->conf['view']['partialRootPaths'],
layoutRootPaths: $this->conf['view']['layoutRootPaths'],
request: $this->request,
);
// @phpstan-ignore-next-line
$view = $this->viewFactory->create($viewFactoryData);
} else {
$view = GeneralUtility::makeInstance(StandaloneView::class);
Expand Down
4 changes: 4 additions & 0 deletions Classes/Plugins/SearchboxPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
*/
class SearchboxPlugin extends PluginBase
{
// @phpstan-ignore-next-line
private ?ViewFactoryInterface $viewFactory;

// TODO: Inject ViewFactoryInterface once TYPO3 v13 is the minimum requirement
Expand All @@ -45,6 +46,7 @@ class SearchboxPlugin extends PluginBase
public function __construct()
{
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) {
// @phpstan-ignore-next-line
$this->viewFactory = GeneralUtility::makeInstance(ViewFactoryInterface::class);
}
}
Expand Down Expand Up @@ -76,12 +78,14 @@ public function main(string $content, array $conf, ServerRequestInterface $reque

// Initialize the view
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) {
// @phpstan-ignore-next-line
$viewFactoryData = new ViewFactoryData(
templateRootPaths: $this->conf['view']['templateRootPaths'],
partialRootPaths: $this->conf['view']['partialRootPaths'],
layoutRootPaths: $this->conf['view']['layoutRootPaths'],
request: $this->request,
);
// @phpstan-ignore-next-line
$view = $this->viewFactory->create($viewFactoryData);
} else {
$view = GeneralUtility::makeInstance(StandaloneView::class);
Expand Down

0 comments on commit be90518

Please sign in to comment.