Skip to content

Larastan breaks @mixin property resolving on requests #2327

@tminich

Description

@tminich
  • Larastan Version: 3.6.0
  • Laravel Version: 11.45.1

Description

Adding Larastan breaks phpstan's resolving of property types included by @mixin into classes inheriting from Laravel requests. The type always resolves to mixed instead of the proper type.

Laravel code where the issue was found

namespace StanTest;

/**
 * @property bool $test
 */
#[\AllowDynamicProperties]
class Mixin
{

}
namespace StanTest;

use Illuminate\Http\Request;

/**
 * @mixin \StanTest\Mixin
 */
#[\AllowDynamicProperties]
class TestClass extends Request
{
    public function test(): bool
    {
        return $this->test;
    }
}

phpstan complains here:

 ------ -------------------------------------------------------------------------
  Line   TestClass.php
 ------ -------------------------------------------------------------------------
  15     Method StanTest\TestClass::test() should return bool but returns mixed.
         🪪  return.type
         ✏️  src/TestClass.php:15
 ------ -------------------------------------------------------------------------

If TestClass doesn't extend Request, it's fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions