ZF2-357: Confusing usage of Interfaces "Color" and "ColorInterface" in \Zend\PDF


In \Zend\Pdf there are the following two Interfaces for Color-Objects: "\Zend\Pdf\Color" and "\Zend\Pdf\Color\ColorInterface" (both fully identically having the same methods containing the same signature).

Implementing Classes such as \Zend\Pdf\Color\RGB, \Zend\Pdf\Color\GrayScale, \Zend\Pdf\Color\HtmlColor and \Zend\Pdf\Color\CMYK only implements ColorInterface.

But some Methods as Style::setFillColor() or setLineColor() are asking for an Argument of Type "\Zend\Pdf\Color" instead of "\Zend\Pdf\Color\ColorInterface". So we can not use \Zend\Pdf\Color\RGB as Argument for Style::setFillColor(). The Page-Class requires ColorInterface, but Style requires Color (which has none implementations).

Either the Implementations of ColorInterface (RGB, GrayScale and so on) should implement also Color (not recommended IMHO), or Style and Font should require the same ArgumentType for Color-Arguments (ColorInterface instead of Color), otherwise it should be scrutinized wether or not \Zend\Pdf needs two separated Interfaces for the same task...


Hi Hagen,

Thank you for your observation. However Zend\Pdf will be rewritten and this will not be applied.