Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

David Négrier:
Type-Hint All The Things
Jul 05, 2017 @ 17:52:53

In this new post to his site David Négrier talks about "type hinting all the things" in response to a recent controversy around "clean code" and "visual debt" in PHP code.

Recently, a video about "visual debt" as sparked a lot of controversy in the PHP world. In this article, I'll present the best practices we are using at TheCodingMachine, and a brand new tool we use to enforce those best practices.

If you haven’t seen the video yet, you can have a look at it on Laracast. At some point, the video advocates to remove the type-hints because they are not needed by the program and are "visually polluting" the code.

He then breaks down his look at type hinting and the benefits they can provide into a few sections:

  • Type-hints are good
  • Type-hints have improved (… but there is still a long road to go)
  • Enforcing type-hints

He also covers some of their own best practices when it comes to type hinting in their code and shares a phpstan package that they use to enforce typing and formatting based on their own standards.

tagged: typehint bestpractice visualdebt package phpstan

Link: https://www.thecodingmachine.com/type-hint-all-the-things/


Trending Topics: