Skip to content

Commit d8a6cbb

Browse files
AmitMYchriskacerguis
authored andcommitted
All around cleaning (chriskacerguis#734)
* Fixed throws statement * Removed unnecessary return doc * Fixed wrong return value * Fixed parameter types in PHP DOC * Removed paths inspection in the project * Added index methods support! Finally * Handle all exceptions showings in one place. not 2 * Added changes to the change log * Fixed properties PHPDoc * English spelling fixes
1 parent d19dc77 commit d8a6cbb

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Changelog:
3838
* Log Table support for IPv6 & NULL parameters
3939
* Abstract out the processes of firing a controller method within _remap() to an separate method
4040
* Moved GET, POST, PUT, and DELETE parsing to separate methods, allowing them to be overridden as needed
41-
* Small bugfix for a PHP 5.3 strlen error
41+
* Small bug-fix for a PHP 5.3 strlen error
4242
* Fixed some PHP 5.4 warnings
4343
* Fix for bug in Format.php's to_html() which failed to detect if $data was really a multidimensional array.
4444
* Fix for empty node on XML output format, for false = 0, true = 1.
@@ -55,11 +55,11 @@ Changelog:
5555
* Support for Backbone.emulateHTTP improved.
5656
* Combine both URI segment and GET params instead of using one or the other
5757
* Separate each piece of the WWW-Authenticate header for digest requests with a comma.
58-
* Added IP whitelist option.
58+
* Added IP white-list option.
5959

6060
### 2.5
6161

62-
* Instead of just seeing item, item, item, the singular version of the basenode will be used if possible. [Example](http://d.pr/RS46).
62+
* Instead of just seeing item, item, item, the singular version of the base-node will be used if possible. [Example](http://d.pr/RS46).
6363
* Re-factored to use the Format library, which will soon be merged with CodeIgniter.
6464
* Fixed Limit bug (limit of 5 would allow 6 requests).
6565
* Added logging for invalid API key requests.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ Enabling digest auth is similarly easy. Configure your desired logins in the con
150150

151151
If you're tying this library into an AJAX endpoint where clients authenticate using PHP sessions then you may not like either of the digest nor basic authentication methods. In that case, you can tell the REST Library what PHP session variable to check for. If the variable exists, then the user is authorized. It will be up to your application to set that variable. You can define the variable in ``$config['auth_source']``. Then tell the library to use a php session variable by setting ``$config['rest_auth']`` to ``session``.
152152

153-
All three methods of authentication can be secured further by using an IP whitelist. If you enable `$config['rest_ip_whitelist_enabled']` in your config file, you can then set a list of allowed IPs.
153+
All three methods of authentication can be secured further by using an IP white-list. If you enable `$config['rest_ip_whitelist_enabled']` in your config file, you can then set a list of allowed IPs.
154154

155-
Any client connecting to your API will be checked against the whitelisted IP array. If they're on the list, they'll be allowed access. If not, sorry, no can do hombre. The whitelist is a comma-separated string:
155+
Any client connecting to your API will be checked against the white-listed IP array. If they're on the list, they'll be allowed access. If not, sorry, no can do hombre. The whitelist is a comma-separated string:
156156

157157
```php
158158
$config['rest_ip_whitelist'] = '123.456.789.0, 987.654.32.1';
@@ -196,7 +196,7 @@ $ curl -X POST -H "X-API-KEY: some_key_here" http://example.com/books
196196
## Contributions
197197

198198
This project was originally written by Phil Sturgeon, however his involvement has shifted
199-
as he is no longer using it. As of 2013/11/20 further developement and support will be done by Chris Kacerguis.
199+
as he is no longer using it. As of 2013/11/20 further development and support will be done by Chris Kacerguis.
200200

201201
Pull Requests are the best way to fix bugs or add features. I know loads of you use this, so please
202202
contribute if you have improvements to be made and I'll keep releasing versions over time.

application/config/rest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@
104104
| Set to specify the REST API requires to be logged in
105105
|
106106
| FALSE No login required
107-
| 'basic' Unsecure login
108-
| 'digest' More secure login
107+
| 'basic' Unsecured login
108+
| 'digest' More secured login
109109
| 'session' Check for a PHP session variable. See 'auth_source' to set the
110110
| authorization key
111111
|
@@ -189,7 +189,7 @@
189189

190190
/*
191191
|--------------------------------------------------------------------------
192-
| Override auth types for specfic 'class/method/HTTP method'
192+
| Override auth types for specific 'class/method/HTTP method'
193193
|--------------------------------------------------------------------------
194194
|
195195
| example:
@@ -214,24 +214,24 @@
214214

215215
/*
216216
|--------------------------------------------------------------------------
217-
| Global IP Whitelisting
217+
| Global IP White-listing
218218
|--------------------------------------------------------------------------
219219
|
220-
| Limit connections to your REST server to whitelisted IP addresses
220+
| Limit connections to your REST server to White-listed IP addresses
221221
|
222222
| Usage:
223223
| 1. Set to TRUE and select an auth option for extreme security (client's IP
224-
| address must be in whitelist and they must also log in)
225-
| 2. Set to TRUE with auth set to FALSE to allow whitelisted IPs access with no login
226-
| 3. Set to FALSE but set 'auth_override_class_method' to 'whitelist' to
227-
| restrict certain methods to IPs in your whitelist
224+
| address must be in white-list and they must also log in)
225+
| 2. Set to TRUE with auth set to FALSE to allow White-listed IPs access with no login
226+
| 3. Set to FALSE but set 'auth_override_class_method' to 'white-list' to
227+
| restrict certain methods to IPs in your white-list
228228
|
229229
*/
230230
$config['rest_ip_whitelist_enabled'] = FALSE;
231231

232232
/*
233233
|--------------------------------------------------------------------------
234-
| REST IP Whitelist
234+
| REST IP White-list
235235
|--------------------------------------------------------------------------
236236
|
237237
| Limit connections to your REST server with a comma separated

application/controllers/api/Example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function users_get()
7373
$this->response(NULL, REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
7474
}
7575

76-
// Get the user from the array, using the id as key for retreival.
76+
// Get the user from the array, using the id as key for retrieval.
7777
// Usually a model is to be used for this.
7878

7979
$user = NULL;

application/libraries/REST_Controller.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,16 +285,16 @@ abstract class REST_Controller extends CI_Controller {
285285
/**
286286
* The start of the response time from the server
287287
*
288-
* @var string
288+
* @var number
289289
*/
290-
protected $_start_rtime = '';
290+
protected $_start_rtime;
291291

292292
/**
293293
* The end of the response time from the server
294294
*
295-
* @var string
295+
* @var number
296296
*/
297-
protected $_end_rtime = '';
297+
protected $_end_rtime;
298298

299299
/**
300300
* List all supported methods, the first will be the default format
@@ -567,7 +567,7 @@ public function __construct($config = 'rest')
567567
}
568568

569569
/**
570-
* Deconstructor
570+
* De-constructor
571571
*
572572
* @author Chris Kacerguis
573573
* @access public
@@ -778,7 +778,7 @@ public function response($data = NULL, $http_code = NULL, $continue = FALSE)
778778
$output = $this->format->factory($data)->{'to_' . $this->response->format}();
779779

780780
// An array must be parsed as a string, so as not to cause an array to string error
781-
// Json is the most appropriate form for such a datatype
781+
// Json is the most appropriate form for such a data type
782782
if ($this->response->format === 'array')
783783
{
784784
$output = $this->format->factory($output)->{'to_json'}();
@@ -1473,7 +1473,7 @@ protected function _parse_put()
14731473
}
14741474
else if ($this->input->method() === 'put')
14751475
{
1476-
// If no filetype is provided, then there are probably just arguments
1476+
// If no file type is provided, then there are probably just arguments
14771477
$this->_put_args = $this->input->input_stream();
14781478
}
14791479
}
@@ -1523,7 +1523,7 @@ protected function _parse_patch()
15231523
}
15241524
else if ($this->input->method() === 'patch')
15251525
{
1526-
// If no filetype is provided, then there are probably just arguments
1526+
// If no file type is provided, then there are probably just arguments
15271527
$this->_patch_args = $this->input->input_stream();
15281528
}
15291529
}
@@ -1941,7 +1941,7 @@ protected function _check_php_session()
19411941
// Get the auth_source config item
19421942
$key = $this->config->item('auth_source');
19431943

1944-
// If falsy, then the user isn't logged in
1944+
// If false, then the user isn't logged in
19451945
if ( ! $this->session->userdata($key))
19461946
{
19471947
// Display an error response

0 commit comments

Comments
 (0)