Problem/Motivation
I did some work with components lately, and noticed one thing that changed the show for me:
With PHP8.1's constructor promotion and readonle properties we get super cheap typesafe immutable objects. Eg like that:
final class FullResult {
public function __construct(
public readonly ListInfo $listInfo,
public readonly MessageInfo $messageInfo,
public readonly ResultVerdict $verdict,
public readonly ResultSummary $summary,
public readonly ResultDetails $details,
) {}
That's it! I passed them to twig, and even with Drupal's restricitons on methods, it was fun to work with that (fyi: In PHPStorm, symfony plugin helps with IDE integration in twig.) I neithe needed nor wanted to convert my typesafe immutable objects to an array.
Guessing that that will be interesting for others too, i wonder if we can improve object support for parameters.
Proposed resolution
Allow class or interface declaration for parameters as alternative to json schema.