diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 804bf79c..856cc782 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ If you've written a new formatter, adapted Faker to a new locale, or fixed a bug Before proposing a pull request, check the following: -* Your code should follow the [PSR-2 coding standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md). Run `make sniff` to check that the coding standards are followed, and use [php-cs-fixer](https://github.com/fabpot/PHP-CS-Fixer) to fix inconsistencies. +* Your code should follow the [PSR-2 coding standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md). Run `make sniff` to check that the coding standards are followed, and run `make fix` to fix inconsistencies. * Unit tests should still pass after your patch. Run the tests on your dev server (with `make test`) or check the continuous integration status for your pull request. * As much as possible, add unit tests for your code * Never use `rand()` in your providers. Faker uses the Mersenne Twister Randomizer, so use `mt_rand()` or any of the base generators (`randomNumber`, `randomElement`, etc.) instead. diff --git a/Makefile b/Makefile index ccfde5cd..bad1dc41 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,10 @@ vendor/autoload.php: composer install --no-interaction --prefer-dist +.PHONY: fix +fix: vendor/autoload.php + vendor/bin/phpcbf --standard=PSR2 src + .PHONY: sniff sniff: vendor/autoload.php vendor/bin/phpcs --standard=PSR2 src -n diff --git a/composer.json b/composer.json index b01b3180..152e1a61 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ }, "require-dev": { "phpunit/phpunit": "^4.8.35 || ^5.7", - "squizlabs/php_codesniffer": "^1.5", + "squizlabs/php_codesniffer": "^2.9.2", "ext-intl": "*" }, "autoload": { diff --git a/src/Faker/ORM/Spot/EntityPopulator.php b/src/Faker/ORM/Spot/EntityPopulator.php index 0ebd6752..bc27e7b0 100644 --- a/src/Faker/ORM/Spot/EntityPopulator.php +++ b/src/Faker/ORM/Spot/EntityPopulator.php @@ -141,7 +141,6 @@ class EntityPopulator foreach ($relations as $relation) { // We don't need any other relation here. if ($relation instanceof BelongsTo) { - $fieldName = $relation->localKey(); $entityName = $relation->entityName(); $field = $fields[$fieldName]; @@ -168,7 +167,6 @@ class EntityPopulator return null; }; - } } diff --git a/src/Faker/Provider/Base.php b/src/Faker/Provider/Base.php index 1415e154..6765c805 100644 --- a/src/Faker/Provider/Base.php +++ b/src/Faker/Provider/Base.php @@ -590,10 +590,10 @@ class Base * * $values = array(); * $evenValidator = function ($digit) { - * return $digit % 2 === 0; + * return $digit % 2 === 0; * }; * for ($i=0; $i < 10; $i++) { - * $values []= $faker->valid($evenValidator)->randomDigit; + * $values []= $faker->valid($evenValidator)->randomDigit; * } * print_r($values); // [0, 4, 8, 4, 2, 6, 0, 8, 8, 6] * diff --git a/src/Faker/Provider/HtmlLorem.php b/src/Faker/Provider/HtmlLorem.php index 9be71bac..6219bc89 100644 --- a/src/Faker/Provider/HtmlLorem.php +++ b/src/Faker/Provider/HtmlLorem.php @@ -90,7 +90,7 @@ class HtmlLorem extends Base private function addRandomLeaf(\DOMElement $node) { $rand = mt_rand(1, 10); - switch($rand){ + switch ($rand) { case 1: $this->addRandomP($node); break; @@ -172,7 +172,6 @@ class HtmlLorem extends Base $node = $element->ownerDocument->createElement($h); $node->appendChild($text); $element->appendChild($node); - } private function addRandomB(\DOMElement $element, $maxLength = 10) diff --git a/src/Faker/Provider/en_US/Payment.php b/src/Faker/Provider/en_US/Payment.php index a4ba79e5..a9248ad8 100644 --- a/src/Faker/Provider/en_US/Payment.php +++ b/src/Faker/Provider/en_US/Payment.php @@ -3,7 +3,6 @@ namespace Faker\Provider\en_US; - class Payment extends \Faker\Provider\Payment { public function bankAccountNumber() diff --git a/src/Faker/Provider/ka_GE/Company.php b/src/Faker/Provider/ka_GE/Company.php index 888386a7..c2ccb40a 100644 --- a/src/Faker/Provider/ka_GE/Company.php +++ b/src/Faker/Provider/ka_GE/Company.php @@ -2,7 +2,6 @@ namespace Faker\Provider\ka_GE; - class Company extends \Faker\Provider\Company { protected static $companyPrefixes = array( diff --git a/src/Faker/Provider/mn_MN/Person.php b/src/Faker/Provider/mn_MN/Person.php index 8a0b8206..3042b5bb 100644 --- a/src/Faker/Provider/mn_MN/Person.php +++ b/src/Faker/Provider/mn_MN/Person.php @@ -72,7 +72,7 @@ class Person extends \Faker\Provider\Person /** * Generate an identification number. - * + * * @example ИЙ92011412 */ public function idNumber() diff --git a/src/Faker/Provider/ms_MY/Address.php b/src/Faker/Provider/ms_MY/Address.php index 5ec2f751..1ad7d44b 100644 --- a/src/Faker/Provider/ms_MY/Address.php +++ b/src/Faker/Provider/ms_MY/Address.php @@ -67,7 +67,7 @@ class Address extends \Faker\Provider\Address /** * 'Jalan' & 'Jln' are more frequently used than 'Lorong' - * + * * @link https://en.wikipedia.org/wiki/List_of_roads_in_Kuala_Lumpur#Standard_translations */ protected static $streetPrefix = array( @@ -117,7 +117,7 @@ class Address extends \Faker\Provider\Address /** * 'Bandar' and 'Taman' are the most common township prefix - * + * * @link https://en.wikipedia.org/wiki/Template:Greater_Kuala_Lumpur > Townships * @link https://en.wikipedia.org/wiki/Template:Johor > Townships * @link https://en.wikipedia.org/wiki/Template:Kedah > Townships @@ -497,9 +497,9 @@ class Address extends \Faker\Provider\Address /** * Return a building prefix - * + * * @example 'No.' - * + * * @return @string */ public static function buildingPrefix() @@ -509,9 +509,9 @@ class Address extends \Faker\Provider\Address /** * Return a building number - * + * * @example '123' - * + * * @return @string */ public static function buildingNumber() @@ -521,7 +521,7 @@ class Address extends \Faker\Provider\Address /** * Return a street prefix - * + * * @example 'Jalan' */ public function streetPrefix() @@ -533,9 +533,9 @@ class Address extends \Faker\Provider\Address /** * Return a complete streename - * + * * @example 'Jalan Utama 7' - * + * * @return @string */ public function streetName() @@ -547,9 +547,9 @@ class Address extends \Faker\Provider\Address /** * Return a randown township - * + * * @example Taman Bahagia - * + * * @return @string */ public function township() @@ -561,9 +561,9 @@ class Address extends \Faker\Provider\Address /** * Return a township prefix abbreviation - * + * * @example 'USJ' - * + * * @return @string */ public function townshipPrefixAbbr() @@ -573,9 +573,9 @@ class Address extends \Faker\Provider\Address /** * Return a township prefix - * + * * @example 'Taman' - * + * * @return @string */ public function townshipPrefix() @@ -585,7 +585,7 @@ class Address extends \Faker\Provider\Address /** * Return a township suffix - * + * * @example 'Bahagia' */ public function townshipSuffix() @@ -595,12 +595,12 @@ class Address extends \Faker\Provider\Address /** * Return a postcode based on state - * + * * @example '55100' * @link https://en.wikipedia.org/wiki/Postal_codes_in_Malaysia#States - * + * * @param null|string $state 'state' or null - * + * * @return @string */ public static function postcode($state = null) @@ -665,9 +665,9 @@ class Address extends \Faker\Provider\Address /** * Return the complete town address with matching postcode and state - * + * * @example 55100 Bukit Bintang, Kuala Lumpur - * + * * @return @string */ public function townState() @@ -682,9 +682,9 @@ class Address extends \Faker\Provider\Address /** * Return a random city (town) - * + * * @example 'Ampang' - * + * * @return @string */ public function city() @@ -695,9 +695,9 @@ class Address extends \Faker\Provider\Address /** * Return a random state - * + * * @example 'Johor' - * + * * @return @string */ public function state() diff --git a/src/Faker/Provider/ms_MY/Company.php b/src/Faker/Provider/ms_MY/Company.php index f2e2f5f4..0e681330 100644 --- a/src/Faker/Provider/ms_MY/Company.php +++ b/src/Faker/Provider/ms_MY/Company.php @@ -13,7 +13,7 @@ class Company extends \Faker\Provider\Company /** * There are more Private Limited Companies(Sdn Bhd) than Public Listed Companies(Berhad) - * + * * @link http://www.risscorporateservices.com/types-of-business-entities.html */ protected static $companySuffix = array( @@ -85,7 +85,7 @@ class Company extends \Faker\Provider\Company /** * Return a random company name - * + * * @example 'AirAsia' */ public static function companyName() @@ -95,7 +95,7 @@ class Company extends \Faker\Provider\Company /** * Return a random industry - * + * * @example 'Automobil' */ public static function industry() diff --git a/src/Faker/Provider/ms_MY/Miscellaneous.php b/src/Faker/Provider/ms_MY/Miscellaneous.php index 22efd33b..b42c6685 100644 --- a/src/Faker/Provider/ms_MY/Miscellaneous.php +++ b/src/Faker/Provider/ms_MY/Miscellaneous.php @@ -22,7 +22,7 @@ class Miscellaneous extends \Faker\Provider\Miscellaneous /** * Some alphabet has higher frequency that coincides with the current number * of registrations. E.g. W = Wilayah Persekutuan - * + * * @link https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Malaysia#Current_format */ protected static $peninsularPrefix = array( @@ -71,7 +71,7 @@ class Miscellaneous extends \Faker\Provider\Miscellaneous /** * Chances of having an empty alphabet will be 1/24 - * + * * @link https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Malaysia#Current_format */ protected static $validAlphabets = array( @@ -83,9 +83,9 @@ class Miscellaneous extends \Faker\Provider\Miscellaneous /** * Return a valid Malaysia JPJ(Road Transport Department) vehicle licence plate number - * + * * @example 'WKN 2368' - * + * * @return @string */ public function jpjNumberPlate() @@ -97,9 +97,9 @@ class Miscellaneous extends \Faker\Provider\Miscellaneous /** * Return Peninsular prefix alphabet - * + * * @example 'W' - * + * * @return @string */ public static function peninsularPrefix() @@ -109,9 +109,9 @@ class Miscellaneous extends \Faker\Provider\Miscellaneous /** * Return Sarawak state prefix alphabet - * + * * @example 'QA' - * + * * @return @string */ public static function sarawakPrefix() @@ -121,9 +121,9 @@ class Miscellaneous extends \Faker\Provider\Miscellaneous /** * Return Sabah state prefix alphabet - * + * * @example 'SA' - * + * * @return @string */ public static function sabahPrefix() @@ -133,9 +133,9 @@ class Miscellaneous extends \Faker\Provider\Miscellaneous /** * Return specialty licence plate prefix - * + * * @example 'G1M' - * + * * @return @string */ public static function specialPrefix() @@ -145,9 +145,9 @@ class Miscellaneous extends \Faker\Provider\Miscellaneous /** * Return a valid license plate alphabet - * + * * @example 'A' - * + * * @return @string */ public static function validAlphabet() @@ -157,9 +157,9 @@ class Miscellaneous extends \Faker\Provider\Miscellaneous /** * Return a valid number sequence between 1 and 9999 - * + * * @example '1234' - * + * * @return @integer */ public static function numberSequence() diff --git a/src/Faker/Provider/ms_MY/Payment.php b/src/Faker/Provider/ms_MY/Payment.php index b70a590f..4a46af16 100644 --- a/src/Faker/Provider/ms_MY/Payment.php +++ b/src/Faker/Provider/ms_MY/Payment.php @@ -144,9 +144,9 @@ class Payment extends \Faker\Provider\Payment /** * Return a Malaysian Bank - * + * * @example 'Maybank' - * + * * @return @string */ public function bank() @@ -158,9 +158,9 @@ class Payment extends \Faker\Provider\Payment /** * Return a Malaysian Bank account number - * + * * @example '1234567890123456' - * + * * @return @string */ public function bankAccountNumber() @@ -172,9 +172,9 @@ class Payment extends \Faker\Provider\Payment /** * Return a Malaysian Local Bank - * + * * @example 'Public Bank' - * + * * @return @string */ public static function localBank() @@ -184,9 +184,9 @@ class Payment extends \Faker\Provider\Payment /** * Return a Malaysian Foreign Bank - * + * * @example 'Citibank Berhad' - * + * * @return @string */ public static function foreignBank() @@ -196,9 +196,9 @@ class Payment extends \Faker\Provider\Payment /** * Return a Malaysian Government Bank - * + * * @example 'Bank Simpanan Nasional' - * + * * @return @string */ public static function governmentBank() @@ -208,9 +208,9 @@ class Payment extends \Faker\Provider\Payment /** * Return a Malaysian insurance company - * + * * @example 'AIA Malaysia' - * + * * @return @string */ public static function insurance() @@ -220,9 +220,9 @@ class Payment extends \Faker\Provider\Payment /** * Return a Malaysian Bank SWIFT Code - * + * * @example 'MBBEMYKLXXX' - * + * * @return @string */ public static function swiftCode() @@ -232,9 +232,9 @@ class Payment extends \Faker\Provider\Payment /** * Return the Malaysian currency symbol - * + * * @example 'RM' - * + * * @return @string */ public static function currencySymbol() diff --git a/src/Faker/Provider/ms_MY/Person.php b/src/Faker/Provider/ms_MY/Person.php index b38ffa70..28d1092a 100644 --- a/src/Faker/Provider/ms_MY/Person.php +++ b/src/Faker/Provider/ms_MY/Person.php @@ -160,12 +160,12 @@ class Person extends \Faker\Provider\Person /** * Note: The empty elements are for names without the title, chances increase by number of empty elements. - * + * * @link https://en.wikipedia.org/wiki/Muhammad_(name) */ protected static $muhammadName = array('', '', '', '', 'Mohamad ','Mohamed ','Mohammad ','Mohammed ','Muhamad ','Muhamed ','Muhammad ','Muhammed ','Muhammet ','Mohd '); /** - * + * * @link https://en.wikipedia.org/wiki/Noor_(name) */ protected static $nurName = array('', '', '', '', 'Noor ', 'Nor ', 'Nur ', 'Nur ', 'Nur ', 'Nurul ','Nuur '); @@ -183,10 +183,10 @@ class Person extends \Faker\Provider\Person /** * Chinese family name or surname - * + * * @link https://en.wikipedia.org/wiki/List_of_common_Chinese_surnames * @link https://en.wikipedia.org/wiki/Hundred_Family_Surnames - * + * */ protected static $lastNameChinese = array( 'An','Ang','Au','Au-Yong','Aun','Aw', @@ -218,7 +218,7 @@ class Person extends \Faker\Provider\Person /** * Chinese second character - * + * * @link https://en.wikipedia.org/wiki/Chinese_given_name * @link https://en.wikipedia.org/wiki/List_of_Malaysians_of_Chinese_descent * @link https://en.wikipedia.org/wiki/Category:Malaysian_people_of_Cantonese_descent @@ -276,7 +276,7 @@ class Person extends \Faker\Provider\Person /** * Chinese male third character - * + * * @link https://en.wikipedia.org/wiki/Chinese_given_name * @link https://en.wikipedia.org/wiki/List_of_Malaysians_of_Chinese_descent * @link https://en.wikipedia.org/wiki/Category:Malaysian_people_of_Cantonese_descent @@ -332,7 +332,7 @@ class Person extends \Faker\Provider\Person /** * Chinese female third character - * + * * @link https://en.wikipedia.org/wiki/Chinese_given_name * @link https://en.wikipedia.org/wiki/List_of_Malaysians_of_Chinese_descent * @link https://en.wikipedia.org/wiki/Category:Malaysian_people_of_Cantonese_descent @@ -542,9 +542,9 @@ class Person extends \Faker\Provider\Person /** * Return a Malay male first name - * + * * @example 'Ahmad' - * + * * @return string */ public static function firstNameMaleMalay() @@ -554,9 +554,9 @@ class Person extends \Faker\Provider\Person /** * Return a Malay female first name - * + * * @example 'Adibah' - * + * * @return string */ public static function firstNameFemaleMalay() @@ -566,9 +566,9 @@ class Person extends \Faker\Provider\Person /** * Return a Malay last name - * + * * @example 'Abdullah' - * + * * @return string */ public function lastNameMalay() @@ -578,9 +578,9 @@ class Person extends \Faker\Provider\Person /** * Return a Malay male 'Muhammad' name - * + * * @example 'Muhammad' - * + * * @return string */ public static function muhammadName() @@ -590,9 +590,9 @@ class Person extends \Faker\Provider\Person /** * Return a Malay female 'Nur' name - * + * * @example 'Nur' - * + * * @return string */ public static function nurName() @@ -602,9 +602,9 @@ class Person extends \Faker\Provider\Person /** * Return a Malay male 'Haji' title - * + * * @example 'Haji' - * + * * @return string */ public static function haji() @@ -614,9 +614,9 @@ class Person extends \Faker\Provider\Person /** * Return a Malay female 'Hajjah' title - * + * * @example 'Hajjah' - * + * * @return string */ public static function hajjah() @@ -626,9 +626,9 @@ class Person extends \Faker\Provider\Person /** * Return a Malay title - * + * * @example 'Syed' - * + * * @return string */ public static function titleMaleMalay() @@ -638,9 +638,9 @@ class Person extends \Faker\Provider\Person /** * Return a Chinese last name - * + * * @example 'Lim' - * + * * @return string */ public static function lastNameChinese() @@ -650,9 +650,9 @@ class Person extends \Faker\Provider\Person /** * Return a Chinese male first name - * + * * @example 'Goh Tong' - * + * * @return string */ public static function firstNameMaleChinese() @@ -662,9 +662,9 @@ class Person extends \Faker\Provider\Person /** * Return a Chinese female first name - * + * * @example 'Mew Choo' - * + * * @return string */ public static function firstNameFemaleChinese() @@ -674,9 +674,9 @@ class Person extends \Faker\Provider\Person /** * Return a Christian male name - * + * * @example 'Aaron' - * + * * @return string */ public static function firstNameMaleChristian() @@ -686,9 +686,9 @@ class Person extends \Faker\Provider\Person /** * Return a Christian female name - * + * * @example 'Alice' - * + * * @return string */ public static function firstNameFemaleChristian() @@ -698,9 +698,9 @@ class Person extends \Faker\Provider\Person /** * Return an Indian initial - * + * * @example 'S. ' - * + * * @return string */ public static function initialIndian() @@ -710,9 +710,9 @@ class Person extends \Faker\Provider\Person /** * Return an Indian male first name - * + * * @example 'Arumugam' - * + * * @return string */ public static function firstNameMaleIndian() @@ -722,9 +722,9 @@ class Person extends \Faker\Provider\Person /** * Return an Indian female first name - * + * * @example 'Ambiga' - * + * * @return string */ public static function firstNameFemaleIndian() @@ -734,9 +734,9 @@ class Person extends \Faker\Provider\Person /** * Return an Indian last name - * + * * @example 'Subramaniam' - * + * * @return string */ public static function lastNameIndian() @@ -746,9 +746,9 @@ class Person extends \Faker\Provider\Person /** * Return a random last name - * + * * @example 'Lee' - * + * * @return string */ public function lastName() @@ -764,14 +764,14 @@ class Person extends \Faker\Provider\Person /** * Return a Malaysian I.C. No. - * + * * @example '890123-45-6789' - * + * * @link https://en.wikipedia.org/wiki/Malaysian_identity_card#Structure_of_the_National_Registration_Identity_Card_Number_(NRIC) - * + * * @param string|null $gender 'male', 'female' or null for any * @param bool|string|null $hyphen true, false, or any separator characters - * + * * @return string */ public static function myKadNumber($gender = null, $hyphen = false) @@ -804,7 +804,7 @@ class Person extends \Faker\Provider\Person // formatting with hyphen if ($hyphen === true) { $hyphen = "-"; - } else if ($hyphen === false) { + } elseif ($hyphen === false) { $hyphen = ""; } diff --git a/src/Faker/Provider/ms_MY/PhoneNumber.php b/src/Faker/Provider/ms_MY/PhoneNumber.php index ad199c0d..f89111d9 100644 --- a/src/Faker/Provider/ms_MY/PhoneNumber.php +++ b/src/Faker/Provider/ms_MY/PhoneNumber.php @@ -88,12 +88,12 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber /** * Return a Malaysian Mobile Phone Number. - * + * * @example '+6012-345-6789' - * + * * @param bool $countryCodePrefix true, false * @param bool $formatting true, false - * + * * @return string */ public function mobileNumber($countryCodePrefix = true, $formatting = true) @@ -113,9 +113,9 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber /** * Return prefix digits for 011 numbers - * + * * @example '10' - * + * * @return string */ public static function zeroOneOnePrefix() @@ -125,9 +125,9 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber /** * Return prefix digits for 014 numbers - * + * * @example '2' - * + * * @return string */ public static function zeroOneFourPrefix() @@ -137,9 +137,9 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber /** * Return prefix digits for 015 numbers - * + * * @example '1' - * + * * @return string */ public static function zeroOneFivePrefix() @@ -149,12 +149,12 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber /** * Return a Malaysian Fixed Line Phone Number. - * + * * @example '+603-4567-8912' - * + * * @param bool $countryCodePrefix true, false * @param bool $formatting true, false - * + * * @return string */ public function fixedLineNumber($countryCodePrefix = true, $formatting = true) @@ -174,12 +174,12 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber /** * Return a Malaysian VoIP Phone Number. - * + * * @example '+6015-678-9234' - * + * * @param bool $countryCodePrefix true, false * @param bool $formatting true, false - * + * * @return string */ public function voipNumber($countryCodePrefix = true, $formatting = true) @@ -199,11 +199,11 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber /** * Return a Malaysian Country Code Prefix. - * + * * @example '+6' - * + * * @param bool $formatting true, false - * + * * @return string */ public static function countryCodePrefix($formatting = true) diff --git a/src/Faker/Provider/nb_NO/Person.php b/src/Faker/Provider/nb_NO/Person.php index c95410b7..56d68837 100644 --- a/src/Faker/Provider/nb_NO/Person.php +++ b/src/Faker/Provider/nb_NO/Person.php @@ -300,7 +300,7 @@ class Person extends \Faker\Provider\Person */ $randomDigits = (string)static::numerify('##'); - switch($gender) { + switch ($gender) { case static::GENDER_MALE: $genderDigit = static::randomElement(array(1,3,5,7,9)); break; diff --git a/src/Faker/Provider/nl_NL/Company.php b/src/Faker/Provider/nl_NL/Company.php index 3185b894..71b12819 100644 --- a/src/Faker/Provider/nl_NL/Company.php +++ b/src/Faker/Provider/nl_NL/Company.php @@ -26,7 +26,6 @@ class Company extends \Faker\Provider\Company public static function vat() { return sprintf("%s%d%s%d", 'NL', self::randomNumber(9, true), 'B', self::randomNumber(2, true)); - } /** diff --git a/src/Faker/Provider/nl_NL/Person.php b/src/Faker/Provider/nl_NL/Person.php index 5c9c33b3..651b0825 100644 --- a/src/Faker/Provider/nl_NL/Person.php +++ b/src/Faker/Provider/nl_NL/Person.php @@ -342,7 +342,6 @@ class Person extends \Faker\Provider\Person } else { $nr[0] = 1; $nr[1]++; - } } return implode('', array_reverse($nr));