ILIAS icon indicating copy to clipboard operation
ILIAS copied to clipboard

Data: Add @template type annotations for `ILIAS\Data\Result`

Open lscharmer opened this issue 5 months ago • 5 comments

This PR adds type annotations for the ILIAS\Data\Result inteface as well as it's implementors ILIAS\Data\Result\Ok and ILIAS\Data\Result\Error to support a generic type. These type annotations are understood by phpstan (https://phpstan.org/blog/generics-in-php-using-phpdocs) and phpstorm.

With this change the following can be checked via static analysis:

/**
 * @param Result<Baz> $bar
 */
function foo(Result $bar): void
{
    // ...
}

lscharmer avatar Sep 12 '24 11:09 lscharmer