Re: Re: attempting to work out conversion/compressionAPI
| From: | Steph Fox | Date: | Thu, 10 Apr 2008 13:50:19 +0000 |
| Subject: | Re: Re: attempting to work out conversion/compressionAPI | ||
| References: | 1 2 3 4 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-5365@lists.php.net to get a copy of this message | ||
Hi Greg,
Phar Phar->convertToExecutable([archiveformat = null][, compression = null][, extension = null]) PharData Phar->convertToData([archiveformat = null][, compression = null][, extension = null])Yes, that would answer my concern about the overly long argument list. On the other hand, it's less intuitive for those unfamiliar with the properties of phars. What do 'Data' and 'Executable' imply to someone who only downloaded the extension because they were told they could use it to make tar.gz -> zip?
This removes 1 parameter, and completely separates the conversion to an executable phar or a data phar. The API is much clearer to read, and removes 1 very non-obvious parameter. Most users will use only the first 2 parameters. null = keep default format. Now we have: <?php $a = new Phar('blah.phar.tar'); $b = $a->convertToExecutable(Phar::TAR, Phar::GZ); // create executable phar.tar.gz $c = $a->convertToData(Phar::ZIP); // create data .zip $d = $a->convertToData(); // create data .tar $e = $b->convertToData(); // create data .tar.gz ?>Question for Lars: what's the difference between having a method for every type or a constant for every type? I actually don't see the benefit here.
I would also like an explicit method of unlinking the underlying file, so that one can do: <?php $a = new PharData('blar.tgz'); $b = $a->convertToExecutable(); $a->unlink(); // unlinks blar.tgz, and removes it from the manifest in-memory $a->*() // throws exception - phar is unusable $a = new PharData('blar.tgz'); // creates new tgz with no relation to blar.tgz ?> This is because simply doing an unlink() on the file will not allow one to "start over" with the last line of the above script.If it's needed, it's needed <shrug />. It's not really open to debate in that case. - Steph