These are the elements of your php docblock that let other developers know about the type that you expect a function or method parameter to be. Here’s an example: @param array $array in the first function above is the type hint for the array parameter.

As a developer, you have to make a choice about how you want to deal with type safety.

The advantage of doing this over doing nothing is that you don’t have to worry about the type of your parameters.

The point of this article and the example was to show that type safety isn’t a binary decision in the WordPress world.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Community Partners