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
- Shapes and docblock fixes.
- Align the
getIslandsByTypes()default, and thePatternPreset::getSources()parameter name with its interface. - PHPStan green at the current level.
Issue fork display_builder-3638827
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
Comment #3
mogtofu33 commented!567 is mostly docblocks, with three code changes that PHPStan forced.
Need to review two points before RC1 freezes:
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()andPatternPreset::getSources()now match their interfaces, andProfileFormno longer passes a label instead of islands for a type with no islands.Comment #4
pdureau commentedWonderful idea. We have too many undefined
arrayin docblocks.I didn't know about
@phpstan-typeuntil today, so I am not feeling very authoritative on the topic. But the 2 types added (SourceNodeandPathIndex) look OK to me.Genuinely asking. Is a docblock like
list<array<string, mixed>>inloadDefaultSources()enough to enforce this restriction at runtime? Would a little line like this helping avoiding unexpected issue?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.
Comment #5
mogtofu33 commentedYou're right, took your line.
Pipeline was flaky.
Comment #6
pdureau commentedComment #8
mogtofu33 commentedThanks!