Hi,
Just found an issue related to traits and generics (templates):
<?php
declare(strict_types=1);
namespace Devsense\Generics\Traits;
trait MyTrait
{
public ?MyParent $test = null;
}
abstract class MyParent {}
final class MyClassA extends MyParent {}
final class MyClassB extends MyParent {}
/**
* @template T
*/
interface MyInterface
{
/**
* @var null|T
*/
public ?MyParent $test { get; }
}
/**
* @implements MyInterface<MyClassA>
*/
final class Test implements MyInterface
{
use MyTrait;
public function runA(MyClassA $v) {}
public function runB(MyClassB $v) {}
}
$test = new Test();
$t = $test->test;
$test->runA($t);
$test->runB($t);
The attribute test has not the right type.
Thank you for the fix.