Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6d8720d

Browse files
committed
Modernize CS code example
1 parentc710e1e commit6d8720d

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

‎contributing/code/standards.rst‎

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,27 @@ short example containing most features described below::
4747
*/
4848
class FooBar
4949
{
50-
const SOME_CONST = 42;
50+
publicconst SOME_CONST = 42;
5151

5252
/**
5353
* @var string
5454
*/
5555
private $fooBar;
56-
5756
private $qux;
5857

5958
/**
60-
* @paramstring$dummySome argument description
59+
* @param $dummysome argument description
6160
*/
62-
public function __construct($dummy, Qux $qux)
61+
public function __construct(string$dummy, Qux $qux)
6362
{
6463
$this->fooBar = $this->transformText($dummy);
6564
$this->qux = $qux;
6665
}
6766

6867
/**
69-
* @return string
70-
*
7168
* @deprecated
7269
*/
73-
public function someDeprecatedMethod()
70+
public function someDeprecatedMethod(): string
7471
{
7572
trigger_deprecation('symfony/package-name', '5.1', 'The %s() method is deprecated, use Acme\Baz::someMethod() instead.', __METHOD__);
7673

@@ -80,14 +77,11 @@ short example containing most features described below::
8077
/**
8178
* Transforms the input given as the first argument.
8279
*
83-
* @param bool|string $dummy Some argument description
84-
* @param array $options An options collection to be used within the transformation
80+
* @param $options an options collection to be used within the transformation
8581
*
86-
* @return string|null The transformed input
87-
*
88-
* @throws \RuntimeException When an invalid option is provided
82+
* @throws \RuntimeException when an invalid option is provided
8983
*/
90-
private function transformText($dummy, array $options = [])
84+
private function transformText(bool|string$dummy, array $options = []): ?string
9185
{
9286
$defaultOptions = [
9387
'some_default' => 'values',
@@ -100,16 +94,13 @@ short example containing most features described below::
10094
}
10195
}
10296

103-
$mergedOptions = array_merge(
104-
$defaultOptions,
105-
$options
106-
);
97+
$mergedOptions = array_merge($defaultOptions, $options);
10798

10899
if (true === $dummy) {
109100
return 'something';
110101
}
111102

112-
if (is_string($dummy)) {
103+
if (\is_string($dummy)) {
113104
if ('values' === $mergedOptions['some_default']) {
114105
return substr($dummy, 0, 5);
115106
}
@@ -122,11 +113,8 @@ short example containing most features described below::
122113

123114
/**
124115
* Performs some basic operations for a given value.
125-
*
126-
* @param mixed $value Some value to operate against
127-
* @param bool $theSwitch Some switch to control the method's flow
128116
*/
129-
private function performOperations($value = null, $theSwitch = false)
117+
private function performOperations(mixed$value = null, bool $theSwitch = false)
130118
{
131119
if (!$theSwitch) {
132120
return;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp