Question

I am using a library called TCPDF and having this particular issue -- I want to use writeHTMLCell function, for example. Documentation states that usage is:

writeHTMLCell ($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=false,
               $reseth=true, $align='', $autopadding=true);

In the code I have things like:

writeHTMLCell($w1, '', '', $ypos, $html2['left']);
writeHTMLCell($w2, '', $xpos, $ypos, 'illustration', 0, 1);
writeHTMLCell($w2, '', '', '', $html2['right'], 0, 1);
writeHTMLCell($width, '', '', $ypos, $html, 0, 1);
writeHTMLCell('', '', '', '', $html, 0, 1);
writeHTMLCell(0, '', '', $ypos, $html, 0, 0, false, true, '', false);
writeHTMLCell(40, 0, 51, 65, $html, 0, 1, 0, true, 'L', true);

And so on. And this is just one of the functions. There are tons more. To use these functions I have to know or remember or look up:

  • the order of the parameters
  • what the parameters are for what I need,
  • and what parameters can be skipped / defaulted

I am looking for a way to ease the task of writing/editing these function parameters. How can I do this?

Was it helpful?

Solution 2

One way is to write my own wrapper class, but that is just too much work to do for a 3rd party library, I think. It is almost like creating a 3rd party separate product, which is not something I want to do. Another way is to use a array with a parameter list, like

//me preparing an array with my own values
$param = array('width' => $width, 'height' => $height, ... 'padding' => $padding);

//and this is how I will always call this function from now on syntax-wise:
writeHTMLCell($param['width'], $param['height'], ..., $param['padding']);

This way does not hide complexity, in fact it adds some code to it, but doing so takes the mystery out of the function call, and makes the complexity immediately visible.

I was wondering if there is a way to do this another way to do this, or did I describe a really good way already?

OTHER TIPS

Most IDEs (NetBeans in the links) do this as parameter hints. You can also get code completion and syntax highlighting, as well as much more.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top