4.5 Demonstrate ability to write code using Drupal Coding Standards
Last updated
Last updated
Review Drupal Coding Standards such as line spacing between @doc blocks. Review PHP constants.
A Review of some key .
Use an indent of 2 spaces, with no tabs.
Lines should have no trailing whitespace at the end.
One line space between namespace and use statements same with annotations and classes.
Annotations are formatted docblocks that use to autoload classes into memory. In Drupal 8 they are used for plugin discovery metadata and configuration.
For example the in the core telephone field module annotation block
Coding standards ensure that a team can cohesively work together on maintainable code. A few naming conventions to note are:
classes: UpperCamel
Classes should not use underscores.
methods: lowerCamel
variables: $lowerCamelCase
or $snake_case
PHP constants: always uppercase const CACHE_TEMPORARY = -1;
See more at .