...
Some existing classes, files and functions have no docs, use a bad style, do not have a boilerplate or contain commented out code so code sniffer will warn about it. However, new files will be expected to follow this and we should attempt to update existing code where possible.
Code Block | ||||
---|---|---|---|---|
| ||||
/**
* 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 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;
}
} |
Page Parameters
$_GET, $_POST and $_REQUEST super globals must not be accessed directly. Instead values passed to them should be access via param::required(), param::optional() or check_var()
If param::required() is used the code must handle the exception that will occur if it is not set.
check_var() will automatically display a message and terminate the script if a required parameter is not present
param::optional() allows a value other than null to be returned if it is not set, so is recommended over check_var() for parameters that are not required.
...