Skip to content

Commit 8d32135

Browse files
authored
Fix: Do not use static in callables (#785)
* Fix: Add tests * Fix: Do not use static in callables
1 parent 2040bda commit 8d32135

File tree

3 files changed

+55
-3
lines changed

3 files changed

+55
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [Unreleased](https://github.com/FakerPHP/Faker/compare/v1.23.0...main)
44

55
- Fixed polish license plates (#685)
6+
- Stopped using `static` in callables in `Provider\pt_BR\PhoneNumber` (#785)
67

78
## [2023-06-12, v1.23.0](https://github.com/FakerPHP/Faker/compare/v1.22.0..v1.23.0)
89

src/Faker/Provider/pt_BR/PhoneNumber.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static function phone($formatted = true)
8383
['landline', null],
8484
]);
8585

86-
return call_user_func("static::{$options[0]}", $formatted, $options[1]);
86+
return call_user_func([static::class, $options[0]], $formatted, $options[1]);
8787
}
8888

8989
/**
@@ -135,7 +135,7 @@ public function phoneNumber()
135135
{
136136
$method = static::randomElement(['cellphoneNumber', 'landlineNumber']);
137137

138-
return call_user_func("static::$method", true);
138+
return call_user_func([static::class, $method], true);
139139
}
140140

141141
/**
@@ -145,6 +145,6 @@ public static function phoneNumberCleared()
145145
{
146146
$method = static::randomElement(['cellphoneNumber', 'landlineNumber']);
147147

148-
return call_user_func("static::$method", false);
148+
return call_user_func([static::class, $method], false);
149149
}
150150
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Faker\Test\Provider\pt_BR;
6+
7+
use Faker\Provider;
8+
use Faker\Test;
9+
10+
/**
11+
* @covers \Faker\Provider\pt_BR\PhoneNumber
12+
*/
13+
final class PhoneNumberTest extends Test\TestCase
14+
{
15+
public function testPhoneReturnsPhoneNumberWhenArgumentIsFalse(): void
16+
{
17+
$phoneNumber = $this->faker->phone(false);
18+
19+
self::assertIsString($phoneNumber);
20+
self::assertNotEmpty($phoneNumber);
21+
}
22+
23+
public function testPhoneReturnsPhoneNumberWhenArgumentIsTrue(): void
24+
{
25+
$phoneNumber = $this->faker->phone(true);
26+
27+
self::assertIsString($phoneNumber);
28+
self::assertNotEmpty($phoneNumber);
29+
}
30+
31+
public function testPhoneNumberReturnsPhoneNumber(): void
32+
{
33+
$phoneNumber = $this->faker->phoneNumber();
34+
35+
self::assertIsString($phoneNumber);
36+
self::assertNotEmpty($phoneNumber);
37+
}
38+
39+
public function testPhoneNumberClearedReturnsPhoneNumber(): void
40+
{
41+
$phoneNumber = $this->faker->phoneNumberCleared();
42+
43+
self::assertIsString($phoneNumber);
44+
self::assertNotEmpty($phoneNumber);
45+
}
46+
47+
protected function getProviders(): iterable
48+
{
49+
yield new Provider\pt_BR\PhoneNumber($this->faker);
50+
}
51+
}

0 commit comments

Comments
 (0)