Skip to content

Skip parameters with an unresolved argument or a conflicting @param doc type - #59

Merged
TomasVotruba merged 1 commit into
mainfrom
tv/skip-unresolved-and-docblock-union
Nov 15, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv/skip-unresolved-and-docblock-union

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

A single literal argument was enough to add a type, even when other call sites pass values argtyper cannot resolve. In Mautic this typed CookieHelper::setCookie($value) as string because of one $this->setCookie($name, '') call, while other callers pass $lead->getId() (an int) - a runtime TypeError.

/** @param int|string|null $value */
public function setCookie($name, $value) {}

$this->setCookie($name, '');                                    // string literal
$this->cookieHelper->setCookie('mtc_id', $lead->getId());       // unresolved

Changes:

  • aggregate - any unresolved argument now leaves the parameter untyped, it may pass any type
  • apply - an existing @param doc type must agree with the resolved type, otherwise the parameter is skipped. Unions (other than with null) and other types skip, generics/shapes, pseudo types (non-empty-string, positive-int, list, ...), literals and mixed are accepted. Applies to the default-value path too

On Mautic 8.x this drops added types from 458 to 239 - the removed ones are the unsafe ones.

Not covered: named and variadic arguments are still skipped at collect, so a call using them does not block typing.

…oc type

A single literal call site typed the parameter even when other call sites pass
values argtyper cannot resolve, e.g. setCookie($name, '') next to
setCookie('id', $lead->getId()) typed $value as string. An existing @PARAM doc
type naming a union or another type is now respected too.
@TomasVotruba
TomasVotruba merged commit 0285aa3 into main Nov 15, 2026
4 checks passed
@TomasVotruba
TomasVotruba deleted the tv/skip-unresolved-and-docblock-union branch November 15, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant