Skip to content
Snippets Groups Projects

Add type declaration to untyped scalar params on interfaces

2 unresolved threads

Closes #3436327

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
123 */
124 private function refactorParamTypes($functionLike, PhpDocInfo $phpDocInfo) : void
125 {
126 foreach ($functionLike->params as $param) {
127 if ($param->type instanceof Node) {
128 continue;
129 }
130 $paramName = (string) $this->getName($param->var);
131 $paramTagValue = $phpDocInfo->getParamTagValueByName($paramName);
132 if (!$paramTagValue instanceof ParamTagValueNode) {
133 continue;
134 }
135 $paramType = $phpDocInfo->getParamType($paramName);
136 if (!$paramType->isScalar()->yes()) {
137 continue;
138 }
  • Michael Strelan added 2 commits

    added 2 commits

    Compare with previous version

  • Adam G-H added 2 commits

    added 2 commits

    Compare with previous version

  • Adam G-H added 2 commits

    added 2 commits

    Compare with previous version

  • Adam G-H added 1 commit

    added 1 commit

    Compare with previous version

  • Adam G-H added 3 commits

    added 3 commits

    • caea9587 - Fix ContentTranslationManageAccessCheckTest
    • fa574ca0 - Fix FormStateDecoratorBaseTest
    • 1d14cd1d - Fix ForumNodeBreadcrumbBuilderTest

    Compare with previous version

  • Adam G-H added 1 commit

    added 1 commit

    • cf322b48 - Fix ConfigNamesMapperTest for real

    Compare with previous version

  • 28 28 *
    29 29 * @return $this
    30 30 */
    31 public function setLabel($label);
    31 public function setLabel(string $label);
    • Comment on lines -31 to +31

      I think this needs to be allow TranslatableMarkup. For example in \Drupal\layout_builder\Plugin\Derivative\FieldBlockDeriver::getDerivativeDefinitions we get labels from \Drupal\Core\Entity\EntityTypeRepository::getEntityTypeLabels which ultimately gets labels from \Drupal\Core\Entity\EntityTypeInterface::getLabel which returns string|\Drupal\Core\StringTranslation\TranslatableMarkup. We then pass those labels to \Drupal\Core\Plugin\Context\ContextDefinition::setLabel which implements this method.

      There are probably many other instances of this that we won't know until the concrete classes declare the same parameter types.

    • Maintainer

      If we allow TranslatableMarkup why not string|Stringable in these cases?

    • I think the trick is detecting which interfaces incorrectly declare that they require a string versus those that actually require a string.

    • Please register or sign in to reply
    Please register or sign in to reply
    Loading