Skip to content

Commit

Permalink
Add StyleCI for conforming code to PSR standards
Browse files Browse the repository at this point in the history
  • Loading branch information
rougin committed Sep 9, 2016
1 parent 32b9266 commit dcdcee1
Show file tree
Hide file tree
Showing 24 changed files with 133 additions and 125 deletions.
1 change: 1 addition & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
preset: psr2
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All Notable changes to `Spark Plug` will be documented in this file.

## [0.4.4](https://github.com/rougin/spark-plug/compare/v0.4.3...v0.4.4) - 2016-09-10

### Added
- StyleCI for conforming code to PSR standards

## [0.4.3](https://github.com/rougin/spark-plug/compare/v0.4.2...v0.4.3) - 2016-05-13

### Changed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"require-dev": {
"phpunit/phpunit" : "4.*",
"scrutinizer/ocular": "~1.1",
"rougin/codeigniter": "^3.0.0"
"rougin/codeigniter": "~3.0"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions src/Instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
* Instance
*
* Creates an instance based on SparkPlug class.
*
*
* @package SparkPlug
* @author Rougin Royce Gutib <rougingutib@gmail.com>
*/
class Instance
{
/**
* Creates an instance of CodeIgniter based on the application path.
*
*
* @param string $appPath
* @param array $server
* @param array $globals
Expand Down
28 changes: 14 additions & 14 deletions src/SparkPlug.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Spark Plug
*
* Returns a CodeIgniter's instance.
*
*
* @package SparkPlug
* @author Rougin Royce Gutib <rougingutib@gmail.com>
*/
Expand Down Expand Up @@ -46,7 +46,7 @@ public function __construct(array &$globals, array $server, $path = '')

/**
* Returns a CodeIgniter instance.
*
*
* @return \CI_Controller
*/
public function getCodeIgniter()
Expand Down Expand Up @@ -78,21 +78,21 @@ public function getCodeIgniter()

/**
* Loads the Common and the Base Controller class.
*
*
* @return void
*/
protected function loadClasses()
{
require BASEPATH . 'core/Common.php';

if ( ! class_exists('CI_Controller')) {
if (! class_exists('CI_Controller')) {
require BASEPATH . 'core/Controller.php';
}
}

/**
* Loads the framework constants.
*
*
* @return void
*/
protected function loadConstants()
Expand Down Expand Up @@ -122,13 +122,13 @@ protected function setCharSet()

ini_set('default_charset', $charset);

if ( ! defined('MB_ENABLED')) {
if (! defined('MB_ENABLED')) {
define('MB_ENABLED', extension_loaded('mbstring'));
}

// mbstring.internal_encoding is deprecated starting with PHP 5.6
// and it's usage triggers E_DEPRECATED messages.
if ( ! is_php('5.6') && ! ini_get('mbstring.internal_encoding')) {
if (! is_php('5.6') && ! ini_get('mbstring.internal_encoding')) {
ini_set('mbstring.internal_encoding', $charset);
}

Expand All @@ -139,7 +139,7 @@ protected function setCharSet()

// There's an ICONV_IMPL constant, but the PHP manual says that using
// iconv's predefined constants is "strongly discouraged".
if ( ! defined('ICONV_ENABLED')) {
if (! defined('ICONV_ENABLED')) {
define('ICONV_ENABLED', extension_loaded('iconv'));
}
}
Expand All @@ -157,14 +157,14 @@ protected function setEnvironment()
$environment = $this->server['CI_ENV'];
}

if ( ! defined('ENVIRONMENT')) {
if (! defined('ENVIRONMENT')) {
define('ENVIRONMENT', $environment);
}
}

/**
* Sets up the APPPATH, VENDOR, and BASEPATH constants.
*
*
* @return void
*/
protected function setPaths()
Expand All @@ -177,15 +177,15 @@ protected function setPaths()
$applicationPath = $this->path . '/application';
}

if ( ! defined('APPPATH')) {
if (! defined('APPPATH')) {
define('APPPATH', $applicationPath . '/');
}

if ( ! defined('VENDOR')) {
if (! defined('VENDOR')) {
define('VENDOR', $vendorPath . '/');
}

if ( ! defined('VIEWPATH')) {
if (! defined('VIEWPATH')) {
define('VIEWPATH', APPPATH . '/views/');
}

Expand All @@ -199,7 +199,7 @@ protected function setPaths()
foreach ($iterator as $file) {
$core = 'core' . DIRECTORY_SEPARATOR . 'CodeIgniter.php';

if (strpos($file->getPathname(), $core) !== FALSE) {
if (strpos($file->getPathname(), $core) !== false) {
$path = str_replace($core, '', $file->getPathname());

define('BASEPATH', $path);
Expand Down
4 changes: 2 additions & 2 deletions src/get_instance.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

if ( ! function_exists('get_instance')) {
if (! function_exists('get_instance')) {
/**
* Gets an instance of CodeIgniter.
*
*
* @return CI_Controller
*/
function &get_instance()
Expand Down
8 changes: 4 additions & 4 deletions tests/SparkPlugTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function setUp()

/**
* Checks if the CodeIgniter instance is successfully retrieved.
*
*
* @return void
*/
public function testCodeIgniterInstance()
Expand All @@ -38,7 +38,7 @@ public function testCodeIgniterInstance()

/**
* Checks if the loaded library can be retrieved.
*
*
* @return void
*/
public function testLoadLibrary()
Expand All @@ -50,7 +50,7 @@ public function testLoadLibrary()

/**
* Checks if the loaded helper can be retrieved.
*
*
* @return void
*/
public function testLoadHelper()
Expand All @@ -62,7 +62,7 @@ public function testLoadHelper()

/**
* Checks the environment-based configurations.
*
*
* @return void
*/
public function testEnvironmentConstants()
Expand Down
44 changes: 22 additions & 22 deletions tests/TestApp/application/config/config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
defined('BASEPATH') or exit('No direct script access allowed');

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -46,7 +46,7 @@
|
| WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
*/
$config['uri_protocol'] = 'REQUEST_URI';
$config['uri_protocol'] = 'REQUEST_URI';

/*
|--------------------------------------------------------------------------
Expand All @@ -70,7 +70,7 @@
| than english.
|
*/
$config['language'] = 'english';
$config['language'] = 'english';

/*
|--------------------------------------------------------------------------
Expand All @@ -94,7 +94,7 @@
| setting this variable to TRUE (boolean). See the user guide for details.
|
*/
$config['enable_hooks'] = FALSE;
$config['enable_hooks'] = false;

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -130,7 +130,7 @@
| Note: This will NOT disable or override the CodeIgniter-specific
| autoloading (application/config/autoload.php)
*/
$config['composer_autoload'] = FALSE;
$config['composer_autoload'] = false;

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -179,8 +179,8 @@
| use segment based URLs.
|
*/
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = FALSE;
$config['allow_get_array'] = true;
$config['enable_query_strings'] = false;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd';
Expand Down Expand Up @@ -295,7 +295,7 @@
| of query parameters.
|
*/
$config['cache_query_string'] = FALSE;
$config['cache_query_string'] = false;

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -361,10 +361,10 @@
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_save_path'] = null;
$config['sess_match_ip'] = false;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['sess_regenerate_destroy'] = false;

/*
|--------------------------------------------------------------------------
Expand All @@ -381,11 +381,11 @@
| 'cookie_httponly') will also affect sessions.
|
*/
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = false;
$config['cookie_httponly'] = false;

/*
|--------------------------------------------------------------------------
Expand All @@ -399,7 +399,7 @@
| (usually \n) and Windows (\r\n).
|
*/
$config['standardize_newlines'] = FALSE;
$config['standardize_newlines'] = false;

/*
|--------------------------------------------------------------------------
Expand All @@ -413,7 +413,7 @@
| for backwards compatibility purposes!
|
*/
$config['global_xss_filtering'] = FALSE;
$config['global_xss_filtering'] = false;

/*
|--------------------------------------------------------------------------
Expand All @@ -429,11 +429,11 @@
| 'csrf_regenerate' = Regenerate token on every submission
| 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks
*/
$config['csrf_protection'] = FALSE;
$config['csrf_protection'] = false;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_regenerate'] = true;
$config['csrf_exclude_uris'] = array();

/*
Expand All @@ -456,7 +456,7 @@
| by the output class. Do not 'echo' any values with compression enabled.
|
*/
$config['compress_output'] = FALSE;
$config['compress_output'] = false;

/*
|--------------------------------------------------------------------------
Expand All @@ -483,7 +483,7 @@
| Note: You need to have eval() enabled for this to work.
|
*/
$config['rewrite_short_tags'] = FALSE;
$config['rewrite_short_tags'] = false;

/*
|--------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions tests/TestApp/application/config/constants.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
defined('BASEPATH') or exit('No direct script access allowed');

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -47,7 +47,7 @@
| of this setting
|
*/
define('SHOW_DEBUG_BACKTRACE', TRUE);
define('SHOW_DEBUG_BACKTRACE', true);

/*
|--------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit dcdcee1

Please sign in to comment.