Skip to content
On this page

trailing-spacefixable

Ensure that there is no trailing whitespace at the end of each line

Examples

  • Examples of correct code for this rule using default options

No trainling whitespace on each line

php
<?php
class Database {
	private $max_connections = 10;
	private $connections = 0;

	/**
	 * Connect to the database.
	 *
	 * @return bool True on success, false on failure
	 */
	public function connect() {
		if ($this->connections < $this->max_connections) {
			$this->connections++;
			return true;
		}
		return false;
	}
}
  • Examples of incorrect code for this rule using default options

Some lines have trailing whitespace

php
<?php
class Database {
	private $max_connections = 10;
	private $connections = 0;
	    
	/**
	 * Connect to the database.
	 *
	 * @return bool True on success, false on failure
	 */
	public function connect() {    
		if ($this->connections < $this->max_connections) {		
			$this->connections++;
			return true;    
		}
		return false;
	}      
}

Released under the MIT License.