Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown formatter "catchPhrase" #310

Closed
laraluke opened this issue Apr 13, 2021 · 7 comments
Closed

Unknown formatter "catchPhrase" #310

laraluke opened this issue Apr 13, 2021 · 7 comments
Labels
bug Something isn't working enhancement New feature or request lifecycle/stale

Comments

@laraluke
Copy link

Summary

After updating to 1.14.1 ->catchPhrase now throws the following error:

Unknown formatter "catchPhrase"

After brief investigations I believe it has been caused by the following commit affecting Laravel app's with faker_locale set to en_GB

7e6c6b0#diff-c65f89c9fc1f2402100a21efa32250b826e08a21c73aa1c84a6d023523132795

Versions

Version
PHP 7.4.14
fakerphp/faker 1.14.1

Self-enclosed code snippet for reproduction

$this->faker->catchPhrase

Expected output

'Some catch phrase'

Actual output

InvalidArgumentException 

Unknown formatter "catchPhrase"
@pimjansen
Copy link

As far as i know this has always been a locale specific method for en_US and never for the GB locale here.

So i do not really think it is a bug

@laraluke
Copy link
Author

@pimjansen it has definitely been available to en_GB as I use it in most of my Laravel applications.

It was working before I updated to the latest version today.

@pimjansen
Copy link

The en_GB locale only has a new Company class since january 2021. Before this it did not even exist and that class never had a catchPhrase method. It only exists in the en_US locale.

Therefor i also do not see this as a bug.

@laraluke
Copy link
Author

@pimjansen The commit I referenced did include the new en_GB Company class as you say, which is the problem.

The class didn't exist before this commit which meant that the default fallback was the en_US Company class as shown here:

https://github.com/FakerPHP/Faker/blob/main/src/Faker/Factory.php#L7

So before the new en_GB Company class was created ->catchPhrase worked as it fell back to en_US, but the newly created en_GB doesn't contain this method - causing the issue.

@laraluke
Copy link
Author

I believe that ->catchPhrase will be used in many other Laravel applications with the locale set to en_GB - so I propose that this method is moved into either the base Company class or added to the en_GB class too.

I'd be happy to submit a PR with either of the above solutions.

@pimjansen pimjansen reopened this Apr 14, 2021
@pimjansen
Copy link

Feel free to raise a PR for this. Meaning implementing the catchPhrase methods on the en_GB provider if needed. Please note that we do not want linking between the locales itself.

@pimjansen pimjansen added bug Something isn't working enhancement New feature or request labels Apr 14, 2021
@stale
Copy link

stale bot commented Apr 28, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 1 week if no further activity occurs. Thank you for your contributions.

@stale stale bot closed this as completed May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request lifecycle/stale
Projects
None yet
Development

No branches or pull requests

2 participants