diff --git a/Classes/Application/AbstractComponentFactory.php b/Classes/Application/AbstractComponentFactory.php index d920ed2..0d59dc1 100644 --- a/Classes/Application/AbstractComponentFactory.php +++ b/Classes/Application/AbstractComponentFactory.php @@ -35,11 +35,15 @@ abstract class AbstractComponentFactory final protected function getEditableProperty(Node $node, string $propertyName, bool $block = false): string { + $value = $node->getProperty($propertyName); + if ($value !== null && !is_string($value)) { + throw new \InvalidArgumentException(sprintf('Cannot make non-string node property "%s" of type "%s" editable.', $propertyName, get_debug_type($value))); + } return $this->contentElementEditableService->wrapContentProperty( $node, $propertyName, ($block ? '
' : '') - . ($node->getProperty($propertyName) ?: '') + . ($value ?? '') . ($block ? '
' : '') ); } diff --git a/Classes/Domain/NodeMetadataFactory.php b/Classes/Domain/NodeMetadataFactory.php index 53fab9b..471d839 100644 --- a/Classes/Domain/NodeMetadataFactory.php +++ b/Classes/Domain/NodeMetadataFactory.php @@ -21,13 +21,13 @@ final class NodeMetadataFactory extends ContentElementWrappingService protected NodeInfoHelper $nodeInfoHelper; /** - * @return array|null + * @return array */ public function getAugmenterAttributesForContentNode( Node $contentNode, ?RenderingEntryPoint $renderingEntryPoint = null, ?string $additionalClasses = null - ): ?array { + ): array { $contentRepository = $this->contentRepositoryRegistry->get($contentNode->contentRepositoryId); $renderingEntryPoint ??= RenderingEntryPoint::forContentRendererDelegation(); @@ -60,7 +60,7 @@ public function getScriptForContentNode(Node $contentNode): string /** * @return array */ - public function forDocumentNode(Node $documentNode, ?string $locator = null, ?Node $siteNode = null): ?array + public function forDocumentNode(Node $documentNode, ?string $locator = null, ?Node $siteNode = null): array { $locator = is_string($locator) ? $locator : '//' . $documentNode->aggregateId->value; diff --git a/Classes/Infrastructure/ComponentSerializer.php b/Classes/Infrastructure/ComponentSerializer.php index fabd138..4458f23 100755 --- a/Classes/Infrastructure/ComponentSerializer.php +++ b/Classes/Infrastructure/ComponentSerializer.php @@ -28,6 +28,7 @@ public static function serializeComponent(ComponentInterface $component): array { $reflectionClass = new \ReflectionClass($component); if ($component instanceof ComponentCollection) { + /** @var \ReflectionClass $reflectionClass */ return self::serializeComponentCollection($component, $reflectionClass); } elseif ($component instanceof CacheSegment) { return $component->serializeForCache(); @@ -70,6 +71,7 @@ public static function serializeComponent(ComponentInterface $component): array } /** + * @param \ReflectionClass $reflectionClass * @return array */ private static function serializeComponentCollection( @@ -90,6 +92,7 @@ private static function serializeComponentCollection( } /** + * @param \ReflectionClass $reflectionClass * @return array */ private static function serializeCollectionType( diff --git a/Classes/Infrastructure/ComponentUnserializer.php b/Classes/Infrastructure/ComponentUnserializer.php index b4b6dd0..5e5c550 100755 --- a/Classes/Infrastructure/ComponentUnserializer.php +++ b/Classes/Infrastructure/ComponentUnserializer.php @@ -47,7 +47,7 @@ public function unserializeComponent( if (!is_string($className)) { throw new \InvalidArgumentException('Class identifiers must be strings', 1659564301); } - /** @var class-string $className */ + /** @var class-string $className */ if (!in_array(ComponentInterface::class, class_implements($className) ?: [])) { throw new \InvalidArgumentException( 'Can only unserialize objects of type ' . ComponentInterface::class . ', ' . $className . ' given', diff --git a/Classes/Infrastructure/IsCollectionType.php b/Classes/Infrastructure/IsCollectionType.php index 26041b2..8d3c3bb 100644 --- a/Classes/Infrastructure/IsCollectionType.php +++ b/Classes/Infrastructure/IsCollectionType.php @@ -9,6 +9,7 @@ namespace Nezaniel\ComponentView\Infrastructure; use Neos\Flow\Annotations as Flow; +use Nezaniel\ComponentView\Domain\ComponentInterface; /** * The specification to determine whether a component class is a collection type @@ -16,6 +17,9 @@ #[Flow\Proxy(false)] final class IsCollectionType { + /** + * @param \ReflectionClass $reflectionClass + */ public static function isSatisfiedByReflectionClass(\ReflectionClass $reflectionClass): bool { $reflectionProperties = $reflectionClass->getProperties(); diff --git a/Tests/Unit/Infrastructure/ComponentReconstitutionTest.php b/Tests/Unit/Infrastructure/ComponentReconstitutionTest.php index ccf1212..d0c7131 100644 --- a/Tests/Unit/Infrastructure/ComponentReconstitutionTest.php +++ b/Tests/Unit/Infrastructure/ComponentReconstitutionTest.php @@ -59,12 +59,8 @@ final class ComponentReconstitutionTest extends TestCase private ComponentCache $cache; - /** - * @param array $data - */ - public function __construct(?string $name = null, array $data = [], $dataName = '') + public function setUp(): void { - parent::__construct($name, $data, $dataName); $this->unserializer = new ComponentUnserializer(); $this->subgraph = new TestingSubgraph(); $this->dummyNode = Node::create( diff --git a/Tests/Unit/Infrastructure/ComponentSerializerTest.php b/Tests/Unit/Infrastructure/ComponentSerializerTest.php index fa669ab..e0e01a0 100644 --- a/Tests/Unit/Infrastructure/ComponentSerializerTest.php +++ b/Tests/Unit/Infrastructure/ComponentSerializerTest.php @@ -32,12 +32,8 @@ final class ComponentSerializerTest extends TestCase { private ComponentSerializer $subject; - /** - * @param array $data - */ - public function __construct(?string $name = null, array $data = [], $dataName = '') + public function setUp(): void { - parent::__construct($name, $data, $dataName); $this->subject = new ComponentSerializer(); } diff --git a/Tests/Unit/Infrastructure/ComponentUnserializerTest.php b/Tests/Unit/Infrastructure/ComponentUnserializerTest.php index 0dd0263..042cdde 100644 --- a/Tests/Unit/Infrastructure/ComponentUnserializerTest.php +++ b/Tests/Unit/Infrastructure/ComponentUnserializerTest.php @@ -58,12 +58,8 @@ final class ComponentUnserializerTest extends TestCase private ComponentCache $cache; - /** - * @param array $data - */ - public function __construct(?string $name = null, array $data = [], $dataName = '') + public function setUp(): void { - parent::__construct($name, $data, $dataName); $this->subject = new ComponentUnserializer(); $this->subgraph = new TestingSubgraph(); $this->dummyNode = Node::create( diff --git a/phpstan.neon b/phpstan.neon index 1ed3407..dbfeae0 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,4 +3,3 @@ parameters: paths: - Classes - Tests - checkGenericClassInNonGenericObjectType: false