Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2aaf3f4

Browse files
committed
Fix: Add parameter type declarations
1 parent 1f83b68 commit 2aaf3f4

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

roave-bc-check.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,30 @@ parameters:
55
- '#\[BC\] CHANGED: Property Faker\\Provider\\[a-z_A-Z]+\\[a-zA-Z]+::\$[1-9a-zA-Z]+ changed default value#'
66
- '#\[BC\] CHANGED: Property Faker\\Provider\\[a-zA-Z]+::\$[1-9a-zA-Z]+ changed default value#'
77
- '#\[BC\] CHANGED: The number of required arguments for Faker\\Container\\ContainerBuilder\#add\(\) increased from 1 to 2#'
8+
- '#\[BC\] CHANGED: The parameter \$char of Faker\\Calculator\\Iban::alphaToNumber\(\) changed from no type to a non-contravariant string#'
9+
- '#\[BC\] CHANGED: The parameter \$char of Faker\\Calculator\\Iban::alphaToNumber\(\) changed from no type to string#'
810
- '#\[BC\] CHANGED: The parameter \$container of Faker\\Generator\#\_\_construct\(\) changed from Psr\\Container\\ContainerInterface\|null to a non-contravariant Faker\\Container\\ContainerInterface\|null#'
911
- '#\[BC\] CHANGED: The parameter \$container of Faker\\Generator\#\_\_construct\(\) changed from Psr\\Container\\ContainerInterface\|null to Faker\\Container\\ContainerInterface\|null#'
12+
- '#\[BC\] CHANGED: The parameter \$digits of Faker\\Calculator\\Ean::checksum\(\) changed from no type to a non-contravariant string#'
13+
- '#\[BC\] CHANGED: The parameter \$digits of Faker\\Calculator\\Ean::checksum\(\) changed from no type to string#'
14+
- '#\[BC\] CHANGED: The parameter \$ean of Faker\\Calculator\\Ean::isValid\(\) changed from no type to a non-contravariant string#'
15+
- '#\[BC\] CHANGED: The parameter \$ean of Faker\\Calculator\\Ean::isValid\(\) changed from no type to string#'
1016
- '#\[BC\] CHANGED: The parameter \$generator of Faker\\UniqueGenerator\#\_\_construct\(\) changed from Faker\\Generator to no type#'
1117
- '#\[BC\] CHANGED: The parameter \$generator of Faker\\ValidGenerator\#\_\_construct\(\) changed from Faker\\Generator to no type#'
18+
- '#\[BC\] CHANGED: The parameter \$iban of Faker\\Calculator\\Iban::checksum\(\) changed from no type to a non-contravariant string#'
19+
- '#\[BC\] CHANGED: The parameter \$iban of Faker\\Calculator\\Iban::checksum\(\) changed from no type to string#'
20+
- '#\[BC\] CHANGED: The parameter \$iban of Faker\\Calculator\\Iban::isValid\(\) changed from no type to a non-contravariant string#'
21+
- '#\[BC\] CHANGED: The parameter \$iban of Faker\\Calculator\\Iban::isValid\(\) changed from no type to string#'
1222
- '#\[BC\] CHANGED: The parameter \$max of Faker\\Extension\\NumberExtension\#randomFloat\(\) changed from float to float\|null#'
1323
- '#\[BC\] CHANGED: The parameter \$name of Faker\\Container\\ContainerBuilder\#add\(\) changed from string\|null to a non-contravariant string#'
24+
- '#\[BC\] CHANGED: The parameter \$number of Faker\\Calculator\\Iban::mod97\(\) changed from no type to a non-contravariant string#'
25+
- '#\[BC\] CHANGED: The parameter \$number of Faker\\Calculator\\Iban::mod97\(\) changed from no type to string#'
26+
- '#\[BC\] CHANGED: The parameter \$number of Faker\\Calculator\\Luhn::isValid\(\) changed from no type to a non-contravariant string#'
27+
- '#\[BC\] CHANGED: The parameter \$number of Faker\\Calculator\\Luhn::isValid\(\) changed from no type to string#'
28+
- '#\[BC\] CHANGED: The parameter \$partialNumber of Faker\\Calculator\\Luhn::computeCheckDigit\(\) changed from no type to a non-contravariant string#'
29+
- '#\[BC\] CHANGED: The parameter \$partialNumber of Faker\\Calculator\\Luhn::computeCheckDigit\(\) changed from no type to string#'
30+
- '#\[BC\] CHANGED: The parameter \$partialValue of Faker\\Calculator\\Luhn::generateLuhnNumber\(\) changed from no type to a non-contravariant string#'
31+
- '#\[BC\] CHANGED: The parameter \$partialValue of Faker\\Calculator\\Luhn::generateLuhnNumber\(\) changed from no type to string#'
1432
- '#\[BC\] CHANGED: The parameter \$value of Faker\\Container\\ContainerBuilder\#add\(\) changed from no type to a non-contravariant string#'
1533
- '#\[BC\] CHANGED: The return type of Faker\\Extension\\PersonExtension\#name\(\) changed from no type to string#'
1634
- '#\[BC\] CHANGED: Type documentation for property Faker\\Provider\\en_ZA\\Internet::\$tld changed from having no type to array#'

src/Faker/Calculator/Ean.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ class Ean
1717
*
1818
* @see https://en.wikipedia.org/wiki/International_Article_Number
1919
*
20-
* @param string $digits
21-
*
2220
* @return int
2321
*/
24-
public static function checksum($digits)
22+
public static function checksum(string $digits)
2523
{
2624
$sequence = (strlen($digits) + 1) === 8 ? [3, 1] : [1, 3];
2725
$sums = 0;
@@ -41,7 +39,7 @@ public static function checksum($digits)
4139
*
4240
* @return bool
4341
*/
44-
public static function isValid($ean)
42+
public static function isValid(string $ean)
4543
{
4644
if (!preg_match(self::PATTERN, $ean)) {
4745
return false;

src/Faker/Calculator/Iban.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ class Iban
77
/**
88
* Generates IBAN Checksum
99
*
10-
* @param string $iban
11-
*
1210
* @return string Checksum (numeric string)
1311
*/
14-
public static function checksum($iban)
12+
public static function checksum(string $iban)
1513
{
1614
// Move first four digits to end and set checksum to '00'
1715
$checkString = substr($iban, 4) . substr($iban, 0, 2) . '00';
@@ -34,11 +32,9 @@ static function (array $matches): string {
3432
/**
3533
* Converts letter to number
3634
*
37-
* @param string $char
38-
*
3935
* @return int
4036
*/
41-
public static function alphaToNumber($char)
37+
public static function alphaToNumber(string $char)
4238
{
4339
return ord($char) - 55;
4440
}
@@ -50,7 +46,7 @@ public static function alphaToNumber($char)
5046
*
5147
* @return int
5248
*/
53-
public static function mod97($number)
49+
public static function mod97(string $number)
5450
{
5551
$checksum = (int) $number[0];
5652

@@ -64,11 +60,9 @@ public static function mod97($number)
6460
/**
6561
* Checks whether an IBAN has a valid checksum
6662
*
67-
* @param string $iban
68-
*
6963
* @return bool
7064
*/
71-
public static function isValid($iban)
65+
public static function isValid(string $iban)
7266
{
7367
return self::checksum($iban) === substr($iban, 2, 2);
7468
}

src/Faker/Calculator/Luhn.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
class Luhn
1414
{
1515
/**
16-
* @param string $number
17-
*
1816
* @return int
1917
*/
20-
private static function checksum($number)
18+
private static function checksum(string $number)
2119
{
2220
$number = (string) $number;
2321
$length = strlen($number);
@@ -35,11 +33,9 @@ private static function checksum($number)
3533
}
3634

3735
/**
38-
* @param string $partialNumber
39-
*
4036
* @return string
4137
*/
42-
public static function computeCheckDigit($partialNumber)
38+
public static function computeCheckDigit(string $partialNumber)
4339
{
4440
$checkDigit = self::checksum($partialNumber . '0');
4541

@@ -53,23 +49,19 @@ public static function computeCheckDigit($partialNumber)
5349
/**
5450
* Checks whether a number (partial number + check digit) is Luhn compliant
5551
*
56-
* @param string $number
57-
*
5852
* @return bool
5953
*/
60-
public static function isValid($number)
54+
public static function isValid(string $number)
6155
{
6256
return self::checksum($number) === 0;
6357
}
6458

6559
/**
6660
* Generate a Luhn compliant number.
6761
*
68-
* @param string $partialValue
69-
*
7062
* @return string
7163
*/
72-
public static function generateLuhnNumber($partialValue)
64+
public static function generateLuhnNumber(string $partialValue)
7365
{
7466
if (!preg_match('/^\d+$/', $partialValue)) {
7567
throw new \InvalidArgumentException('Argument should be an integer.');

0 commit comments

Comments
 (0)