|  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: 2015-08-18 17:28 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: rgasler at streamwide dot ro Assigned:
Status: Open Package: intl (PECL)
PHP Version: 5.3.8 OS: Ubuntu 11.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
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
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 18:03:37 2021 UTC