Expansion on Class Standards #71

Closed
wants to merge 8 commits into
from

Projects

None yet

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 Dec 30, 2012

this should say setBaz()

@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 Jan 3, 2013

spelling mistake: $privateFoo with just one r

@bobthecow
bobthecow Jan 4, 2013 Contributor

Maybe it's a pirate varrrgh?

@manchuck
manchuck Jan 4, 2013

Sorry that got by me again.

Chuck Reeves
President
631.374.0772
MANCHUCK | www.manchuck.com

On Fri, Jan 4, 2013 at 12:17 AM, Justin Hileman notifications@github.comwrote:

In 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;

Maybe it's a pirate varrrgh?


Reply to this email directly or view it on GitHubhttps://github.com/php-fig/fig-standards/pull/71/files#r2547580.

@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 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

@philsturgeon
Contributor

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