Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mybb/standards
MyBB 2.0 Code Standards.
https://github.com/mybb/standards
Last synced: 25 days ago
JSON representation
MyBB 2.0 Code Standards.
- Host: GitHub
- URL: https://github.com/mybb/standards
- Owner: mybb
- License: bsd-3-clause
- Created: 2015-04-21T11:53:31.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-10T08:48:50.000Z (over 9 years ago)
- Last Synced: 2024-10-30T00:54:45.994Z (3 months ago)
- Language: PHP
- Homepage: https://www.mybb.com
- Size: 116 KB
- Stars: 3
- Watchers: 24
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# MyBB 2.0 Coding Standard
This repository contains the coding standard for MyBB 2.0. These files are supposed to be used as a standard for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) and are run automatically against all repositories related to MyBB 2.0.## Standard
PHP code must follow the [PSR-2](http://www.php-fig.org/psr/psr-2/) coding style guide. [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) will be ran against all contributions to ensure that code follows this standard.
In addition to the PSR-2 standard, we have other standards and best practices that must be ahered to:
- All interface names MUST be suffixed with `Interface`. (e.g. `ForumInterface`).
- All abstract class names MUST be prefixed with `Abstract` (e.g. `AbstractForum`).
- All repository class names MUST be suffixed with `Repository` (e.g. `ForumRepository`).
- All factory class names MUST be suffixed with `Factory` (e.g. `ForumFactory`).
- The `Interface` suffix MUST take priority over other suffixes. (e.g. `ForumRepositoryInterface`, `ForumFactoryInterface`.
- Getters MUST be used when retrieving the property of a non-Eloquent object.
- Setters MUST be used when manipulating the property of a non-Eloquent object.
- Properties on an object SHOULD have `protected` or `private` visibility.```php
/**
* @property string magic
*/
class Foo
{
/**
* @var string
*/
protected $bar;
/**
* @return string;
*/
public function getBar()
{
return $this->bar;
}
/**
* @param string $bar
*/
public function setBar($bar)
{
$this->bar = $bar;
}
/**
* @param string $name
*/
public function __get($name)
{
return 'magic';
}
}
```- Methods with a return value and/or arguments MUST have a document block.
- Object properties MUST have a document block with `@var` tag denoting their type.
- Magic properties on an object MUST be declared in a doc block at the top of the class using the `@property` tag.
- Method arguments that are required MUST NOT have a default value.