Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ryanmortier's avatar

Can I omit PHP docblocks if I type hint parameters and return values?

Also, what's the purpose of docblocks? Is it just for IDE helpers and static analysis?

0 likes
2 replies
Tray2's avatar

Docblocks are optional and the same goes for typehints. You don't really need them but some argue that you always should use docblocks and or typehints and some argue against it.

It all comes up to personal preferences unless of course there is a standard at the company or project that says you should use one or both.

Nash's avatar

Docblocks are not solely for giving hints about used types in the source code file. It is used for generating documentation (e.g. using phpDocumentor, Doxygen etc.) and describing/explaining your methods. Whether you choose to use them or not is up to you.

Please or to participate in this conversation.