Skip to content

Commit de9f987

Browse files
committed
minor #5560 [2.3] [Contributing] [CS] Added missing docblocks in code snippet (phansys)
This PR was submitted for the 2.7 branch but it was merged into the 2.3 branch instead (closes #5560). Discussion ---------- [2.3] [Contributing] [CS] Added missing docblocks in code snippet | Q | A | ------------- | --- | Doc fix? | no | New docs? | no | Applies to | | Fixed tickets | Commits ------- 8395e66 [2.3] [Contributing] [CS] Added missing docblocks in code snippet
2 parents dea153c + 8395e66 commit de9f987

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

contributing/code/standards.rst

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ example containing most features described below:
3737
{
3838
const SOME_CONST = 42;
3939
40+
/**
41+
* @var string
42+
*/
4043
private $fooBar;
4144
4245
/**
@@ -48,20 +51,30 @@ example containing most features described below:
4851
}
4952
5053
/**
51-
* @param string $dummy Some argument description
52-
* @param array $options
54+
* Transforms the input given as first argument.
55+
*
56+
* @param bool|string $dummy Some argument description
57+
* @param array $options An options collection to be used within the transformation
5358
*
54-
* @return string|null Transformed input
59+
* @return string|null The transformed input
5560
*
56-
* @throws \RuntimeException
61+
* @throws \RuntimeException When an invalid option is provided
5762
*/
5863
private function transformText($dummy, array $options = array())
5964
{
65+
$defaultOptions = array(
66+
'some_default' => 'values',
67+
'another_default' => 'more values',
68+
);
69+
70+
foreach ($options as $option) {
71+
if (!in_array($option, $defaultOptions)) {
72+
throw new \RuntimeException(sprintf('Unrecognized option "%s"', $option));
73+
}
74+
}
75+
6076
$mergedOptions = array_merge(
61-
array(
62-
'some_default' => 'values',
63-
'another_default' => 'more values',
64-
),
77+
$defaultOptions,
6578
$options
6679
);
6780

@@ -76,10 +89,16 @@ example containing most features described below:
7689

7790
return ucwords($dummy);
7891
}
79-
80-
throw new \RuntimeException(sprintf('Unrecognized dummy option "%s"', $dummy));
8192
}
8293

94+
/**
95+
* Performs some basic check for a given value.
96+
*
97+
* @param mixed $value Some value to check against
98+
* @param bool $theSwitch Some switch to control the method's flow
99+
*
100+
* @return bool|null The resultant check if $theSwitch isn't false, null otherwise
101+
*/
83102
private function reverseBoolean($value = null, $theSwitch = false)
84103
{
85104
if (!$theSwitch) {

0 commit comments

Comments
 (0)