Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagephp
titleGood commenting Commenting examples
/**
 * A short one line description of the class
 *
 * You can now add a longer description and describe properties that might
 * be found via a magic get or set.
 *
 * @author Your Name <email@example.com>
 * @copyright Copyright (c) 2024 You or your employer
 */
class MyClass
{
	/** @var int A description of what the property stores. */
	protected int $property;

	/**
	 * A property that needs a long explanation
	 *
	 * If a property is complicated you may use a multi-line
	 * doc block for it.
	 *
	 * @var array
	 */
	protected array $data = [];

	/**
	 * A one line description of the method
	 *
	 * An optional longer description of the method if needed.
	 *
	 * You only need to to define @returns if you explicitly use
	 * a return statement.
	 *
	 * @param int $value A description of the value
	 */
	public function set_property(int $value)
	{
		$this->property = $value;
	}

	/**
	 * A one line description of the method
	 *
	 * An optional longer description of the method if needed.
	 *
	 * @returns int An optional text description what is returned when it is not already described.  
	 */
	public function get_property(): int
	{
		return $this->property;
	}
}

...

  • use the file extenstion '.class.php'
  • be located in any of the following locations:
    • <base dir>/classes
    • <base dir>/*/classes
    • <base dir>/plugins/*/classes
  • the main name of the file must be a lowercase version of the class name, for exmple if your class is called MyClass the filename would be myclass.class.php

We expect all classes in ExamSys to autoload

Files

PHP files should only contain php code.

...