diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 2168129d7fa..6860e0fbecf 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -37,6 +37,9 @@ example containing most features described below: { const SOME_CONST = 42; + /** + * @var string + */ private $fooBar; /** @@ -48,20 +51,30 @@ example containing most features described below: } /** - * @param string $dummy Some argument description - * @param array $options + * Transforms the input given as first argument. + * + * @param bool|string $dummy Some argument description + * @param array $options An options collection to be used within the transformation * - * @return string|null Transformed input + * @return string|null The transformed input * - * @throws \RuntimeException + * @throws \RuntimeException When an invalid option is provided */ private function transformText($dummy, array $options = array()) { + $defaultOptions = array( + 'some_default' => 'values', + 'another_default' => 'more values', + ); + + foreach ($options as $option) { + if (!in_array($option, $defaultOptions)) { + throw new \RuntimeException(sprintf('Unrecognized option "%s"', $option)); + } + } + $mergedOptions = array_merge( - array( - 'some_default' => 'values', - 'another_default' => 'more values', - ), + $defaultOptions, $options ); @@ -76,10 +89,16 @@ example containing most features described below: return ucwords($dummy); } - - throw new \RuntimeException(sprintf('Unrecognized dummy option "%s"', $dummy)); } + /** + * Performs some basic check for a given value. + * + * @param mixed $value Some value to check against + * @param bool $theSwitch Some switch to control the method's flow + * + * @return bool|null The resultant check if $theSwitch isn't false, null otherwise + */ private function reverseBoolean($value = null, $theSwitch = false) { if (!$theSwitch) {