parser icon indicating copy to clipboard operation
parser copied to clipboard

Add phpunit helper

Open roxblnfk opened this issue 11 months ago • 0 comments

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

roxblnfk avatar Feb 07 '25 12:02 roxblnfk