PHP

Body

Changes to Drupal coding standards are proposed and discussed in issues in the Coding Standards project.

The Drupal coding standards for PHP.

PHP standards are enforced using PHP_CodeSniffer. The rules used are from that project as well as the Drupal coder project and Slevomat.

 

PHP coding standards

The Drupal Coding Standards apply to code within Drupal and its contributed modules.

API documentation and comment standards

Standards for API documentation blocks in PHP code

API Documentation Examples

This page is intended to be a collection of the complete API documentation examples

Namespaces

Standards having to do with namespaces

Naming standards for services and extending Symfony

Standards for services and Symfony usage

Object-oriented code

Drupal project standards for PHP classes

PHP Exceptions

Basic conventions, exception subclasses, try-catch blocks, inheritance

PSR-4 namespaces and autoloading in Drupal 8

Summary of how Drupal 8 uses the PSR-4 standard for namespace autoloading

Temporary placeholders and delimiters

Standards for what to call delimiters and placeholders in code

Use Drupal Unicode functions for strings

How and why to use Unicode functions for strings

Write E_ALL compliant code

Adjusting the error reporting level

Drupal SimpleTest coding standards

Standards for writing SImpleTest tests prior to Drupal 8

Knowledge Category