Fixed possible bugs introduced by fixing PHP bug

- https://bugs.php.net/bug.php?id=67072
- https://github.com/doctrine/doctrine2/pull/1051