Here's an example PHP code standard that you should follow as closely as you can:
<?php
/**
* Class ExampleClass
*
* This is an example class demonstrating coding standards.
*/
class ExampleClass
{
/** @var string */
private $property;
/**
* Constructor
*
* @param string $value Initial value for the property
*/
public function __construct(string $value)
{
$this->property = $value;
}
/**
* Get the property value
*
* @return string
*/
public function getProperty(): string
{
return $this->property;
}
/**
* Set the property value
*
* @param string $value New value for the property
* @return void
*/
public function setProperty(string $value): void
{
$this->property = $value;
}
/**
* Example method with multiple parameters
*
* @param int $param1 Description of param1
* @param string $param2 Description of param2
* @return bool
*/
public function exampleMethod(int $param1, string $param2): bool
{
if ($param1 > 0 && !empty($param2)) {
return true;
}
return false;
}
}
Key points of this PHP code standard:
Here are some Leaf specific standards that are consistent throughout our codebase: