composite annotated incorrectly
axkirillov opened this issue · 1 comments
axkirillov commented
Is the composite method annotated incorrectly?
/**
* Composite $other on top of $this with $mode.
*
* @param mixed $other The overlay.
* @param BlendMode|array $mode The mode to composite with.
* @param array $options An array of options to pass to the operation.
*
* @throws Exception
*
* @return Image A new image.
*/
public function composite($other, $mode, array $options = []): ImageThe second param is annotated as BlendMode|array, but BlendMode is not a true enum, just an empty class with a bunch of constants. I assume the intention here is just to use the constants but then the type is string and static analysers (phpstan) will complain about that.
jcupitt commented
Hi @axkirillov,
You're right, this could probably be improved.
php-vips lets you either use numbers for enum values (so 2 is VIPS_BLEND_MODE_OVER, for example), or strings (they get looked up in the enum introspection and turned to numbers before being passed to libvips).
BlendMode is supposed to help catch typos. I think php only added true enums in 8.1, so we can't use them yet.