/
4.4.MethodsAndFunctions.php
49 lines (40 loc) · 1.48 KB
/
4.4.MethodsAndFunctions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
declare(strict_types=1);
namespace LaminasCodingStandardTest\fixed;
class MethodsAndFunctions
{
public function testMethodsAndFunctions($arg1, &$arg2, $arg3 = [])
{
// Visibility MUST be declared on all methods.
//
// Method names MUST NOT be prefixed with a single underscore to indicate
// protected or private visibility. That is, an underscore prefix
// explicitly has no meaning.
//
// Method and function names MUST NOT be declared with space after the
// method name. The opening brace MUST go on its own line, and the
// closing brace MUST go on the next line following the body. There MUST
// NOT be a space after the opening parenthesis, and there MUST NOT be a
// space before the closing parenthesis.
function fooBar($arg1, &$arg2, $arg3 = []): void
{
// function body
}
}
public function testOneSingleLineBetweenMethods(): void
{
// There MUST be a single empty line between methods in a class.
}
public static function testThisMayNotBeCalledInsideStaticFunction(): void
{
// The pseudo-variable `$this` MAY not be called inside a static method
// or function.
echo $this->name;
}
public function testReturnedVariablesShouldBeUseful(): bool
{
// Returned variables SHOULD be useful and not be assign to a value and
// returned on the next line.
return true;
}
}