@@ -70,7 +70,7 @@ public function getLine(float $posx1, float $posy1, float $posx2, float $posy2,
7070 * @param float $posy2 Ordinate of control point 2.
7171 * @param float $posx3 Abscissa of end point.
7272 * @param float $posy3 Ordinate of end point.
73- * @param string $mode Mode of rendering. @see getPathPaintOp()
73+ * @param string|PathPaintOp $mode Mode of rendering. @see getPathPaintOp()
7474 * @param StyleDataOpt $style Style.
7575 *
7676 * @return string PDF command
@@ -86,7 +86,7 @@ public function getCurve(
8686 float $ posy2 ,
8787 float $ posx3 ,
8888 float $ posy3 ,
89- string $ mode = 'S ' ,
89+ string | PathPaintOp $ mode = 'S ' ,
9090 array $ style = [],
9191 ): string {
9292 return (
@@ -104,7 +104,7 @@ public function getCurve(
104104 * @param float $posx0 Abscissa of start point.
105105 * @param float $posy0 Ordinate of start point.
106106 * @param array<array<float>> $segments An array of bezier descriptions. Format: array(x1, y1, x2, y2, x3, y3).
107- * @param string $mode Mode of rendering. @see getPathPaintOp()
107+ * @param string|PathPaintOp $mode Mode of rendering. @see getPathPaintOp()
108108 * @param StyleDataOpt $style Style.
109109 *
110110 * @return string PDF command
@@ -113,7 +113,7 @@ public function getPolycurve(
113113 float $ posx0 ,
114114 float $ posy0 ,
115115 array $ segments ,
116- string $ mode = 'S ' ,
116+ string | PathPaintOp $ mode = 'S ' ,
117117 array $ style = [],
118118 ): string {
119119 $ out = $ this ->getStyleCmd ($ style ) . $ this ->getRawPoint ($ posx0 , $ posy0 );
@@ -145,7 +145,7 @@ public function getPolycurve(
145145 * @param float $angle Angle oriented (anti-clockwise). Default value: 0.
146146 * @param float $angs Angle in degrees at which starting drawing.
147147 * @param float $angf Angle in degrees at which stop drawing.
148- * @param string $mode Mode of rendering. @see getPathPaintOp()
148+ * @param string|PathPaintOp $mode Mode of rendering. @see getPathPaintOp()
149149 * @param StyleDataOpt $style Style.
150150 * @param int $ncv Number of curves used to draw a 90 degrees portion of ellipse.
151151 *
@@ -161,7 +161,7 @@ public function getEllipse(
161161 float $ angle = 0 ,
162162 float $ angs = 0 ,
163163 float $ angf = 360 ,
164- string $ mode = 'S ' ,
164+ string | PathPaintOp $ mode = 'S ' ,
165165 array $ style = [],
166166 int $ ncv = 2 ,
167167 ): string {
@@ -198,7 +198,7 @@ public function getEllipse(
198198 * @param float $rad Radius.
199199 * @param float $angs Angle in degrees at which starting drawing.
200200 * @param float $angf Angle in degrees at which stop drawing.
201- * @param string $mode Mode of rendering. @see getPathPaintOp()
201+ * @param string|PathPaintOp $mode Mode of rendering. @see getPathPaintOp()
202202 * @param StyleDataOpt $style Style.
203203 * @param int $ncv Number of curves used to draw a 90 degrees portion of ellipse.
204204 *
@@ -210,7 +210,7 @@ public function getCircle(
210210 float $ rad ,
211211 float $ angs = 0 ,
212212 float $ angf = 360 ,
213- string $ mode = 'S ' ,
213+ string | PathPaintOp $ mode = 'S ' ,
214214 array $ style = [],
215215 int $ ncv = 2 ,
216216 ): string {
@@ -225,7 +225,7 @@ public function getCircle(
225225 * @param float $rad Radius.
226226 * @param float $angs Angle in degrees at which starting drawing.
227227 * @param float $angf Angle in degrees at which stop drawing.
228- * @param string $mode Mode of rendering. @see getPathPaintOp()
228+ * @param string|PathPaintOp $mode Mode of rendering. @see getPathPaintOp()
229229 * @param StyleDataOpt $style Style.
230230 * @param int $ncv Number of curves used to draw a 90 degrees portion of ellipse.
231231 *
@@ -237,7 +237,7 @@ public function getPieSector(
237237 float $ rad ,
238238 float $ angs = 0 ,
239239 float $ angf = 360 ,
240- string $ mode = 'FD ' ,
240+ string | PathPaintOp $ mode = 'FD ' ,
241241 array $ style = [],
242242 int $ ncv = 2 ,
243243 ): string {
@@ -252,12 +252,12 @@ public function getPieSector(
252252 * Draws a basic polygon.
253253 *
254254 * @param array<float> $points Points - array containing 4 points for each segment: (x0, y0, x1, y1, x2, y2, ...)
255- * @param string $mode Mode of rendering. @see getPathPaintOp()
255+ * @param string|PathPaintOp $mode Mode of rendering. @see getPathPaintOp()
256256 * @param StyleDataOpt $style Style.
257257 *
258258 * @return string PDF command
259259 */
260- public function getBasicPolygon (array $ points , string $ mode = 'S ' , array $ style = []): string
260+ public function getBasicPolygon (array $ points , string | PathPaintOp $ mode = 'S ' , array $ style = []): string
261261 {
262262 $ nco = \count ($ points ); // number of coordinates
263263 if ($ nco < 4 || ($ points [0 ] ?? null ) === null || ($ points [1 ] ?? null ) === null ) {
@@ -301,7 +301,7 @@ protected function getDefaultSegStyle(array $styles = []): string
301301 * Draws a polygon with a different style for each segment.
302302 *
303303 * @param array<float> $points Points - array with values (x0, y0, x1, y1,..., x(n-1), y(n-1))
304- * @param string $mode Mode of rendering. @see getPathPaintOp()
304+ * @param string|PathPaintOp $mode Mode of rendering. @see getPathPaintOp()
305305 * @param array<StyleDataOpt> $styles Array of styles -
306306 * one style entry for each polygon segment and/or one global "all" entry.
307307 *
@@ -310,8 +310,12 @@ protected function getDefaultSegStyle(array $styles = []): string
310310 * @SuppressWarnings("PHPMD.CyclomaticComplexity")
311311 * @SuppressWarnings("PHPMD.NPathComplexity")
312312 */
313- public function getPolygon (array $ points , string $ mode = 'S ' , array $ styles = []): string
313+ public function getPolygon (array $ points , string | PathPaintOp $ mode = 'S ' , array $ styles = []): string
314314 {
315+ if ($ mode instanceof PathPaintOp) {
316+ $ mode = $ mode ->value ;
317+ }
318+
315319 $ nco = \count ($ points ); // number of points
316320 if ($ nco < 6 || ($ points [0 ] ?? null ) === null || ($ points [1 ] ?? null ) === null ) {
317321 return '' ; // we need at least 3 points
@@ -406,10 +410,10 @@ public function getPolygon(array $points, string $mode = 'S', array $styles = []
406410 * @param float $radius Radius of inscribed circle.
407411 * @param int $sides Number of sides.
408412 * @param float $angle Angle of the orientation (anti-clockwise).
409- * @param string $mode Mode of rendering. @see getPathPaintOp()
413+ * @param string|PathPaintOp $mode Mode of rendering. @see getPathPaintOp()
410414 * @param array<StyleDataOpt> $styles Array of styles -
411415 * one style entry for each polygon segment and/or one global "all" entry.
412- * @param string $cirmode Mode of rendering of the inscribed circle (if any). @see getPathPaintOp()
416+ * @param string|PathPaintOp $cirmode Mode of rendering of the inscribed circle (if any). @see getPathPaintOp()
413417 * @param StyleDataOpt $cirstyle Style of inscribed circle.
414418 *
415419 * @return string PDF command
@@ -420,9 +424,9 @@ public function getRegularPolygon(
420424 float $ radius ,
421425 int $ sides ,
422426 float $ angle = 0 ,
423- string $ mode = 'S ' ,
427+ string | PathPaintOp $ mode = 'S ' ,
424428 array $ styles = [],
425- string $ cirmode = '' ,
429+ string | PathPaintOp $ cirmode = '' ,
426430 array $ cirstyle = [],
427431 ): string {
428432 if ($ sides < 3 ) { // triangle is the minimum polygon
@@ -453,10 +457,10 @@ public function getRegularPolygon(
453457 * @param int $nvert Number of vertices.
454458 * @param int $ngaps Number of gaps (if ($ngaps % $nvert = 1) then is a regular polygon).
455459 * @param float $angle Angle oriented (anti-clockwise).
456- * @param string $mode Mode of rendering. @see getPathPaintOp()
460+ * @param string|PathPaintOp $mode Mode of rendering. @see getPathPaintOp()
457461 * @param array<StyleDataOpt> $styles Array of styles -
458462 * one style entry for each polygon segment and/or one global "all" entry.
459- * @param string $cirmode Mode of rendering of the inscribed circle (if any). @see getPathPaintOp()
463+ * @param string|PathPaintOp $cirmode Mode of rendering of the inscribed circle (if any). @see getPathPaintOp()
460464 * @param StyleDataOpt $cirstyle Style of inscribed circle.
461465 *
462466 * @return string PDF command
@@ -470,9 +474,9 @@ public function getStarPolygon(
470474 int $ nvert ,
471475 int $ ngaps ,
472476 float $ angle = 0 ,
473- string $ mode = 'S ' ,
477+ string | PathPaintOp $ mode = 'S ' ,
474478 array $ styles = [],
475- string $ cirmode = '' ,
479+ string | PathPaintOp $ cirmode = '' ,
476480 array $ cirstyle = [],
477481 ): string {
478482 if ($ nvert < 2 ) {
@@ -509,7 +513,7 @@ public function getStarPolygon(
509513 * @param float $posy Ordinate of upper-left corner.
510514 * @param float $width Width.
511515 * @param float $height Height.
512- * @param string $mode Mode of rendering. @see getPathPaintOp()
516+ * @param string|PathPaintOp $mode Mode of rendering. @see getPathPaintOp()
513517 * @param array<StyleDataOpt> $styles Array of styles -
514518 * one style entry for each side (T,R,B,L) and/or one global "all" entry.
515519 *
@@ -520,7 +524,7 @@ public function getRect(
520524 float $ posy ,
521525 float $ width ,
522526 float $ height ,
523- string $ mode = 'S ' ,
527+ string | PathPaintOp $ mode = 'S ' ,
524528 array $ styles = [],
525529 ): string {
526530 $ points = [
@@ -550,7 +554,7 @@ public function getRect(
550554 * @param string $corner Round corners to draw: 0 (square i-corner) or 1 (rounded i-corner) in i-position.
551555 * Positions are int the following order: top right, bottom right, bottom left and
552556 * top left.
553- * @param string $mode Mode of rendering. @see getPathPaintOp()
557+ * @param string|PathPaintOp $mode Mode of rendering. @see getPathPaintOp()
554558 * @param StyleDataOpt $style Style.
555559 *
556560 * @return string PDF command
@@ -566,7 +570,7 @@ public function getRoundedRect(
566570 float $ hrad ,
567571 float $ vrad ,
568572 string $ corner = '1111 ' ,
569- string $ mode = 'S ' ,
573+ string | PathPaintOp $ mode = 'S ' ,
570574 array $ style = [],
571575 ): string {
572576 if ($ corner === '0000 ' || $ hrad === 0.0 && $ vrad === 0.0 ) {
0 commit comments