-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathBasic.correct.php.inc
165 lines (138 loc) · 4.33 KB
/
Basic.correct.php.inc
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php declare(strict_types=1);
namespace Lmc\CodingStandard\Integration\Fixtures;
// NoUnneededImportAliasFixer
use Bar\Foo;
use Some\Other\Namespace\AbstractBasic;
class Basic extends AbstractBasic implements InterfaceFromThisNamespace // FullyQualifiedStrictTypesFixer
{
use SomeUsefulTrait; // OrderedClassElementsFixer
public const FOO = 'foo'; // ClassAttributesSeparationFixer
public const MY_PUBLIC_CONST = 333; // OrderedClassElementsFixer
protected int $myProperty = 666; // OrderedClassElementsFixer
// MagicMethodCasingFixer, OrderedClassElementsFixer
public function __toString(): string
{
return '';
}
public function isEqual($a, ?string $b): ?bool // VisibilityRequiredFixer, CompactNullableTypeDeclarationFixer
{
// TrimArraySpacesFixer
$fooBar = ['a', 'b'];
// NoTrailingCommaInSinglelineFixer
mb_strlen('foobar');
// MbStrFunctionsFixer
$bazLength = mb_strlen('baz');
// LambdaNotUsedImportFixer
$lambdaWithUnusedImport = function () { return 'foo'; };
// NoUselessSprintfFixer
$uselessSprintf = 'bar';
// StrictParamFixer
$useStrictParam = in_array(1337, $fooBar, true);
// NoSpaceAroundDoubleColonFixer
$className = DateTime::class;
// ClassReferenceNameCasingFixer
$date = new \DateTime();
$aliasedClass = new Foo();
// SingleSpaceAfterConstructFixer, StrictComparisonFixer
if ($a === $b || $bazLength !== 3) {
return true;
}
return false; // BlankLineBeforeStatementFixer
}
public function fooBar(mixed $foo): mixed // FunctionDeclarationFixer
{
// MagicConstantCasingFixer
$magicConstant = __DIR__;
$value = 5;
// FunctionDeclarationFixer
$function = function ($foo) use ($value) {
return $foo + $value;
};
// FunctionDeclarationFixer
$fn = fn($foo) => $foo + $value;
// PhpdocToCommentFixer
/*
* Phpdoc used instead of plain comment
*/
if ($foo === 'bar') {
// NoAliasFunctionsFixer
$baz = implode(',', ['foo', 'bar']);
}
$i = 3;
$i += 6; // LongToShorthandOperatorFixer
$i *= 2; // LongToShorthandOperatorFixer
$text = 'foo';
$text .= 'bar'; // LongToShorthandOperatorFixer
switch ($i) {
case 1: // NoUnneededControlParenthesesFixer
$i++;
break;
default:
break;
}
// HeredocIndentationFixer
$heredoc = <<<HEREDOC
This is a
multiline heredoc string. It contains $foo.
It should be indented, though.
HEREDOC;
// HeredocIndentationFixer
$newdoc = <<<'NEWDOC'
This is a $newdoc, where variables are not expanded.
NEWDOC;
// TernaryToElvisOperatorFixer
return ($foo ?: 'not true');
}
public function arrayDeclarations(): void
{
$empty = [];
$singleLineArray = ['foo', 'bar', 'baz'];
$singleLineArray2 = [1, 2, 3];
$multiLineAssociative1 = [
'foo' => 'bar',
'baz' => 'bat',
];
$multiLineAssociative2 = [
'foo' => 'bar',
'baz' => 'bat',
'bak' => 'baz',
];
$multiLineAssociative3 = [
'firstKey' => 'bar',
'thisIsSecondKey' => 'bat',
'third' => 'bat',
];
}
public function emptyFunction1(): void {} // SingleLineEmptyBodyFixer
public function emptyFunction2(
$arg,
): void {} // SingleLineEmptyBodyFixer
// TrailingCommaInMultilineFixer
public function multiline(
$arg1,
$arg2,
$arg3,
): void {
// TrailingCommaInMultilineFixer
$isSet = isset(
$arg1,
$arg2,
$arg3,
);
$sprintf = sprintf(
'%s%s',
'bar',
'baz',
);
foo(
1,
2,
);
}
public function withParameters(
// NullableTypeDeclarationFixer
?string $nullableValue,
// NullableTypeDeclarationForDefaultNullValueFixer
?string $anotherNullableValue = null,
): void {}
}