← All results

@mixin

Group: Advanced PHPDoc types · Category: ecosystem · File: phpdoc_advanced_mixin.php

The tag tells analyzers that unknown method/property access is delegated to another type. Honouring it means doA() on B is treated as A::doA(). References: - PHPStan phpdocs-basics: Mixins - Psalm supported_annotations.md: @mixins

Analyzer results

AnalyzerVersionResultDiagnostics
phan 6.0.7Phan 6.0.7 php-ast version 1.1.3 PHP version used to run Phan: 8.5.9 Recognized (no probes)

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
phpstan 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 Enforced reported Lv.2+
phpdoc_advanced_mixin.php:61: Call to an undefined method Conformance\Tests\PhpdocAdvancedMixin\Facade::missing(). [identifier=method.notFound] [reported-from-level=2]
phpdoc_advanced_mixin.php:61: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedMixin\takesInt expects int, mixed given. [identifier=argument.type] [reported-from-level=10]
With strict-rules
phpdoc_advanced_mixin.php:61: Call to an undefined method Conformance\Tests\PhpdocAdvancedMixin\Facade::missing(). [identifier=method.notFound]
phpdoc_advanced_mixin.php:61: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedMixin\takesInt expects int, mixed given. [identifier=argument.type]
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported
psalm 6.16.1Psalm 6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac
next: 7.0.0-beta19
Enforced
phpdoc_advanced_mixin.php:61: Argument 1 of Conformance\Tests\PhpdocAdvancedMixin\takesInt cannot be mixed, expecting int [MixedArgument]
phpdoc_advanced_mixin.php:61: Magic method Conformance\Tests\PhpdocAdvancedMixin\Facade::missing does not exist [UndefinedMagicMethod]
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported
mago 1.46.0mago 1.46.0 Enforced
phpdoc_advanced_mixin.php:61: Ambiguous method call to `missing` on class `Conformance\Tests\PhpdocAdvancedMixin\Facade`. [non-documented-method]
phpdoc_advanced_mixin.php:61: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedMixin\takesInt`: expected `int`, but found `mixed`. [mixed-argument]
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported
mir 0.70.1mir 0.70.1 Recognized (no probes)

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
phpantom 0.9.0phpantom_lsp 0.9.0 Recognized (no probes)

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
intelephense 1.18.5intelephense 1.18.5 Not enforced
phpdoc_advanced_mixin.php:56: Expected type 'int'. Found 'mixed'. [P1006]
phpdoc_advanced_mixin.php:61: Expected type 'int'. Found 'mixed'. [P1006]
  • Recognition: spelling resolved
  • Enforcement: 0/1 of the expected violations reported
phpy 0.2.0phpy 0.2.0 Recognized (no probes)
phpdoc_advanced_mixin.php:61: Method Facade::missing() is not defined. The call is passed to the magic Facade::__call() method.
  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
qodana 262.8665.325Qodana 262.8665.325 Recognized (no probes)

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
noverify 0.5.5NoVerify, version 0.5.5: built on: 2025.04.22 14:36:46 OS: r-kuchinskas arm64 Commit: 4774b82f8adc53fbef38f95e97af4b953b4d1529 Recognized (no probes)
phpdoc_advanced_mixin.php:34: param $arguments miss matched with phpdoc type <<list<mixed>>> [funcParamTypeMissMatch]
  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
steins 0.1.5steins 0.1.5 (2026-08-12 revision 39b4cc1) Recognized (no probes)

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: not measured — this test carries no rejection probes
phpstan-strict 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 Enforced
phpdoc_advanced_mixin.php:61: Call to an undefined method Conformance\Tests\PhpdocAdvancedMixin\Facade::missing(). [identifier=method.notFound]
phpdoc_advanced_mixin.php:61: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedMixin\takesInt expects int, mixed given. [identifier=argument.type]
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported
psalm-next 7.0.0-beta19Psalm 7.0.0-beta19@7e751c06a756fa64dc4c759c09fe4a173afcb433 Enforced
phpdoc_advanced_mixin.php:61: Argument 1 of Conformance\Tests\PhpdocAdvancedMixin\takesInt cannot be mixed, expecting int [MixedArgument]
phpdoc_advanced_mixin.php:61: Magic method Conformance\Tests\PhpdocAdvancedMixin\Facade::missing does not exist [UndefinedMagicMethod]
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported

Source

<?php

declare(strict_types=1);

namespace Conformance\Tests\PhpdocAdvancedMixin;

/**
 * Cross-tool handling of `@mixin`.
 *
 * The tag tells analyzers that unknown method/property access is delegated to
 * another type. Honouring it means `doA()` on `B` is treated as `A::doA()`.
 *
 * References:
 * - PHPStan phpdocs-basics: Mixins
 * - Psalm supported_annotations.md: @mixins
 */

final class Delegated
{
    public function answer(): int
    {
        return 42;
    }
}

/**
 * @mixin Delegated
 */
final class Facade // T: @mixin
{
    /**
     * @param list<mixed> $arguments
     */
    public function __call(string $name, array $arguments): mixed // E?[noise]: some tools flag the docblock/native array mismatch
    {
        if ($name === 'answer') {
            return (new Delegated())->answer();
        }

        throw new \BadMethodCallException($name);
    }
}

function takesInt(int $value): void
{
}

// Mixin makes answer() visible and typed as int. Honouring the tag means this
// is silent; a tool that ignores @mixin routes answer() through __call and sees
// `mixed`, so a diagnostic here means the tag was not applied. Silence is the
// discriminator, so this is a quiet probe — but only for the analyzers that
// both flag `mixed` arguments and would therefore stay silent *because* the
// mixin resolved answer() to int. Tools that never flag `mixed` (phan, phpy,
// …) would be silent regardless, so scoring them here would hand out a free
// pass; they are left as recognition-only instead.
takesInt((new Facade())->answer()); // Q?<phpstan> // Q?<phpstan-strict> // Q?<psalm> // Q?<pzoom> // Q?<mago> // Q?<intelephense> // E?[noise]

// A method neither on Facade nor on the mixin target stays undefined. It is
// caught by __call handling whether or not @mixin is honoured, so it is noise
// for the tag rather than an enforcement probe.
takesInt((new Facade())->missing()); // E?[noise]: missing is not provided by @mixin Delegated