mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Contributing: updated example
[ci skip]
This commit is contained in:
parent
51350be190
commit
b3f44562e9
@ -78,17 +78,18 @@ It is mainly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accept
|
|||||||
- Strings SHOULD use the double quote `"` except when the single quote is required.
|
- Strings SHOULD use the double quote `"` except when the single quote is required.
|
||||||
- All code SHOULD have parameter and type declarations where possible.
|
- All code SHOULD have parameter and type declarations where possible.
|
||||||
- Strict types SHOULD be enabled on new files where it is sensible to do so.
|
- Strict types SHOULD be enabled on new files where it is sensible to do so.
|
||||||
|
- All constant declarations SHOULD be preceded by a visibility modifier.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace pocketmine\example;
|
namespace pocketmine\example;
|
||||||
|
|
||||||
class ExampleClass{
|
class ExampleClass{
|
||||||
|
|
||||||
const EXAMPLE_CLASS_CONSTANT = 1;
|
public const EXAMPLE_CLASS_CONSTANT = 1;
|
||||||
|
|
||||||
public $examplePublicVariable = "defaultValue";
|
public $examplePublicVariable = "defaultValue";
|
||||||
private $examplePrivateVariable;
|
private $examplePrivateVariable;
|
||||||
@ -99,7 +100,7 @@ class ExampleClass{
|
|||||||
* @param string $firstArgument the first argument
|
* @param string $firstArgument the first argument
|
||||||
* @param string|null $secondArgument default null
|
* @param string|null $secondArgument default null
|
||||||
*/
|
*/
|
||||||
public function __construct(string $firstArgument, &$secondArgument = null){
|
public function __construct(string $firstArgument, ?string &$secondArgument = null){
|
||||||
if($firstArgument === "exampleValue"){ //Remember to use === instead of == when possible
|
if($firstArgument === "exampleValue"){ //Remember to use === instead of == when possible
|
||||||
//do things
|
//do things
|
||||||
}elseif($firstArgument === "otherValue"){
|
}elseif($firstArgument === "otherValue"){
|
||||||
@ -119,7 +120,6 @@ class ExampleClass{
|
|||||||
public function doStuff(string $stuff) : string{
|
public function doStuff(string $stuff) : string{
|
||||||
return $stuff;
|
return $stuff;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user