Re: Add a static initialization method to `BcMath\Number`
| From: | Marco Pivetta | Date: | Fri, 29 May 2026 08:42:33 +0000 |
| Subject: | Re: Add a static initialization method to `BcMath\Number` | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131048@lists.php.net to get a copy of this message | ||
Hey Saki,
On Sat, 23 May 2026 at 14:51, Saki Takamachi <saki@sakiot.com> wrote:
> I am in favor of introducing such a static method. It would probably look
> something like this:
>
> ```
> // $scale is optional
> $num = BcMath\Number::createFrom($val, $scale);
> ```
I'm overall very much in favor of static factory methods: they are a clear
and established way of doing this in the ecosystem at large, with no
particular drawbacks, and better future BC boundaries.
Important though:
::createFrom() is probably a bad name, and
::fromValueAndScale() or such would allow clearer/future expansion via
other constructors.
Marco Pivetta
https://mastodon.social/@ocramius
https://ocramius.github.io/