Generated with the help of an LLM.

Problem/Motivation

Contrib reads our docblocks, not our code, and most arrays in the public contracts are a bare array.

InstanceInterface, DisplayBuildableInterface and PatternPresetInterface document no shape. getIslandsByTypes() has a different default in the interface and the class.

PatternPreset::getSources() names its flag $fillInternalId where the interface says $fillNodeId, so a call with a named argument fails.

Proposed resolution

Document the node shape once on InstanceInterface and reference it from every method taking or returning nodes.

Then the island build() data and options, the island configuration keys, getPathIndex(), getAllowedProfiles(), getIslandsByTypes(), PatternPresetInterface::getSources(), the DisplayBuilderEvent getters and the ConfigBuildablePluginBase default sources methods. PageDisplays is already shaped: follow it.

Remaining tasks

  1. Shapes and docblock fixes.
  2. Align the getIslandsByTypes() default, and the PatternPreset::getSources() parameter name with its interface.
  3. PHPStan green at the current level.
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mogtofu33 created an issue. See original summary.

mogtofu33’s picture

Status: Active » Needs review
Issue tags: +display_builder-1.0.0-beta, +RC blocker, +BC break

!567 is mostly docblocks, with three code changes that PHPStan forced.

Need to review two points before RC1 freezes:

  • First, the names SourceNode and PathIndex, the PHPStan type aliases on InstanceInterface that contrib will import.
  • Second, ConfigBuildablePluginBase::getSources() no longer accepts a single stored root: nothing shipped has reached that branch since presets wrap their root in a list, and a contrib config buildable now wraps its own.

The rest needs no decision: getIslandsByTypes() and PatternPreset::getSources() now match their interfaces, and ProfileForm no longer passes a label instead of islands for a type with no islands.

pdureau’s picture

Assigned: Unassigned » mogtofu33

Wonderful idea. We have too many undefined array in docblocks.

First, the names SourceNode and PathIndex, the PHPStan type aliases on InstanceInterface that contrib will import.

I didn't know about @phpstan-type until today, so I am not feeling very authoritative on the topic. But the 2 types added (SourceNode and PathIndex) look OK to me.

Second, ConfigBuildablePluginBase::getSources() no longer accepts a single stored root: nothing shipped has reached that branch since presets wrap their root in a list, and a contrib config buildable now wraps its own.

Genuinely asking. Is a docblock like list<array<string, mixed>> in loadDefaultSources() enough to enforce this restriction at runtime? Would a little line like this helping avoiding unexpected issue?

$base = $this->loadDefaultSources();
$base = \array_is_list($base) ? $base : [$base];

But I agree the logic in ConfigBuildablePluginBase::getSources() was too complicated and the change is welcomed.

There is also a pipeline fail, I don't know if it is related.

mogtofu33’s picture

Assigned: mogtofu33 » pdureau

You're right, took your line.

Pipeline was flaky.

pdureau’s picture

Assigned: pdureau » mogtofu33
Status: Needs review » Reviewed & tested by the community

  • mogtofu33 committed ec362abc on 1.0.x
    task: #3638827 Document the array shapes of the public API
    
    By:...
mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Reviewed & tested by the community » Fixed

Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.