Skip to content

Commit eee4109

Browse files
committed
Merge pull request #1393 from WouterJ/improve_cs_example
[Contributing] Improved CS
2 parents 240cf46 + 10e7bd5 commit eee4109

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

contributing/code/standards.rst

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,40 @@ example containing most features described below:
3030
3131
namespace Acme;
3232
33-
class Foo
33+
class FooBar
3434
{
3535
const SOME_CONST = 42;
3636
37-
private $foo;
37+
private $fooBar;
3838
3939
/**
4040
* @param string $dummy Some argument description
4141
*/
4242
public function __construct($dummy)
4343
{
44-
$this->foo = $this->transform($dummy);
44+
$this->fooBar = $this->transform($dummy);
4545
}
4646
4747
/**
4848
* @param string $dummy Some argument description
4949
* @return string|null Transformed input
5050
*/
51-
private function transform($dummy)
51+
private function transformText($dummy, $options = array())
5252
{
53+
$mergedOptions = array_merge($options, array(
54+
'some_default' => 'values',
55+
));
56+
5357
if (true === $dummy) {
5458
return;
5559
}
5660
if ('string' === $dummy) {
57-
$dummy = substr($dummy, 0, 5);
58-
}
61+
if ('values' === $mergedOptions['some_default']) {
62+
$dummy = substr($dummy, 0, 5);
63+
} else {
64+
$dummy = ucwords($dummy);
65+
}
66+
}
5967
6068
return $dummy;
6169
}
@@ -74,9 +82,6 @@ Structure
7482
* Use braces to indicate control structure body regardless of the number of
7583
statements it contains;
7684

77-
* Declare visibility explicitly for class, methods, and properties (usage of
78-
`var` is prohibited);
79-
8085
* Define one class per file - this does not apply to private helper classes
8186
that are not intended to be instantiated from the outside and thus are not
8287
concerned by the PSR-0 standard;

0 commit comments

Comments
 (0)