php-src/ext/intl/tests/bug48227.phpt
Nikita Popov b2b2b437af Add _IS_NUMBER as cast_object() target type
convert_scalar_to_number() will now call cast_object() with an
_IS_NUMBER argument, in which case the cast handler should return
either an integer or floating point number, whichever is more
appropriate.

Previously convert_scalar_to_number() unconditionally converted
objects to integers instead.

Fixes bug #53033.
Fixes bug #54973.
Fixes bug #73108.
2017-12-26 12:39:06 +01:00

22 lines
472 B
PHP

--TEST--
Bug #48227 (NumberFormatter::format leaks memory)
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
--FILE--
<?php
$x = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
var_dump($x->format(''));
var_dump($x->format(1));
var_dump($x->format(NULL));
var_dump($x->format($x));
?>
--EXPECTF--
string(1) "0"
string(1) "1"
string(1) "0"
Notice: Object of class NumberFormatter could not be converted to number in %s on line %d
string(1) "1"