Skip to content

Commit dba104e

Browse files
authored
Merge pull request #108 from jim-parry/guidelines
Update the contributing guide & process to explain signed commits.
2 parents 05e8c06 + 46bb088 commit dba104e

4 files changed

Lines changed: 105 additions & 35 deletions

File tree

system/Debug/CustomExceptions.php

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace CodeIgniter;
1+
<?php
2+
3+
namespace CodeIgniter;
24

35
/**
46
* CodeIgniter
@@ -35,48 +37,57 @@
3537
* @since Version 3.0.0
3638
* @filesource
3739
*/
38-
3940
/**
4041
* Custom Exceptions
4142
*
42-
* These exceptions are provided for you use, and work to provide a consistent
43+
* These exceptions are provided for your use, and work to provide a consistent
4344
* experience across the application. The default error codes are already set,
4445
* and will be used to provide both HTTP status codes and CLI exit codes.
4546
*
47+
* The Error Exceptions below are primarily to provide a way to have
48+
* information logged automatically by the application's log system.
49+
*
4650
* @package CodeIgniter
4751
*/
4852

49-
50-
/*
51-
The Error Exceptions below are primarily to provide a way to have information logged
52-
automatically by the application's log system.
53-
*/
54-
5553
/**
56-
* Exception for automatic logging.
54+
* Error: system is unusable
5755
*/
58-
class EmergencyError extends \Error {}; // system is unusable
56+
class EmergencyError extends \Error
57+
{
58+
59+
}
5960

6061
/**
61-
* Exception for automatic logging.
62+
* Error: Action must be taken immediately (system/db down, etc)
6263
*/
63-
class AlertError extends \Error {}; // Action must be taken immediately (system/db down, etc)
64+
class AlertError extends \Error
65+
{
66+
67+
}
6468

6569
/**
66-
* Exception for automatic logging.
70+
* Error: Critical conditions, like component unavailble, etc.
6771
*/
68-
class CriticalError extends \Error {}; // Critical conditions, like component unavailble, etc.
72+
class CriticalError extends \Error
73+
{
74+
75+
}
6976

7077
/**
71-
* Exception for automatic logging.
78+
* Error: Runtime errors that do not require immediate action
7279
*/
73-
class Error extends \Error {}; // Runtime errors that do not require immediate action
80+
class Error extends \Error
81+
{
82+
83+
}
7484

7585
/**
7686
* Exception for automatic logging.
7787
*/
7888
class PageNotFoundException extends \OutOfBoundsException
7989
{
90+
8091
/**
8192
* Error code
8293
* @var int
@@ -85,13 +96,12 @@ class PageNotFoundException extends \OutOfBoundsException
8596

8697
}
8798

88-
;
89-
9099
/**
91100
* Exception for automatic logging.
92101
*/
93102
class ConfigException extends CriticalError
94103
{
104+
95105
/**
96106
* Error code
97107
* @var int
@@ -100,13 +110,12 @@ class ConfigException extends CriticalError
100110

101111
}
102112

103-
;
104-
105113
/**
106114
* Exception for automatic logging.
107115
*/
108116
class UnknownFileException extends CriticalError
109117
{
118+
110119
/**
111120
* Error code
112121
* @var int
@@ -115,13 +124,12 @@ class UnknownFileException extends CriticalError
115124

116125
}
117126

118-
;
119-
120127
/**
121128
* Exception for automatic logging.
122129
*/
123130
class UnknownClassException extends CriticalError
124131
{
132+
125133
/**
126134
* Error code
127135
* @var int
@@ -130,13 +138,12 @@ class UnknownClassException extends CriticalError
130138

131139
}
132140

133-
;
134-
135141
/**
136142
* Exception for automatic logging.
137143
*/
138144
class UnknownMethodException extends CriticalError
139145
{
146+
140147
/**
141148
* Error code
142149
* @var int
@@ -145,13 +152,12 @@ class UnknownMethodException extends CriticalError
145152

146153
}
147154

148-
;
149-
150155
/**
151156
* Exception for automatic logging.
152157
*/
153158
class UserInputException extends \OutOfBoundsException
154159
{
160+
155161
/**
156162
* Error code
157163
* @var int
@@ -160,19 +166,16 @@ class UserInputException extends \OutOfBoundsException
160166

161167
}
162168

163-
;
164-
165169
/**
166170
* Exception for automatic logging.
167171
*/
168172
class DatabaseException extends Error
169173
{
174+
170175
/**
171176
* Error code
172177
* @var int
173178
*/
174179
protected $code = 8;
175180

176181
}
177-
178-
;

user_guide_src/source/contributing/guidelines.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ Change Log
6767
==========
6868

6969
The change-log, in the user guide root, needs to be kept up-to-date.
70+
Not all changes will need an entry in it, but new classes, major or BC changes
71+
to existing classes, and bug fixes should.
7072

7173
See the `CodeIgniter 3 change log
7274
<https://github.com/bcit-ci/CodeIgniter/blob/develop/user_guide_src/source/changelog.rst>`_

user_guide_src/source/contributing/process.rst

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,21 @@ at the same time, we might really want X but disagree with Y, meaning we
2323
cannot merge the request. Using the Git-Flow branching model you can create
2424
new branches for both of these features and send two requests.
2525

26-
Signing
27-
=======
26+
Basic Signing
27+
=============
2828
You must sign your work, certifying that you either wrote the work or
29-
otherwise have the right to pass it on to an open source project. git makes
30-
this easy as you merely have to use `--signoff` on your commits to your
29+
otherwise have the right to pass it on to an open source project.
30+
31+
Setup your commit message user name and email address. See
32+
`Setting your email in Git <https://help.github.com/articles/setting-your-email-in-git/>`_
33+
to set these up globally or for a single repository.
34+
35+
.. code-block:: bash
36+
37+
git config --global user.email "john.public@example.com"
38+
git config --global user.name "John Q Public"
39+
40+
Once in place, you merely have to use `--signoff` on your commits to your
3141
CodeIgniter fork.
3242

3343
.. code-block:: bash
@@ -52,3 +62,25 @@ it.
5262
By signing your work in this manner, you certify to a "Developer's Certificate
5363
of Origin". The current version of this certificate is in the :doc:`/DCO` file
5464
in the root of this documentation.
65+
66+
Secure Signing
67+
==============
68+
69+
The "basic signing" described above cannot be verified, though it is a great start.
70+
To verify your commits, you will need to
71+
setup a GPG key, and attach it to your github account.
72+
73+
See the `git tools <https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work>`_
74+
page for directions on doing this. The complete story is part of
75+
`Github help <https://help.github.com/categories/gpg/>`_.
76+
77+
The basic steps are
78+
79+
- `generate your GPG key <https://help.github.com/articles/generating-a-new-gpg-key/>`_, and copy the ASCII representation of it.
80+
- `Add your GPG key to your Github account <https://help.github.com/articles/adding-a-new-gpg-key-to-your-github-account/>`_.
81+
- `Tell Git <https://help.github.com/articles/telling-git-about-your-gpg-key/>`_ about your GPG key.
82+
- `Set default signing <https://help.github.com/articles/signing-commits-using-gpg/>`_ to have all of your commits securely signed automatically.
83+
- Provide your GPG key passphrase, as prompted, when you do a commit.
84+
85+
Depending on your IDE, you may have to do your Git commits from your Git bash shell
86+
to use the **-S** option to force the secure signing.

user_guide_src/source/contributing/styleguide.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ Structure
4747
=========
4848

4949
- A single file SHOULD NOT declare more than one class.
50+
Examples where we feel that more than one class in a source file
51+
is appropriate:
52+
53+
- `system/Debug/CustomExceptions` contains a number of CodeIgniter
54+
exceptions and errors, that we want to use for a consistent
55+
experience across applications.
56+
If we stick with the purist route, then each of the 13+/- custom
57+
exceptions would require an additional file, which would have a
58+
performance impact at times.
59+
- `system/HTTP/Response` provides a RedirectException, used with the
60+
Response class.
61+
- `system/Router/Router` similarly provides a RedirectException, used with
62+
the Router class.
63+
5064
- Files SHOULD either declare symbols (i.e. classes, functions, constants)
5165
or execute non-declarative logic, but SHOULD NOT do both.
5266

@@ -185,6 +199,25 @@ Operators
185199
- An operator MUST NOT be the last set of printable characters on a line.
186200
- An operator MAY be the first set of printable characters on a line.
187201

202+
Logical Operators
203+
=================
204+
205+
- Use the symbol versions (**||** and **&&**) of the logical operators
206+
instead of the word versions (**OR** and **AND**).
207+
208+
- This is consistent with other programming languages
209+
- It avoids the problem of the assignment operator (**=**) having
210+
higher precedence::
211+
212+
$result = true && false; // $result is false, expected
213+
$result = true OR false; // $result is true, evaluated as "($result = true) OR false"
214+
$result = (true OR false); // $result is false
215+
216+
- The logical negation operator MUST be separated from its argument by a
217+
single space, as in **! $result** instead of **!$result**
218+
- If there is potential confusion with a logical expression, then use
219+
parentheses for clarity, as shown above.
220+
188221
Other
189222
=====
190223

0 commit comments

Comments
 (0)