[PEPr] Comment on Encryption::Crypt_DiffieHellman
| From: | Philippe Jausions | Date: | Fri, 22 Jun 2007 15:14:48 +0000 |
| Subject: | [PEPr] Comment on Encryption::Crypt_DiffieHellman | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-47103@lists.php.net to get a copy of this message | ||
Philippe Jausions (http://pear.php.net/user/jausions) has commented on the proposal for
Encryption::Crypt_DiffieHellman.
Comment:
Couple of nitpicking and PEAR CS comments:
- For speed use ctype_digit() instead of preg_match(/^\d$/...)
- Constructor don't actually "return" so remove the "@return void" in
docblock
- Use PEAR::loadExtension() instead of loaded_extension(), dl() and so
on...
- For Crypt_DiffieHellman_Math_BigInteger add an actual factory() method
to allow overriding the automatic detection of which backend to use
(sometimes needed if an extension gets buggy.)
- the "class Crypt_DiffieHellman_Math extends
Crypt_DiffieHellman_Math_BigInteger" is a bit an unconventional class name
order. We can see the negaive side effect of this in the "if instanceof
Crypt_<snip>_gmp" tests. Organize the backend classes so they are
self-contained (i.e. not try to guess which type they are at runtime; if
you already loaded a backend no need to recheck whether a feature is
available or not.)
- Always put spaces between "if" and opening ( - same for "elseif" & co.
- Use ++$i instead of $i++ whenever possible ("for" loops)
Proposal information:
http://pear.php.net/pepr/pepr-proposal-show.php?id=496
--
Sent by PEPr, the automatic proposal system at http://pear.php.net