Skip to content

Commit

Permalink
🐛 fix grumphp
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanti committed Oct 2, 2024
1 parent d885953 commit 4b80639
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 12 deletions.
14 changes: 12 additions & 2 deletions Classes/DataProcessing/LazyDataProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ public function __construct()
$this->contentDataProcessor = GeneralUtility::makeInstance(ContentDataProcessor::class);
}

public function process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData)
/**
* Process content object data
*
* @param ContentObjectRenderer $cObj The data of the content element or page
* @param array<mixed> $contentObjectConfiguration The configuration of Content Object
* @param array<mixed> $processorConfiguration The configuration of this processor
* @param array<mixed> $processedData Key/value store of processed data (e.g. to be passed to a Fluid View)
* @return array<mixed> the processed data as key/value store
*/
public function process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData): array
{
$realProcessedData = 'LazyDataProcessor $realProcessedData';
$variables = $processorConfiguration['variables']; // given variable names to proxy
Expand All @@ -41,11 +50,12 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
]];
$realProcessedData = $this->contentDataProcessor->process($cObj, $configuration, $processedData);
}

return $realProcessedData[$variableName] ?? null;
});
}
}

return $processedData;
}
}

18 changes: 8 additions & 10 deletions Classes/Proxy/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@

namespace AUS\SsiInclude\Proxy;

/**
* @template TKey
* @template-covariant TValue
* @template-implements \Traversable<TKey, TValue>
*/
final class Proxy implements \Iterator, \Countable
use Iterator;
use Countable;
use Stringable;
use Closure;

final class Proxy implements Iterator, Countable, Stringable
{
private ?\Closure $callback = null;
/** @var mixed */
private $value;

public function __construct(\Closure $callback)
public function __construct(private ?Closure $callback)
{
$this->callback = $callback;
}

private function processRealInstance(): void
Expand Down Expand Up @@ -100,7 +98,7 @@ public function rewind(): void
reset($this->value);
}

public function count()
public function count(): int
{
$this->processRealInstance();
return is_countable($this->value) ? count($this->value) : (isset($this->value) ? 1 : 0);
Expand Down
3 changes: 3 additions & 0 deletions Classes/ViewHelpers/RenderIncludeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
class RenderIncludeViewHelper extends RenderViewHelper
{
public const SSI_INCLUDE_DIR = '/typo3temp/tx_ssiinclude/';

public const METHOD_SSI = 'ssi';

public const METHOD_ESI = 'esi';

protected static function getContext(): Context
Expand Down Expand Up @@ -73,6 +75,7 @@ public static function renderStatic(array $arguments, Closure $renderChildrenClo
if ($method === self::METHOD_ESI) {
return '<esi:include src="' . $reqUrl . '" />';
}

return '<!--# include wait="yes" virtual="' . $reqUrl . '" -->';
}

Expand Down
50 changes: 50 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1 +1,51 @@
parameters:
ignoreErrors:
-
message: "#^Class AUS\\\\SsiInclude\\\\Proxy\\\\Proxy implements generic interface Iterator but does not specify its types\\: TKey, TValue$#"
count: 1
path: Classes/Proxy/Proxy.php

-
message: "#^Method AUS\\\\SsiInclude\\\\Proxy\\\\Proxy\\:\\:__call\\(\\) has parameter \\$arguments with no type specified\\.$#"
count: 1
path: Classes/Proxy/Proxy.php

-
message: "#^Method AUS\\\\SsiInclude\\\\Proxy\\\\Proxy\\:\\:__call\\(\\) has parameter \\$name with no type specified\\.$#"
count: 1
path: Classes/Proxy/Proxy.php

-
message: "#^Method AUS\\\\SsiInclude\\\\Proxy\\\\Proxy\\:\\:__get\\(\\) has parameter \\$name with no type specified\\.$#"
count: 1
path: Classes/Proxy/Proxy.php

-
message: "#^Method AUS\\\\SsiInclude\\\\Proxy\\\\Proxy\\:\\:__invoke\\(\\) has parameter \\$arguments with no type specified\\.$#"
count: 1
path: Classes/Proxy/Proxy.php

-
message: "#^Method AUS\\\\SsiInclude\\\\Proxy\\\\Proxy\\:\\:__isset\\(\\) has parameter \\$name with no type specified\\.$#"
count: 1
path: Classes/Proxy/Proxy.php

-
message: "#^Method AUS\\\\SsiInclude\\\\Proxy\\\\Proxy\\:\\:__set\\(\\) has parameter \\$name with no type specified\\.$#"
count: 1
path: Classes/Proxy/Proxy.php

-
message: "#^Method AUS\\\\SsiInclude\\\\Proxy\\\\Proxy\\:\\:__set\\(\\) has parameter \\$value with no type specified\\.$#"
count: 1
path: Classes/Proxy/Proxy.php

-
message: "#^Method AUS\\\\SsiInclude\\\\Proxy\\\\Proxy\\:\\:__unset\\(\\) has parameter \\$name with no type specified\\.$#"
count: 1
path: Classes/Proxy/Proxy.php

-
message: "#^Parameter \\#1 \\$callback of function call_user_func expects callable\\(\\)\\: mixed, array\\{mixed, mixed\\} given\\.$#"
count: 1
path: Classes/Proxy/Proxy.php

0 comments on commit 4b80639

Please sign in to comment.