Skip to content

Skip parameters passed into a type check function like is_array() in the body - #57

Merged
TomasVotruba merged 1 commit into
mainfrom
skip-type-checked-params
Nov 15, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
skip-type-checked-params

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

A parameter checked with is_array($param), is_string($param), gettype($param) etc. in the method body accepts more than one type, even when every resolved call site passes the same one. Call sites with the other type are often unresolved (a container-fetched local, a mock), so they never reach the aggregate.

Reproducer from Mautic - sendSms() got Lead $sendTo, while tests pass an array:

public function sendSms(Sms $sms, $sendTo, ...)
{
    $sendTo = is_array($sendTo) ? $sendTo : [$sendTo];

On Mautic with --objects, this drops 6 wrong types (SmsModel::sendSms(), CompanyModel::addLeadToCompany()/removeLeadFromCompany(), ListModel::addLead()/removeLead(), FocusModel::addStat()), and no other change.

@TomasVotruba
TomasVotruba merged commit 9219ade into main Nov 15, 2026
4 checks passed
@TomasVotruba
TomasVotruba deleted the skip-type-checked-params branch November 15, 2026 19:32
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