Skip to content

summaryfixable

Ensure that docblocks have a short summary and that is properly formatted

Examples

  • Examples of correct code for this rule using default options

Class and methods with short summary

php
<?php

/**
 * Manage and handle database connections.
 */
class DatabaseConnect {
	
	/**
	 * Connect to the database.
	 *
	 * @param string $host Hostname of the database server
	 * @param string $username Username to connect with
	 * @param string $password Password to connect with
	 * @param string $database Database to connect to
	 * @return bool True on success, false on failure
	 */
	public function connect($host, $username, $password, $database) {
		$this->connection = mysql_connect($host, $username, $password);
		if (!$this->connection) {
			return false;
		}
		if (!mysql_select_db($database, $this->connection)) {
			return false;
		}
		return true;
	}
}

Functions with short summary

php
<?php
/**
 * Get data from API endpoint.
 * 
 * @param string $endpoint API endpoint
 * @return string Data from API
 */
function get_data($endpoint){
	// Connect and return data
	return $data;
}

/**
 * Disconnect from database.
 */
function disconnect(){
	echo "Disconnecting...";
}

function no_docblock(){
	echo "This function will be ignored by this rule.";
}

/* This is a non docblock comment and will be ignored by this rule */
function non_docblock_comment(){
	echo "This function will be ignored by this rule.";
}
  • Examples of incorrect code for this rule using default options

Functions missing short summary

php
<?php
/**
 *
 *
 * @param string $endpoint API endpoint
 * @return string Data from API
 */
function get_data($endpoint) {
    // Connect and return data
    return $data;
}

/**
 * This short summary is not ending with a dot
 */
function disconnect() {
    echo "Disconnecting...";
}

Released under the MIT License.