Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Classes/Application/AbstractComponentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? '<div>' : '')
. ($node->getProperty($propertyName) ?: '')
. ($value ?? '')
. ($block ? '</div>' : '')
);
}
Expand Down
6 changes: 3 additions & 3 deletions Classes/Domain/NodeMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ final class NodeMetadataFactory extends ContentElementWrappingService
protected NodeInfoHelper $nodeInfoHelper;

/**
* @return array<string,mixed>|null
* @return array<string,mixed>
*/
public function getAugmenterAttributesForContentNode(
Node $contentNode,
?RenderingEntryPoint $renderingEntryPoint = null,
?string $additionalClasses = null
): ?array {
): array {
$contentRepository = $this->contentRepositoryRegistry->get($contentNode->contentRepositoryId);
$renderingEntryPoint ??= RenderingEntryPoint::forContentRendererDelegation();

Expand Down Expand Up @@ -60,7 +60,7 @@ public function getScriptForContentNode(Node $contentNode): string
/**
* @return array<string,mixed>
*/
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 : '/<Neos.Neos:Document>/' . $documentNode->aggregateId->value;

Expand Down
3 changes: 3 additions & 0 deletions Classes/Infrastructure/ComponentSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static function serializeComponent(ComponentInterface $component): array
{
$reflectionClass = new \ReflectionClass($component);
if ($component instanceof ComponentCollection) {
/** @var \ReflectionClass<ComponentCollection> $reflectionClass */
return self::serializeComponentCollection($component, $reflectionClass);
} elseif ($component instanceof CacheSegment) {
return $component->serializeForCache();
Expand Down Expand Up @@ -70,6 +71,7 @@ public static function serializeComponent(ComponentInterface $component): array
}

/**
* @param \ReflectionClass<ComponentCollection> $reflectionClass
* @return array<string,mixed>
*/
private static function serializeComponentCollection(
Expand All @@ -90,6 +92,7 @@ private static function serializeComponentCollection(
}

/**
* @param \ReflectionClass<ComponentInterface> $reflectionClass
* @return array<string,mixed>
*/
private static function serializeCollectionType(
Expand Down
2 changes: 1 addition & 1 deletion Classes/Infrastructure/ComponentUnserializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<ComponentInterface> $className */
if (!in_array(ComponentInterface::class, class_implements($className) ?: [])) {
throw new \InvalidArgumentException(
'Can only unserialize objects of type ' . ComponentInterface::class . ', ' . $className . ' given',
Expand Down
4 changes: 4 additions & 0 deletions Classes/Infrastructure/IsCollectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
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
*/
#[Flow\Proxy(false)]
final class IsCollectionType
{
/**
* @param \ReflectionClass<ComponentInterface> $reflectionClass
*/
public static function isSatisfiedByReflectionClass(\ReflectionClass $reflectionClass): bool
{
$reflectionProperties = $reflectionClass->getProperties();
Expand Down
6 changes: 1 addition & 5 deletions Tests/Unit/Infrastructure/ComponentReconstitutionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,8 @@ final class ComponentReconstitutionTest extends TestCase

private ComponentCache $cache;

/**
* @param array<mixed> $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(
Expand Down
6 changes: 1 addition & 5 deletions Tests/Unit/Infrastructure/ComponentSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ final class ComponentSerializerTest extends TestCase
{
private ComponentSerializer $subject;

/**
* @param array<mixed> $data
*/
public function __construct(?string $name = null, array $data = [], $dataName = '')
public function setUp(): void
{
parent::__construct($name, $data, $dataName);
$this->subject = new ComponentSerializer();
}

Expand Down
6 changes: 1 addition & 5 deletions Tests/Unit/Infrastructure/ComponentUnserializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,8 @@ final class ComponentUnserializerTest extends TestCase

private ComponentCache $cache;

/**
* @param array<mixed> $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(
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ parameters:
paths:
- Classes
- Tests
checkGenericClassInNonGenericObjectType: false