diff --git a/CHANGELOG.md b/CHANGELOG.md index 8735e63d36..ded020890b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased](https://github.com/FakerPHP/Faker/compare/v1.23.0...main) - Fixed polish license plates (#685) +- Stopped using `static` in callables in `Provider\pt_BR\PhoneNumber` (#785) ## [2023-06-12, v1.23.0](https://github.com/FakerPHP/Faker/compare/v1.22.0..v1.23.0) diff --git a/src/Faker/Provider/pt_BR/PhoneNumber.php b/src/Faker/Provider/pt_BR/PhoneNumber.php index 6717def5a5..6601658306 100644 --- a/src/Faker/Provider/pt_BR/PhoneNumber.php +++ b/src/Faker/Provider/pt_BR/PhoneNumber.php @@ -83,7 +83,7 @@ public static function phone($formatted = true) ['landline', null], ]); - return call_user_func("static::{$options[0]}", $formatted, $options[1]); + return call_user_func([static::class, $options[0]], $formatted, $options[1]); } /** @@ -135,7 +135,7 @@ public function phoneNumber() { $method = static::randomElement(['cellphoneNumber', 'landlineNumber']); - return call_user_func("static::$method", true); + return call_user_func([static::class, $method], true); } /** @@ -145,6 +145,6 @@ public static function phoneNumberCleared() { $method = static::randomElement(['cellphoneNumber', 'landlineNumber']); - return call_user_func("static::$method", false); + return call_user_func([static::class, $method], false); } } diff --git a/test/Faker/Provider/pt_BR/PhoneNumberTest.php b/test/Faker/Provider/pt_BR/PhoneNumberTest.php new file mode 100644 index 0000000000..e9118049a2 --- /dev/null +++ b/test/Faker/Provider/pt_BR/PhoneNumberTest.php @@ -0,0 +1,51 @@ +faker->phone(false); + + self::assertIsString($phoneNumber); + self::assertNotEmpty($phoneNumber); + } + + public function testPhoneReturnsPhoneNumberWhenArgumentIsTrue(): void + { + $phoneNumber = $this->faker->phone(true); + + self::assertIsString($phoneNumber); + self::assertNotEmpty($phoneNumber); + } + + public function testPhoneNumberReturnsPhoneNumber(): void + { + $phoneNumber = $this->faker->phoneNumber(); + + self::assertIsString($phoneNumber); + self::assertNotEmpty($phoneNumber); + } + + public function testPhoneNumberClearedReturnsPhoneNumber(): void + { + $phoneNumber = $this->faker->phoneNumberCleared(); + + self::assertIsString($phoneNumber); + self::assertNotEmpty($phoneNumber); + } + + protected function getProviders(): iterable + { + yield new Provider\pt_BR\PhoneNumber($this->faker); + } +}