Typehinting merge #50

Merged
belliash merged 298 commits from typehinting into master 2019-04-17 11:27:52 +02:00
Showing only changes of commit 3074b4efaf - Show all commits

View File

@ -1,7 +1,7 @@
class Program { class Program {
private string num2Roman(int $num) { private string num2Roman(int $num) {
int $n = intval($num); int $n = (int) $num;
string $result = ''; string $result = '';
int[] $lookup = {'M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, int[] $lookup = {'M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400,
'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40,
@ -9,7 +9,7 @@ class Program {
int $matches; int $matches;
foreach($lookup as $roman => $value) { foreach($lookup as $roman => $value) {
$matches = intval($n / $value); $matches = (int) ($n / $value);
$result += str_repeat($roman, $matches); $result += str_repeat($roman, $matches);
$n = $n % $value; $n = $n % $value;
} }