Skip to content

Expansion on Class Standards #71

Closed
wants to merge 8 commits into from

6 participants

@manchuck

I though that class definition description in PSR-1 and 2 needs a little expansion with defining classes. I wrote this up in hopes that it will server a purpose

@strayobject strayobject commented on an outdated diff Dec 30, 2012
proposed/Class-declaration.md
+ public function setFoo($value)
+ {
+ $this->foo = $value;
+ }
+
+ public function getFoo()
+ {
+ return $this->foo;
+ }
+
+ public function setBar($value)
+ {
+ $this->bar = $value;
+ }
+
+ public function setBar($value)
@strayobject
strayobject added a note Dec 30, 2012

this should say setBaz()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kampde kampde and 2 others commented on an outdated diff Jan 3, 2013
proposed/Class-declaration.md
+
+### 1.3 Setters and Getters
+
+- Setters and Getters MUST NOT have private visibility
+- Getters and Setters SHOULD be declared in serial or grouped with each but MUST NOT be both
+
+## 2 Examples:
+
+### 2.1 Good Example:
+```php
+<?php
+class OrderExample
+{
+ const VERSION = '1.4';
+
+ private static $prrivateFoo;
@kampde
kampde added a note Jan 3, 2013

spelling mistake: $privateFoo with just one r

@bobthecow
bobthecow added a note Jan 4, 2013

Maybe it's a pirate varrrgh?

@manchuck
manchuck added a note Jan 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@CyExy CyExy commented on an outdated diff Jan 7, 2013
proposed/Class-declaration.md
+<?php
+class OrderExample
+{
+ const VERSION = '1.4';
+
+ private static $privateFoo;
+
+ protected static $protectedFoo;
+
+ public static $publicFoo;
+
+ private $privateBar;
+
+ protected $protectedBar;
+
+ public $publicBar;
@CyExy
CyExy added a note Jan 7, 2013

This contradicts the §1.1 that say's that properties visibility should be in order of public, protected and private but here it's other-way around

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@philsturgeon

This seems like a really nice list of things to consider for your in-house best practices, but it really doesn't do much to help interoperability. Bring this up on the mailing list if you feel I'm wrong, but I'm going to close this due to lack of interest over the last 4 months.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.