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

SquizLabs:
Analysis of Coding Conventions
Jun 10, 2016 @ 00:05:26

On the SquizLabs site they've shares the results of their coding conventions analysis of PHP projects using the PHP_CodeSniffer tool.

PHP_CodeSniffer, using a custom coding standard and report, was used to record various coding conventions across 193 PHP projects.

They've broken it down by the list of rules included in the default coding standards including:

  • Array end comma
  • Class defined in namespace
  • Function has doc comment
  • Adjacent assignments aligned
  • CamelCase method name
  • Line length
  • Spacing before object operator

Each item on the list has the current measurements represented as graphs and a historical view about its previous usage. You can also view per-project statistics for a wide range of PHP related projects.

tagged: squizlabs phpcodesniffer coding conventions report results

Link: http://squizlabs.github.io/PHP_CodeSniffer/analysis/index.html

Vinícius Krolow:
Some tips to improve your codes readability
Jan 25, 2013 @ 15:53:55

In this new post to his site Vinícius Krolow shares some tips he thinks will help to make your PHP code more readable in the long run.

What about code readability, from my point of view is one of the most important thing in the code. Who writes code that is easy to read, writes good code. Probably reading code is where you spent most part of your time, and not only your code, probably code of your team mates, or maybe code from the open source community, so write code that is simple and is easy to understand it’s really important.

His tips (seven of them) are:

  • Comment before write your code (DocBlock)
  • Return frequently, Return early
  • Break, Continue
  • Code Standard / Name conventions
  • Throw Exception
  • Comment often, but not write stupid comments
  • Methods can be always smaller than they are

It's a little difficult to read as the English isn't the speaker's native tongue, but it gets the point across. He also recommends reading this if you'd like more information about writing better OOP code that's easier to read.

tagged: code readability recommendations structure comments conventions

Link:


Trending Topics: