Add a workaround for PHPs inconsistent handling of boolean values.

Fixes #393, #355