ZF-5077: Object of class Zend_Locale to string conversion


The issue is originaly reported by Ilya Gruzinov (see [ZF-4992]).

This is reproducible with 1.7.0. version, but only on php <5.2(i test on 5.1.6)

php LocaleTest.php

PHPUnit 3.3.5 by Sebastian Bergmann.


Time: 4 seconds

There were 2 errors: {panel} 1) testObjectCreation(Zend_LocaleTest) Object of class Zend_Locale to string conversion /tmp/ZendFramework-1.7.0/library/Zend/Locale.php:885 /tmp/ZendFramework-1.7.0/library/Zend/Locale.php:189

2) testIsLocale(Zend_LocaleTest) Object of class Zend_Locale to string conversion /tmp/ZendFramework-1.7.0/library/Zend/Locale.php:885 /tmp/ZendFramework-1.7.0/library/Zend/Locale.php:732

FAILURES! Tests: 28, Assertions: 171, Errors: 2. {panel}

I think next lines can explain where mistake: […] :

It is worth noting that before PHP 5.2.0 the __toString method was only called when it was directly combined with echo() or print(). Since PHP 5.2.0, it is called in any string context (e.g. in printf() with %s modifier) but not in other types contexts (e.g. with %d modifier). Since PHP 5.2.0, converting objects without __toString method to string would cause E_RECOVERABLE_ERROR.


I think this issue is already fixed in trunk/branch... Line 885 is a require_once call which does no string conversion.

And any given Zend_Locale instance will be forced to string at line 846/847 by calling toString on the instance.

Can you please test it against trunk. I can not reproduce it on Windows with 5.1.4

Trunk now:

Time: 4 seconds

There was 1 failure:

1) testIsLocale(Zend_LocaleTest) Failed asserting that is true.

FAILURES! Tests: 29, Assertions: 189, Failures: 1.

Ilva: This failure is ZF-4992

Please to not throw together different issues. This is useless and make only more work as it should.

And it just raises the time we need for fixing.

So you are no longer getting the failure of this issue in your environment on trunk ? Is that correct ?

Then this issue can be closed and we can work on ZF-4992

Yes, it is correct. This issue can be closed.

Updating these issues to mark them resolved for 1.7.1.