|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #60148 Cannot select rule set when using NumberFormatter with pattern rule based
Submitted: 2011-10-27 14:33 UTC Modified: 2021-11-11 11:16 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: rgasler at streamwide dot ro Assigned:
Status: Open Package: I18N and L10N related
PHP Version: 5.3.8 OS: Ubuntu 11.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: rgasler at streamwide dot ro
New email:
PHP Version: OS:


 [2011-10-27 14:33 UTC] rgasler at streamwide dot ro
According to the RuleBasedNumberFormat documentation:, a rule pattern 
string can have multiple rule sets.
When calling the format method, it is possible to select the rule set to use. 

But it PHP seems that this is not possible in the current implementation:

NumberFormatter::string format ( number $value [, int $type ] )

Notice that $type is an integer and may take only these possible values:

For rule set selection to work $type should be a string (the rule set name).

Test script:

$formatter = new NumberFormatter(null, NumberFormatter::PATTERN_RULEBASED, $ruleSet);

echo $formatter->format(1, 'spellout-ordinal');

Expected result:

Actual result:
PHP Warning:  NumberFormatter::format() expects parameter 2 to be long, string 
given in /home/raducu/Workspace/Spelling/numbers.php on line 12


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-19 13:02 UTC] clicky at erebot dot net
You're correct in saying it is not possible to select the ruleset when calling format(). But there is a workaround.

You can use the setTextAttribute() method with the NumberFormatter::DEFAULT_RULESET attribute to select the ruleset.
See my comment here for more information: (internally, NumberFormatter::DURATION uses a ruleset).
 [2015-08-18 17:28 UTC]
-Type: Bug +Type: Feature/Change Request
 [2021-11-11 11:16 UTC]
-Package: intl +Package: I18N and L10N related
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Nov 28 08:05:53 2022 UTC