Skip to content

Commit 27da0b2

Browse files
authored
Enhancement: Enable long_to_shorthand_operator fixer (#791)
1 parent 6239bd1 commit 27da0b2

File tree

9 files changed

+12
-11
lines changed

9 files changed

+12
-11
lines changed

.php-cs-fixer.rules.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
'list_syntax' => [
6868
'syntax' => 'short',
6969
],
70+
'long_to_shorthand_operator' => true,
7071
'lowercase_cast' => true,
7172
'lowercase_static_reference' => true,
7273
'magic_constant_casing' => true,

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ parameters:
66
path: src/Calculator/Iban.php
77

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

src/Calculator/Isbn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static function checksum(string $input): string
3535
array_walk(
3636
$digits,
3737
static function (&$digit, $position): void {
38-
$digit = (10 - $position) * $digit;
38+
$digit *= (10 - $position) ;
3939
},
4040
);
4141
$result = (11 - array_sum($digits) % 11) % 11;

src/Generator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ public function optional(float $weight = 0.5, $default = null)
646646
{
647647
if ($weight > 1) {
648648
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);
649-
$weight = $weight / 100;
649+
$weight /= 100;
650650
}
651651

652652
return new ChanceGenerator($this, $weight, $default);

src/Provider/ar_EG/Person.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ public static function nationalIdNumber($gender = null)
9696
$birthRegistrationSequence = Extension\Helper::randomNumberBetween(1, 500);
9797

9898
if ($gender === static::GENDER_MALE) {
99-
$birthRegistrationSequence = $birthRegistrationSequence | 1; // Convert to the nearest odd number
99+
$birthRegistrationSequence |= 1; // Convert to the nearest odd number
100100
} elseif ($gender === static::GENDER_FEMALE) {
101-
$birthRegistrationSequence = $birthRegistrationSequence & ~1; // Convert to the nearest even number
101+
$birthRegistrationSequence &= ~1; // Convert to the nearest even number
102102
}
103103

104104
$birthRegistrationSequence = str_pad((string) $birthRegistrationSequence, 4, '0', STR_PAD_LEFT);

src/Provider/en_GB/Company.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ public static function calculateModulus97(string $input, bool $use9755 = true):
117117
}
118118

119119
if ($use9755) {
120-
$sum = $sum + 55;
120+
$sum += 55;
121121
}
122122

123123
while ($sum > 0) {
124124
$sum -= 97;
125125
}
126-
$sum = $sum * -1;
126+
$sum *= -1;
127127

128128
return str_pad((string) $sum, 2, '0', STR_PAD_LEFT);
129129
}

src/Provider/ms_MY/Person.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,9 @@ public static function myKadNumber($gender = null, $hyphen = false)
795795

796796
//Credit: https://gist.github.com/mauris/3629548
797797
if ($gender === static::GENDER_MALE) {
798-
$g = $g | 1;
798+
$g |= 1;
799799
} elseif ($gender === static::GENDER_FEMALE) {
800-
$g = $g & ~1;
800+
$g &= ~1;
801801
}
802802

803803
// formatting with hyphen

src/Provider/pl_PL/Payment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ protected static function addBankCodeChecksum($iban, $countryCode = 'PL')
113113
for ($i = 0; $i < 7; ++$i) {
114114
$checksum += $weights[$i] * (int) $iban[$i];
115115
}
116-
$checksum = $checksum % 10;
116+
$checksum %= 10;
117117

118118
return substr($iban, 0, 7) . $checksum . substr($iban, 8);
119119
}

src/Provider/ro_RO/Person.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ protected function getChecksumDigit($value)
244244
foreach (range(0, 11) as $digit) {
245245
$checksum += (int) substr($value, $digit, 1) * (int) substr($checkNumber, $digit, 1);
246246
}
247-
$checksum = $checksum % 11;
247+
$checksum %= 11;
248248

249249
return $checksum == 10 ? 1 : $checksum;
250250
}

0 commit comments

Comments
 (0)