xref: /php-src/ext/intl/tests/bug48227.phpt (revision 74859783)
1--TEST--
2Bug #48227 (NumberFormatter::format leaks memory)
3--EXTENSIONS--
4intl
5--FILE--
6<?php
7
8$x = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
9foreach (['', 1, NULL, $x] as $value) {
10    try {
11        var_dump($x->format($value));
12    } catch (TypeError $ex) {
13        echo $ex->getMessage(), PHP_EOL;
14    }
15}
16
17?>
18--EXPECTF--
19NumberFormatter::format(): Argument #1 ($num) must be of type int|float, string given
20string(1) "1"
21
22Deprecated: NumberFormatter::format(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
23string(1) "0"
24NumberFormatter::format(): Argument #1 ($num) must be of type int|float, NumberFormatter given
25