Skip to content

Commit

Permalink
Merge pull request #7640 from kenjis/fix-number_to_roman
Browse files Browse the repository at this point in the history
fix: number_to_roman() param type
  • Loading branch information
kenjis authored Jun 29, 2023
2 parents eeaa556 + 713c1db commit 46e1ab1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions system/Helpers/number_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ function format_number(float $num, int $precision = 1, ?string $locale = null, a
/**
* Convert a number to a roman numeral.
*
* @param string $num it will convert to int
* @param int|string $num it will convert to int
*/
function number_to_roman(string $num): ?string
function number_to_roman($num): ?string
{
static $map = [
'M' => 1000,
Expand Down
4 changes: 2 additions & 2 deletions user_guide_src/source/helpers/number_helper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ The following functions are available:

.. php:function:: number_to_roman($num)
:param string $num: The number want to convert
:param int|string $num: The number want to convert
:returns: The roman number converted from given parameter
:rtype: string|null

Expand All @@ -101,4 +101,4 @@ The following functions are available:
.. literalinclude:: number_helper/009.php

This function only handles numbers in the range 1 through 3999.
It will return null for any value outside that range.
It will return ``null`` for any value outside that range.
4 changes: 2 additions & 2 deletions user_guide_src/source/helpers/number_helper/009.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

echo number_to_roman(23); // Returns XXIII
echo number_to_roman(324); // Returns CCCXXIV
echo number_to_roman(23); // Returns XXIII
echo number_to_roman(324); // Returns CCCXXIV
echo number_to_roman(2534); // Returns MMDXXXIV

0 comments on commit 46e1ab1

Please sign in to comment.