[PEPr] Comment on Web Services::Services_JSON
| From: | Justin Patrin | Date: | Sat, 08 Oct 2005 22:36:39 +0000 |
| Subject: | [PEPr] Comment on Web Services::Services_JSON | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-40115@lists.php.net to get a copy of this message | ||
Justin Patrin (http://pear.php.net/user/justinpatrin) has commented on the proposal for Web
Services::Services_JSON.
Comment:
sprintf('%d', $var) and sprintf('%f', $var) should really be (int)$var and
(float)$var. Sprintf is a slow solution and it very rarely, if ever,
needed.
sprintf('{%s}',and '[%s]', same thing. It makes no sense to do simple
string inserting with sprintf. Use '{'.(string).'}' and
'['.(string).']'
Why both enc() and encode() and dec() and decode()?
Again, sprintf("%s:%s"), not ok. This is simple concatenation. Use
(string).':'.(string).
'/^("|\').+("|\')$/s'
Perhaps you mean:
'/^("|\').+$/s'
$c+=1 should be ++$c
Please put each line of code on its own line. Ex:
case '\b': $utf8 .= chr(0x08); $c+=1; break;
Should be:
case '\b':
$utf8 .= chr(0x08);
++$c;
break;
And:
$utf8 .= substr($chrs, $c, 2); $c += 1;
Should be:
$utf8 .= substr($chrs, $c, 2);
++$c;
preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)
can be reduced to:
preg_match('/^([\[\{]).*$/s', $str)
"\" should be '\'
There seems to be something wrong with your indeting (see end of
decode()).
Is there a reason the string needs to be reduced before being decoded? It
seems that if decode() handles comments (and it seems to) then
reduce_string() is basically just repeated code.
Proposal information:
http://pear.php.net/pepr/pepr-proposal-show.php?id=198
--
Sent by PEPr, the automatic proposal system at http://pear.php.net