Skip to content

ValueError: NumberFormatter::format(): Argument #3 must be a NumberFormatter::TYPE_* constant #9421

Closed
@bobmagicii

Description

@bobmagicii

Description

from the php manual

public NumberFormatter::format(int|float $num, int $type = NumberFormatter::TYPE_DEFAULT): string|false

not quite sure about this mystical argument # 3.

$Fmt = new NumberFormatter('en_US', NumberFormatter::CURRENCY);
var_dump($Fmt->format(1234.45, NumberFormatter::TYPE_CURRENCY));

Resulted in this output:

Output for 8.0.1 - 8.0.22, 8.1.0 - 8.1.9

    Fatal error: Uncaught ValueError: NumberFormatter::format(): Argument #3 must be a NumberFormatter::TYPE_* constant in /in/mc4XU:4
    Stack trace:
    #0 /in/mc4XU(4): NumberFormatter->format(1234.45, 4)
    #1 {main}
      thrown in /in/mc4XU on line 4

    Process exited with code 255.

But I expected this output instead:

pretty much anything except saying it needs a third argument that isn't documented.

https://3v4l.org/mc4XU

PHP Version

PHP 8+

Operating System

Linux 5.4.0-88-generic # 99-Ubuntu SMP Thu Sep 23 17:29:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

[edit] idk it says i added those tags (bugs, triage) but they showed up on their own i just report the news

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions