logo
podcast Podcast
get help Get Unstuck

Use Faker methods instead of properties

Another thing I see a lot of

Joel Clermont
Joel Clermont
2025-05-14

Maybe you can tell I've been doing a bunch of code reviews lately.

Here's another pretty basic tip, but one I see ignored quite frequently in real-world projects.

Older versions of Faker used dynamic properties to generate fake data. For example, $faker->name would return a random name.

Then they added support for method calls, like $faker->name().

You might think this is just a stylistic choice, since both options continue to work. But the property syntax is deprecated since Faker v1.14.0 (which came out way back in 2021) and will be removed in a future version.

Property access also triggers deprecation warnings, so it's a good idea to clean up your factories now and not rely on the older syntax.

Here to help,

Joel

P.S. Do you want some help on your project? Would you like to work with devs that pay attention to even the small details? We can help.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice you can use.