Skip to content

Commit 714a5b5

Browse files
committed
Resolve phpstan issues
1 parent 5f85207 commit 714a5b5

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

‎Classes/Core/ViewHelpers/SchemaViewHelperResolverDelegate.php‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,13 @@
1111

1212
namespace Brotkrueml\Schema\Core\ViewHelpers;
1313

14-
use Brotkrueml\Schema\Type\ModelClassNotFoundException;
15-
use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInterface;
1614
use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperResolverDelegateInterface;
1715

1816
/**
1917
* @internal
2018
*/
2119
final readonly class SchemaViewHelperResolverDelegate implements ViewHelperResolverDelegateInterface
2220
{
23-
/**
24-
* @param string $name ViewHelper name as written in the template, for example "type.person"
25-
* @return class-string<ViewHelperInterface>
26-
* @throws ModelClassNotFoundException
27-
*/
2821
public function resolveViewHelperClassName(string $name): string
2922
{
3023
if (\str_starts_with($name, 'type.')) {
@@ -33,11 +26,14 @@ public function resolveViewHelperClassName(string $name): string
3326

3427
$explodedViewHelperName = \explode('.', $name);
3528

36-
return \sprintf(
29+
/** @var class-string $class */
30+
$class = \sprintf(
3731
'%s\%sViewHelper',
3832
$this->getNamespace(),
3933
\implode('\\', \array_map(ucfirst(...), $explodedViewHelperName)),
4034
);
35+
36+
return $class;
4137
}
4238

4339
public function getNamespace(): string

‎Classes/Core/ViewHelpers/TypeViewHelper.php‎

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

1414
use Brotkrueml\Schema\Core\Model\TypeInterface;
1515
use Brotkrueml\Schema\Type\TypeFactory;
16+
use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode;
1617
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
1718
use TYPO3Fluid\Fluid\Core\ViewHelper\ArgumentDefinition;
1819

@@ -24,7 +25,7 @@ final class TypeViewHelper extends AbstractViewHelper
2425
private TypeInterface $schemaType;
2526

2627
/**
27-
* @var array<string, list<ArgumentDefinition>>
28+
* @var array<string, array<string, ArgumentDefinition>>
2829
*/
2930
private static array $typeArgumentDefinitions = [];
3031

@@ -45,10 +46,11 @@ public function setArguments(array $arguments): void
4546
}
4647

4748
/**
48-
* @return list<ArgumentDefinition>
49+
* @return array<string, ArgumentDefinition>
4950
*/
5051
public function prepareArguments(): array
5152
{
53+
\assert($this->viewHelperNode instanceof ViewHelperNode);
5254
$name = $this->viewHelperNode->getName();
5355
if (! \str_starts_with($name, 'type.')) {
5456
// There is something wrong, this should not happen
@@ -66,7 +68,7 @@ public function prepareArguments(): array
6668
if (! isset(self::$typeArgumentDefinitions[$typeName])) {
6769
self::$typeArgumentDefinitions[$typeName] = $this->getNotableArguments();
6870
foreach ($this->schemaType->getPropertyNames() as $propertyName) {
69-
self::$typeArgumentDefinitions[$this->schemaType->getType()][$propertyName] = new ArgumentDefinition(
71+
self::$typeArgumentDefinitions[$typeName][$propertyName] = new ArgumentDefinition(
7072
$propertyName,
7173
'mixed',
7274
\sprintf('Property "%s"', $propertyName),
@@ -75,11 +77,11 @@ public function prepareArguments(): array
7577
}
7678
}
7779

78-
return self::$typeArgumentDefinitions[$this->schemaType->getType()];
80+
return self::$typeArgumentDefinitions[$typeName];
7981
}
8082

8183
/**
82-
* @return array<string, list<ArgumentDefinition>>
84+
* @return array<string, ArgumentDefinition>
8385
*/
8486
private function getNotableArguments(): array
8587
{

0 commit comments

Comments
 (0)