It would be great if you created a helper package for PHPUnit that can assert the type of a given value.
For example:
final class Branch
{
/**
* @param T $item
* @param list<Branch<T>> $children
* @param Branch<T>|null $parent
*/
public function __construct(
public object $item,
public array $children = [],
public ?Branch $parent = null,
) {}
}
self::assertType('Branch<Edge>', $branch);
This function will check that inside the Branch $branch, in a property of type T, there is an exactly Edge. The same about other fields
It would be great if you created a helper package for PHPUnit that can assert the type of a given value.
For example:
This function will check that inside the
Branch $branch, in a property of typeT, there is an exactlyEdge. The same about other fields