Consequence and consistence

Posted on 2009-02-12 20:01:49 EET.

I tell it here and there. But people tend to forget, so it's better to write it down. I know, some people (developers) already don't like me, but it's not really my fault they write bad code. And since now, I will (consequently) write about something they produce. Ah! It's PHP or Zend Engine 2, if I forgot to mention.

Let's look at one file, php_reflection.c from reflection extension.

/* Invoke the __toString() method */
ZVAL_STRINGL(&fname, "__tostring", sizeof("__tostring") - 1, 1);

So what is the method name? __tostring or __toString? What minimal alphabet they use?

And note second line:

ZVAL_STRINGL(&fname, "__tostring", sizeof("__tostring") - 1, 1);

And one more from the same file:

zend_hash_find(EG(function_table), lcname, name_len + 1, (void **)&fptr);

and one more:

zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL);

What's the deal with those three lines of code? API is created such way, so it forces you to pass length of the passed string. So if you look at examples above, how do you count length of the string?

Back

Layout Copyright © 2006 Finnish Teleservice Center Ltd Oy - Site Powered by Midgard CMS