diff --git a/src/Faker/Factory.php b/src/Faker/Factory.php index 7d29de75b2..e9d201432d 100644 --- a/src/Faker/Factory.php +++ b/src/Faker/Factory.php @@ -38,10 +38,12 @@ protected static function getProviderClassname($provider, $locale = '') if ($providerClass = self::findProviderClassname($provider, $locale)) { return $providerClass; } + // fallback to default locale if ($providerClass = self::findProviderClassname($provider, static::DEFAULT_LOCALE)) { return $providerClass; } + // fallback to no locale if ($providerClass = self::findProviderClassname($provider)) { return $providerClass; diff --git a/src/Faker/Provider/Base.php b/src/Faker/Provider/Base.php index a590afb478..6b9876bc1d 100644 --- a/src/Faker/Provider/Base.php +++ b/src/Faker/Provider/Base.php @@ -576,6 +576,7 @@ public static function regexify($regex = '') // 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); }, $regex); diff --git a/src/Faker/Provider/Image.php b/src/Faker/Provider/Image.php index 53f28dfcfa..e787142178 100644 --- a/src/Faker/Provider/Image.php +++ b/src/Faker/Provider/Image.php @@ -123,6 +123,7 @@ public static function image( ); $dir = null === $dir ? sys_get_temp_dir() : $dir; // GNU/Linux / OS X / Windows compatible + // Validate directory path if (!is_dir($dir) || !is_writable($dir)) { throw new \InvalidArgumentException(sprintf('Cannot write to directory "%s"', $dir)); diff --git a/src/Faker/Provider/cs_CZ/Person.php b/src/Faker/Provider/cs_CZ/Person.php index 64b4e9e0c8..e962fb6d9e 100644 --- a/src/Faker/Provider/cs_CZ/Person.php +++ b/src/Faker/Provider/cs_CZ/Person.php @@ -451,6 +451,7 @@ public function birthNumber($gender = null, $minAge = 0, $maxAge = 100, $slashPr if ($gender == static::GENDER_FEMALE) { $month += 50; } + // from year 2004 everyone has +20 to month when birth numbers in one day are exhausted if ($year >= 2004 && $this->generator->boolean(10)) { $month += 20; diff --git a/src/Faker/Provider/en_ZA/Person.php b/src/Faker/Provider/en_ZA/Person.php index df018d1514..2d2b525ede 100644 --- a/src/Faker/Provider/en_ZA/Person.php +++ b/src/Faker/Provider/en_ZA/Person.php @@ -135,9 +135,8 @@ class Person extends \Faker\Provider\Person /** * @see https://en.wikipedia.org/wiki/National_identification_number#South_Africa * - * @param \DateTime $birthdate - * @param bool $citizen - * @param string $gender + * @param bool $citizen + * @param string $gender * * @return string */ diff --git a/src/Faker/Provider/fi_FI/Person.php b/src/Faker/Provider/fi_FI/Person.php index 328a44b2c8..bb1c24c06a 100644 --- a/src/Faker/Provider/fi_FI/Person.php +++ b/src/Faker/Provider/fi_FI/Person.php @@ -91,8 +91,7 @@ class Person extends \Faker\Provider\Person * * @see http://www.finlex.fi/fi/laki/ajantasa/2010/20100128 * - * @param \DateTime $birthdate - * @param string $gender Person::GENDER_MALE || Person::GENDER_FEMALE + * @param string $gender Person::GENDER_MALE || Person::GENDER_FEMALE * * @return string on format DDMMYYCZZZQ, where DDMMYY is the date of birth, C the century sign, ZZZ the individual number and Q the control character (checksum) */ diff --git a/src/Faker/Provider/ja_JP/Text.php b/src/Faker/Provider/ja_JP/Text.php index 55bcc62972..9cb9a71ba4 100644 --- a/src/Faker/Provider/ja_JP/Text.php +++ b/src/Faker/Provider/ja_JP/Text.php @@ -628,10 +628,12 @@ protected static function appendEnd($text) $chars = static::split($text); $last = end($chars); } + // if the last char is a not-valid-end punctuation, remove it if (in_array($last, static::$notEndPunct, false)) { $text = preg_replace('/.$/u', '', $text); } + // if the last char is not a valid punctuation, append a default one. return in_array($last, static::$endPunct, false) ? $text : $text . '。'; } diff --git a/src/Faker/Provider/kk_KZ/Company.php b/src/Faker/Provider/kk_KZ/Company.php index 4663a748dd..75efebf836 100644 --- a/src/Faker/Provider/kk_KZ/Company.php +++ b/src/Faker/Provider/kk_KZ/Company.php @@ -54,8 +54,6 @@ public static function companyNameSuffix() * * @see http://egov.kz/wps/portal/Content?contentPath=%2Fegovcontent%2Fbus_business%2Ffor_businessmen%2Farticle%2Fbusiness_identification_number&lang=en * - * @param \DateTime $registrationDate - * * @return string 12 digits, like 150140000019 */ public static function businessIdentificationNumber(\DateTime $registrationDate = null) diff --git a/src/Faker/Provider/kk_KZ/Person.php b/src/Faker/Provider/kk_KZ/Person.php index 61852a2143..353dfae4b1 100644 --- a/src/Faker/Provider/kk_KZ/Person.php +++ b/src/Faker/Provider/kk_KZ/Person.php @@ -207,8 +207,7 @@ private static function getCenturyByYear($year) * @see http://egov.kz/wps/portal/Content?contentPath=%2Fegovcontent%2Fcitizen_migration%2Fpassport_id_card%2Farticle%2Fiin_info&lang=en * @see https://ru.wikipedia.org/wiki/%D0%98%D0%BD%D0%B4%D0%B8%D0%B2%D0%B8%D0%B4%D1%83%D0%B0%D0%BB%D1%8C%D0%BD%D1%8B%D0%B9_%D0%B8%D0%B4%D0%B5%D0%BD%D1%82%D0%B8%D1%84%D0%B8%D0%BA%D0%B0%D1%86%D0%B8%D0%BE%D0%BD%D0%BD%D1%8B%D0%B9_%D0%BD%D0%BE%D0%BC%D0%B5%D1%80 * - * @param \DateTime $birthDate - * @param int $gender + * @param int $gender * * @return string 12 digits, like 780322300455 */ diff --git a/src/Faker/Provider/lt_LT/Person.php b/src/Faker/Provider/lt_LT/Person.php index c448ab814f..570eecfbeb 100644 --- a/src/Faker/Provider/lt_LT/Person.php +++ b/src/Faker/Provider/lt_LT/Person.php @@ -325,9 +325,8 @@ public function passportNumber() * @see https://en.wikipedia.org/wiki/National_identification_number#Lithuania * @see https://lt.wikipedia.org/wiki/Asmens_kodas * - * @param string $gender [male|female] - * @param \DateTime $birthdate - * @param string $randomNumber three integers + * @param string $gender [male|female] + * @param string $randomNumber three integers * * @return string on format XXXXXXXXXXX */ diff --git a/src/Faker/Provider/lv_LV/Person.php b/src/Faker/Provider/lv_LV/Person.php index 4e9b93b75d..2139671788 100644 --- a/src/Faker/Provider/lv_LV/Person.php +++ b/src/Faker/Provider/lv_LV/Person.php @@ -134,8 +134,6 @@ public function passportNumber() * * @see https://en.wikipedia.org/wiki/National_identification_number#Latvia * - * @param \DateTime $birthdate - * * @return string on format XXXXXX-XXXXX */ public function personalIdentityNumber(\DateTime $birthdate = null) diff --git a/src/Faker/Provider/ms_MY/Person.php b/src/Faker/Provider/ms_MY/Person.php index 1cd011bf9f..d685715d8f 100644 --- a/src/Faker/Provider/ms_MY/Person.php +++ b/src/Faker/Provider/ms_MY/Person.php @@ -792,6 +792,7 @@ public static function myKadNumber($gender = null, $hyphen = false) // gender digit. Odd = MALE, Even = FEMALE $g = self::numberBetween(0, 9); + //Credit: https://gist.github.com/mauris/3629548 if ($gender === static::GENDER_MALE) { $g = $g | 1; diff --git a/src/Faker/Provider/nb_NO/Person.php b/src/Faker/Provider/nb_NO/Person.php index 86ce721ba3..8ee85cac72 100644 --- a/src/Faker/Provider/nb_NO/Person.php +++ b/src/Faker/Provider/nb_NO/Person.php @@ -288,8 +288,7 @@ class Person extends \Faker\Provider\Person * * @see https://no.wikipedia.org/wiki/Personnummer * - * @param \DateTime $birthdate - * @param string $gender Person::GENDER_MALE || Person::GENDER_FEMALE + * @param string $gender Person::GENDER_MALE || Person::GENDER_FEMALE * * @return string on format DDMMYY##### */ diff --git a/src/Faker/Provider/ro_RO/Person.php b/src/Faker/Provider/ro_RO/Person.php index d8ef51d005..9077004135 100644 --- a/src/Faker/Provider/ro_RO/Person.php +++ b/src/Faker/Provider/ro_RO/Person.php @@ -182,6 +182,7 @@ protected function getDateOfBirth($dateOfBirth) $dateOfBirthFinal = implode('-', $dateOfBirthParts); $date = \DateTime::createFromFormat('Y-m-d', $dateOfBirthFinal); + //a full (invalid) date might have been supplied, check if it converts if ($date->format('Y-m-d') !== $dateOfBirthFinal) { throw new \InvalidArgumentException("Invalid date of birth - '{$date->format('Y-m-d')}' generated based on '{$dateOfBirth}' received"); diff --git a/src/Faker/Provider/sv_SE/Person.php b/src/Faker/Provider/sv_SE/Person.php index a98f0871bf..1142a1f63f 100644 --- a/src/Faker/Provider/sv_SE/Person.php +++ b/src/Faker/Provider/sv_SE/Person.php @@ -121,8 +121,7 @@ class Person extends \Faker\Provider\Person * * @see http://en.wikipedia.org/wiki/Personal_identity_number_(Sweden) * - * @param \DateTime $birthdate - * @param string $gender Person::GENDER_MALE || Person::GENDER_FEMALE + * @param string $gender Person::GENDER_MALE || Person::GENDER_FEMALE * * @return string on format XXXXXX-XXXX */