Using Types in PHP is one of the least used features, but very powerful features available in PHP. This is a feature that can save you and other developers a whole lot of stress (if you work with a team).

Of course, you can write function descriptions, but it becomes quite a daunting task to write function descriptions for all your functions and variables in a large project.

When someone else wants to use your function or even you want to use it after a couple of weeks later, it needs to check the function’s body to recognize which types you should pass to the function while using, if you don’t specify arguments types.


function getItem(array $item) {
return allItems()[$item[0]];

This will make sure that whatever is passed in here is the type needed. You can read more from

For more tips:

Leave a Reply

Your email address will not be published. Required fields are marked *