Skip to content

Enhancement: Enable long_to_shorthand_operator fixer #791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .php-cs-fixer.rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
'list_syntax' => [
'syntax' => 'short',
],
'long_to_shorthand_operator' => true,
'lowercase_cast' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
Expand Down
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ parameters:
path: src/Calculator/Iban.php

-
message: "#^Binary operation \"\\*\" between int and string results in an error\\.$#"
message: "#^Binary operation \"\\*\\=\" between string and int results in an error\\.$#"
count: 1
path: src/Calculator/Isbn.php

Expand Down
2 changes: 1 addition & 1 deletion src/Calculator/Isbn.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function checksum(string $input): string
array_walk(
$digits,
static function (&$digit, $position): void {
$digit = (10 - $position) * $digit;
$digit *= (10 - $position) ;
},
);
$result = (11 - array_sum($digits) % 11) % 11;
Expand Down
2 changes: 1 addition & 1 deletion src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ public function optional(float $weight = 0.5, $default = null)
{
if ($weight > 1) {
trigger_deprecation('fakerphp/faker', '1.16', 'First argument ($weight) to method "optional()" must be between 0 and 1. You passed %f, we assume you meant %f.', $weight, $weight / 100);
$weight = $weight / 100;
$weight /= 100;
}

return new ChanceGenerator($this, $weight, $default);
Expand Down
4 changes: 2 additions & 2 deletions src/Provider/ar_EG/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ public static function nationalIdNumber($gender = null)
$birthRegistrationSequence = Extension\Helper::randomNumberBetween(1, 500);

if ($gender === static::GENDER_MALE) {
$birthRegistrationSequence = $birthRegistrationSequence | 1; // Convert to the nearest odd number
$birthRegistrationSequence |= 1; // Convert to the nearest odd number
} elseif ($gender === static::GENDER_FEMALE) {
$birthRegistrationSequence = $birthRegistrationSequence & ~1; // Convert to the nearest even number
$birthRegistrationSequence &= ~1; // Convert to the nearest even number
}

$birthRegistrationSequence = str_pad((string) $birthRegistrationSequence, 4, '0', STR_PAD_LEFT);
Expand Down
4 changes: 2 additions & 2 deletions src/Provider/en_GB/Company.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ public static function calculateModulus97(string $input, bool $use9755 = true):
}

if ($use9755) {
$sum = $sum + 55;
$sum += 55;
}

while ($sum > 0) {
$sum -= 97;
}
$sum = $sum * -1;
$sum *= -1;

return str_pad((string) $sum, 2, '0', STR_PAD_LEFT);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Provider/ms_MY/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -795,9 +795,9 @@ public static function myKadNumber($gender = null, $hyphen = false)

//Credit: https://gist.github.com/mauris/3629548
if ($gender === static::GENDER_MALE) {
$g = $g | 1;
$g |= 1;
} elseif ($gender === static::GENDER_FEMALE) {
$g = $g & ~1;
$g &= ~1;
}

// formatting with hyphen
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/pl_PL/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected static function addBankCodeChecksum($iban, $countryCode = 'PL')
for ($i = 0; $i < 7; ++$i) {
$checksum += $weights[$i] * (int) $iban[$i];
}
$checksum = $checksum % 10;
$checksum %= 10;

return substr($iban, 0, 7) . $checksum . substr($iban, 8);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/ro_RO/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ protected function getChecksumDigit($value)
foreach (range(0, 11) as $digit) {
$checksum += (int) substr($value, $digit, 1) * (int) substr($checkNumber, $digit, 1);
}
$checksum = $checksum % 11;
$checksum %= 11;

return $checksum == 10 ? 1 : $checksum;
}
Expand Down