Problem/Motivation

#3523789: DataTypeNamespace complains about namespace when PHPStan types are used claims to have fixed this.

I have a hunch that #3523789-3: DataTypeNamespace complains about namespace when PHPStan types are used only didn't reproduce the problem because it declared the @phpstan-type in the same file, rather than importing it from another file using @phpstan-import-type.

I just was forced to add a second

// phpcs:disable Drupal.Commenting.DataTypeNamespace.DataTypeNamespace
/**
…
*/
// phpcs:enable Drupal.Commenting.DataTypeNamespace.DataTypeNamespace

dance to Canvas. @dpi's report in #4 on that prior issue shows the same symptom: https://git.drupalcode.org/project/pinto_theme/-/blob/1.x/src/EventListe...

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

wim leers created an issue.

wim leers’s picture

Theory confirmed: removing the @phpstan-import-type and declaring locally works.

Note that this is even true for indirect imports. In my case, I'm using

@param ComponentTreeItemListArray $new_values

→ top of the same file:

@phpstan-type ComponentTreeItemListArray array<int, ComponentTreeItemArray>
→ top of the same file: <code>@phpstan-type ComponentTreeItemArray array{'uuid': string, 'component_id': string, 'parent_uuid'?: string, 'slot'?: string, inputs: OptimizedSingleComponentInputArray}

→ that one depends on an import: @phpstan-import-type OptimizedSingleComponentInputArray from \Drupal\canvas\Plugin\DataType\ComponentInputs

⇒ work-around: https://git.drupalcode.org/project/canvas/-/merge_requests/1309/diffs?co...