• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

The Importance of Type Hinting and Parameter Hints

Type Hinting.png

PHP development is best done in an Integrated Development Environment (IDE). I prefer PhpStorm.

Updating to PhpStorm 2017.1 added parameter hints. In particular, it's easy to start typing and type the word parameters. This loads the parameters needed for calling a method. This was used while looking at the updateSessionActivity for the online members widget.

I've also been paying attention to type hinting. Type hinting is adding a comment above a code line or a foreach. Sometimes the type hinting exposes new areas to learn. For example, adding type hinting above the foreach loop in the XenWord online widget lead to a statement that the __toString method was not available. It turned out adding another type hint cleared the error.

One notice still unclear is for the wp_update_user. For some reason the IDE is returning the notice wp_update_user expected Object|\WP_User, got array. Invocation parameter types are not compatible with declared. The development site for WordPress states wp_update_user can accept an array; therefore, this notice is probably a bug in PhpStorm.

Blog entry information

Author
LPH
Views
2,144
Last update

More entries in General

More entries from LPH

Top