Skip to content

Commit

Permalink
Remove invalid postcode pattern for France
Browse files Browse the repository at this point in the history
  • Loading branch information
ker0x committed Aug 23, 2023
1 parent 1d21cbc commit 6663770
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 31 deletions.
28 changes: 9 additions & 19 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$input of function str_pad expects string, int given\\.$#"
message: "#^Parameter \\#1 \\$string of function str_pad expects string, int given\\.$#"
count: 1
path: src/Faker/Calculator/Iban.php

Expand Down Expand Up @@ -610,11 +610,6 @@ parameters:
count: 1
path: src/Faker/ORM/Spot/Populator.php

-
message: "#^Class UnitEnum not found\\.$#"
count: 2
path: src/Faker/Provider/Base.php

-
message: """
#^Instantiation of deprecated class Faker\\\\DefaultGenerator\\:
Expand All @@ -629,7 +624,7 @@ parameters:
path: src/Faker/Provider/Base.php

-
message: "#^Parameter \\#1 \\$input of function str_pad expects string, int given\\.$#"
message: "#^Parameter \\#1 \\$string of function str_pad expects string, int given\\.$#"
count: 1
path: src/Faker/Provider/Base.php

Expand Down Expand Up @@ -679,12 +674,12 @@ parameters:
path: src/Faker/Provider/Lorem.php

-
message: "#^Parameter \\#1 \\$str of function md5 expects string, int given\\.$#"
message: "#^Parameter \\#1 \\$string of function md5 expects string, int given\\.$#"
count: 1
path: src/Faker/Provider/Miscellaneous.php

-
message: "#^Parameter \\#1 \\$str of function sha1 expects string, int given\\.$#"
message: "#^Parameter \\#1 \\$string of function sha1 expects string, int given\\.$#"
count: 1
path: src/Faker/Provider/Miscellaneous.php

Expand Down Expand Up @@ -774,7 +769,7 @@ parameters:
path: src/Faker/Provider/en_NG/Address.php

-
message: "#^Parameter \\#1 \\$input of function str_pad expects string, int given\\.$#"
message: "#^Parameter \\#1 \\$string of function str_pad expects string, int given\\.$#"
count: 1
path: src/Faker/Provider/en_ZA/Person.php

Expand Down Expand Up @@ -899,12 +894,7 @@ parameters:
path: src/Faker/Provider/pt_PT/Address.php

-
message: "#^Left side of \\|\\| is always true\\.$#"
count: 1
path: src/Faker/Provider/pt_PT/Person.php

-
message: "#^Right side of \\|\\| is always false\\.$#"
message: "#^Binary operation \"\\*\" between string and int results in an error\\.$#"
count: 1
path: src/Faker/Provider/pt_PT/Person.php

Expand All @@ -914,7 +904,7 @@ parameters:
path: src/Faker/Provider/ro_RO/Person.php

-
message: "#^Parameter \\#1 \\$input of function str_pad expects string, int given\\.$#"
message: "#^Parameter \\#1 \\$string of function str_pad expects string, int given\\.$#"
count: 1
path: src/Faker/Provider/ru_RU/Company.php

Expand All @@ -934,7 +924,7 @@ parameters:
path: src/Faker/Provider/sv_SE/Municipality.php

-
message: "#^Parameter \\#1 \\$input of function str_pad expects string, int given\\.$#"
message: "#^Parameter \\#1 \\$string of function str_pad expects string, int given\\.$#"
count: 1
path: src/Faker/Provider/zh_CN/Address.php

Expand All @@ -944,7 +934,7 @@ parameters:
path: src/Faker/Provider/zh_CN/Address.php

-
message: "#^Parameter \\#1 \\$autoload_function of function spl_autoload_register expects callable\\(string\\)\\: void, Closure\\(mixed\\)\\: bool given\\.$#"
message: "#^Parameter \\#1 \\$callback of function spl_autoload_register expects \\(callable\\(string\\)\\: void\\)\\|null, Closure\\(mixed\\)\\: bool given\\.$#"
count: 1
path: src/autoload.php

14 changes: 3 additions & 11 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,26 +141,18 @@
</file>
<file src="src/Faker/Provider/Base.php">
<InvalidArgument>
<code>[static::class, 'randomDigit']</code>
<code>static function ($matches) {
<code><![CDATA[[static::class, 'randomDigit']]]></code>
<code><![CDATA[static function ($matches) {
// remove backslashes (that are not followed by another backslash) because they are escape characters
$match = preg_replace('/\\\(?!\\\)/', '', $matches[1]);
$randomElement = Base::randomElement(str_split($match));
//[.] should not be a random character, but a literal .
return str_replace('.', '\.', $randomElement);
}</code>
}]]></code>
</InvalidArgument>
<UndefinedClass>
<code>\UnitEnum</code>
<code>\UnitEnum</code>
</UndefinedClass>
<UndefinedDocblockClass>
<code>Closure</code>
</UndefinedDocblockClass>
<UndefinedFunction>
<code>enum_exists($array)</code>
<code>enum_exists($array)</code>
</UndefinedFunction>
</file>
<file src="src/Faker/Provider/Biased.php">
<InvalidParamDefault>
Expand Down
6 changes: 5 additions & 1 deletion src/Faker/Provider/fr_FR/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class Address extends \Faker\Provider\Address
];

protected static $buildingNumber = ['%', '%#', '%#', '%#', '%##'];
protected static $postcode = ['#####', '## ###'];

/**
* @see https://en.wikipedia.org/wiki/Postal_codes_in_France
*/
protected static $postcode = ['#####'];

protected static $country = [
'Afghanistan', 'Afrique du sud', 'Albanie', 'Algérie', 'Allemagne', 'Andorre', 'Angola', 'Anguilla', 'Antarctique', 'Antigua et Barbuda', 'Antilles néerlandaises', 'Arabie saoudite', 'Argentine', 'Arménie', 'Aruba', 'Australie', 'Autriche', 'Azerbaïdjan', 'Bahamas', 'Bahrain', 'Bangladesh', 'Belgique', 'Belize', 'Benin', 'Bermudes (Les)', 'Bhoutan', 'Biélorussie', 'Bolivie', 'Bosnie-Herzégovine', 'Botswana', 'Bouvet (Îles)', 'Brunei', 'Brésil', 'Bulgarie', 'Burkina Faso', 'Burundi', 'Cambodge', 'Cameroun', 'Canada', 'Cap Vert', 'Cayman (Îles)', 'Chili', 'Chine (Rép. pop.)', 'Christmas (Île)', 'Chypre', 'Cocos (Îles)', 'Colombie', 'Comores', 'Cook (Îles)', 'Corée du Nord', 'Corée, Sud', 'Costa Rica', 'Croatie', 'Cuba', 'Côte d\'Ivoire', 'Danemark', 'Djibouti', 'Dominique', 'Égypte', 'El Salvador', 'Émirats arabes unis', 'Équateur', 'Érythrée', 'Espagne', 'Estonie', 'États-Unis', 'Ethiopie', 'Falkland (Île)', 'Fidji (République des)', 'Finlande', 'France', 'Féroé (Îles)', 'Gabon',
Expand Down
8 changes: 8 additions & 0 deletions test/Faker/Provider/fr_FR/AddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
*/
final class AddressTest extends TestCase
{
public function testPostcode(): void
{
$postcode = $this->faker->postcode();
self::assertNotEmpty($postcode);
self::assertIsString($postcode);
self::assertMatchesRegularExpression('@^\d{5}$@', $postcode);
}

public function testSecondaryAddress(): void
{
self::assertEquals('Étage 007', $this->faker->secondaryAddress());
Expand Down

0 comments on commit 6663770

Please sign in to comment.