A PHPStan extension for a magic method the analyser cannot see

Frameworks built on __call and facades produce hundreds of false positives, and the answer is not to lower the level but to teach the analyser what those calls mean.

final class MacroMethodsExtension implements MethodsClassReflectionExtension
{
    public function hasMethod(ClassReflection $class, string $name): bool
    {
        return $class->getName() === Collection::class
            && Collection::hasMacro($name);
    }

    // getMethod() returns a reflection describing the macro's signature
}

// phpstan.neon
// services:
//   - class: AppPHPStanMacroMethodsExtension
//     tags: [phpstan.broker.methodsClassReflectionExtension]

For Laravel and Symfony the community extensions already do this and installing one is the right first move — writing your own is for a macro or a magic method that is specific to your codebase. The alternative of adding hundreds of entries to the baseline works and hides real errors of the same shape. An extension is thirty lines and turns a permanent blind spot into a checked one.