public
Description: The ultra-lightweight ultra-flexible blogging engine with a fetish for birds and misspellings.
Homepage: http://chyrp.net/
Clone URL: git://github.com/vito/chyrp.git
Click here to lend your support to: chyrp and make a donation at www.pledgie.com !
vito (author)
Mon Oct 05 10:48:26 -0700 2009
commit  6caea733a36320fb66f3ad35eae64e967243ddc5
tree    c1d34eccbb1fd6013b19d04f0b6c94c1e6c4e72e
parent  c41fc068cbe4456f5194d5d925ad88e269646e5f
chyrp / STYLE
100644 86 lines (55 sloc) 2.694 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
The coding style in Chyrp's code is very, very specific in almost every
case. If you are going to contribute, please try to follow the guidelines
below. Thank you!
 
* Use single quotes only for strings containing numerous double-quotes,
  like HTML. Use double quotes everywhere else, except for array accessors
  in $_POST, $_GET, and all the other $_* and "core" variables.
 
  A complex example:
 
      $foo = '<a href="'.$foo["bar"].'">'.$_GET['link_name'].'</a>';
 
  Edge case: If writing HTML and the part containing the opening tag is in
             single quotes, put the closing tag in single quotes too.
 
* Use four spaces for indenting. No tabs.
 
* Keep the braces on the same line as the declaration, like so:
  
      function foo_bar($baz) {
          # code
      }
 
* Use hashmarks for commenting.
 
* Don't use excessive spaces. Calling a function with multiple arguments
  should look like so:
 
      foo($bar, $baz);
 
* Use the no-braces shortcuts wherever possible, but don't make it cryptic.
  When used intermixed with other code, keep them spaced by a blank line:
 
      $foo = "bar";
      $fizz = "buzz";
 
      if ($something)
          do_something();
 
      other_stuff();
 
* Multi-line arrays should be formatted like this:
  
      array($foo,
            "bar",
            $bazz);
 
* Keep function names simple, preferrably one word. Use snake_case for most
  names, but halfCamelCase where appropriate (e.g. class methods).
 
* Use NaturalDocs for docstrings. Use hashmarks for docstrings on
  variables and constants, but use C-style block comments for functions
  and classes.
 
* For infix boolean notation:
 
      $foo = ($bar ? $baz : buzz);
 
  Be sure to use proper parentheses if you're going to use "and" and "or"
  instead of "&&" and "||". Because PHP is retarded like that.
 
      $foo = (($bar and $baz) ? $fizz : $buzz);
 
  Or, alternatively:
  
      $foo = ($bar and $baz) ? $fizz : $buzz ;
 
* Comments should describe WHY, not HOW, and only be used when it is not
  clear in the code itself.
 
* Avoid global variables. Only use them when a cleaner location for them is
  not available.
 
* Don't use too many variables. If it is only used once, just use its
  value unless you are preparing many variables for a later operation.
 
* Use snake_case for variable names, but try to keep them to one word.
 
* Take advantage of PHP's key => val arrays whenever possible, they make
  for very clear and concise code structures.
 
* If you're only going to use FooClass::current() once, don't bother
  declaring a variable for it. Conversely, if you use it a lot, declare a
  variable for it at or near the top of the function, or above its first
  usage.