Skip to content

Commit

Permalink
Add codesniffer that ensures indentation is with tabs.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwelsh committed Dec 12, 2012
1 parent ed11970 commit b0121b5
Show file tree
Hide file tree
Showing 107 changed files with 3,117 additions and 3,103 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -22,7 +22,8 @@ before_script:


script: script:
- phpunit -c phpunit.xml.dist - phpunit -c phpunit.xml.dist
- phpcs --encoding=utf-8 --tab-width=4 --standard=framework/tests/phpcs -np framework - phpcs --encoding=utf-8 --tab-width=4 --standard=framework/tests/phpcs/ruleset.xml -np framework
- phpcs --encoding=utf-8 --standard=framework/tests/phpcs/tabs.xml -np framework


branches: branches:
except: except:
Expand Down
18 changes: 9 additions & 9 deletions admin/code/CMSProfileController.php
Expand Up @@ -26,15 +26,15 @@ public function getEditForm($id = null, $fields = null) {
$form->Fields()->push(new HiddenField('ID', null, Member::currentUserID())); $form->Fields()->push(new HiddenField('ID', null, Member::currentUserID()));
$form->Actions()->push( $form->Actions()->push(
FormAction::create('save',_t('CMSMain.SAVE', 'Save')) FormAction::create('save',_t('CMSMain.SAVE', 'Save'))
->addExtraClass('ss-ui-button ss-ui-action-constructive') ->addExtraClass('ss-ui-button ss-ui-action-constructive')
->setAttribute('data-icon', 'accept') ->setAttribute('data-icon', 'accept')
->setUseButtonTag(true) ->setUseButtonTag(true)
); );
$form->Actions()->removeByName('delete'); $form->Actions()->removeByName('delete');
$form->setValidator(new Member_Validator()); $form->setValidator(new Member_Validator());
$form->setTemplate('Form'); $form->setTemplate('Form');
$form->setAttribute('data-pjax-fragment', null); $form->setAttribute('data-pjax-fragment', null);
if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet'); if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
$form->addExtraClass('member-profile-form root-form cms-edit-form cms-panel-padded center'); $form->addExtraClass('member-profile-form root-form cms-edit-form cms-panel-padded center');


return $form; return $form;
Expand Down
2 changes: 1 addition & 1 deletion admin/code/ModelAdmin.php
Expand Up @@ -296,7 +296,7 @@ public function getManagedModels() {
* *
* @return array Map of model class names to importer instances * @return array Map of model class names to importer instances
*/ */
public function getModelImporters() { public function getModelImporters() {
$importerClasses = $this->stat('model_importers'); $importerClasses = $this->stat('model_importers');


// fallback to all defined models if not explicitly defined // fallback to all defined models if not explicitly defined
Expand Down
4 changes: 2 additions & 2 deletions admin/javascript/LeftAndMain.Tree.js
Expand Up @@ -153,8 +153,8 @@
"select_limit" : 1, "select_limit" : 1,
'initially_select': [this.find('.current').attr('id')] 'initially_select': [this.find('.current').attr('id')]
}, },
"crrm": { "crrm": {
'move': { 'move': {
// Check if a node is allowed to be moved. // Check if a node is allowed to be moved.
// Caution: Runs on every drag over a new node // Caution: Runs on every drag over a new node
'check_move': function(data) { 'check_move': function(data) {
Expand Down
2 changes: 1 addition & 1 deletion admin/javascript/LeftAndMain.js
Expand Up @@ -301,7 +301,7 @@ jQuery.noConflict();
*/ */
submitForm: function(form, button, callback, ajaxOptions) { submitForm: function(form, button, callback, ajaxOptions) {
var self = this; var self = this;

// look for save button // look for save button
if(!button) button = this.find('.Actions :submit[name=action_save]'); if(!button) button = this.find('.Actions :submit[name=action_save]');
// default to first button if none given - simulates browser behaviour // default to first button if none given - simulates browser behaviour
Expand Down
6 changes: 3 additions & 3 deletions admin/javascript/lib.js
Expand Up @@ -170,8 +170,8 @@
convertUrlToDataUrl: function( absUrl ) { convertUrlToDataUrl: function( absUrl ) {
var u = path.parseUrl( absUrl ); var u = path.parseUrl( absUrl );
if ( path.isEmbeddedPage( u ) ) { if ( path.isEmbeddedPage( u ) ) {
// For embedded pages, remove the dialog hash key as in getFilePath(), // For embedded pages, remove the dialog hash key as in getFilePath(),
// otherwise the Data Url won't match the id of the embedded Page. // otherwise the Data Url won't match the id of the embedded Page.
return u.hash.split( dialogHashKey )[0].replace( /^#/, "" ); return u.hash.split( dialogHashKey )[0].replace( /^#/, "" );
} else if ( path.isSameDomain( u, documentBase ) ) { } else if ( path.isSameDomain( u, documentBase ) ) {
return u.hrefNoHash.replace( documentBase.domain, "" ); return u.hrefNoHash.replace( documentBase.domain, "" );
Expand Down Expand Up @@ -232,4 +232,4 @@
}; };


$.path = path; $.path = path;
}(jQuery)); }(jQuery));
6 changes: 3 additions & 3 deletions api/FormEncodedDataFormatter.php
Expand Up @@ -30,9 +30,9 @@ public function supportedMimeTypes() {
} }


public function convertStringToArray($strData) { public function convertStringToArray($strData) {
$postArray = array(); $postArray = array();
parse_str($strData, $postArray); parse_str($strData, $postArray);
return $postArray; return $postArray;
//TODO: It would be nice to implement this function in Convert.php //TODO: It would be nice to implement this function in Convert.php
//return Convert::querystr2array($strData); //return Convert::querystr2array($strData);
} }
Expand Down
8 changes: 4 additions & 4 deletions api/RSSFeed.php
Expand Up @@ -106,9 +106,9 @@ class RSSFeed extends ViewableData {
* every time the representation does * every time the representation does
*/ */
public function __construct(SS_List $entries, $link, $title, public function __construct(SS_List $entries, $link, $title,
$description = null, $titleField = "Title", $description = null, $titleField = "Title",
$descriptionField = "Content", $authorField = null, $descriptionField = "Content", $authorField = null,
$lastModified = null, $etag = null) { $lastModified = null, $etag = null) {
$this->entries = $entries; $this->entries = $entries;
$this->link = $link; $this->link = $link;
$this->description = $description; $this->description = $description;
Expand Down Expand Up @@ -269,7 +269,7 @@ class RSSFeed_Entry extends ViewableData {
* Create a new RSSFeed entry. * Create a new RSSFeed entry.
*/ */
public function __construct($entry, $titleField, $descriptionField, public function __construct($entry, $titleField, $descriptionField,
$authorField) { $authorField) {
$this->failover = $entry; $this->failover = $entry;
$this->titleField = $titleField; $this->titleField = $titleField;
$this->descriptionField = $descriptionField; $this->descriptionField = $descriptionField;
Expand Down
6 changes: 3 additions & 3 deletions api/RestfulService.php
Expand Up @@ -65,7 +65,7 @@ public function setQueryString($params=NULL){
* @param string $password The proxy auth password * @param string $password The proxy auth password
* @param boolean $socks Set true to use socks5 proxy instead of http * @param boolean $socks Set true to use socks5 proxy instead of http
*/ */
public function setProxy($proxy, $port = 80, $user = "", $password = "", $socks = false) { public function setProxy($proxy, $port = 80, $user = "", $password = "", $socks = false) {
$this->proxy = array( $this->proxy = array(
CURLOPT_PROXY => $proxy, CURLOPT_PROXY => $proxy,
CURLOPT_PROXYUSERPWD => "{$user}:{$password}", CURLOPT_PROXYUSERPWD => "{$user}:{$password}",
Expand Down Expand Up @@ -337,14 +337,14 @@ protected function getRecurseValues($xml,&$data,$parent=""){
$child_count++; $child_count++;
$k = ($parent == "") ? (string)$key : $parent . "_" . (string)$key; $k = ($parent == "") ? (string)$key : $parent . "_" . (string)$key;
if($this->getRecurseValues($value,$data,$k) == 0){ // no childern, aka "leaf node" if($this->getRecurseValues($value,$data,$k) == 0){ // no childern, aka "leaf node"
$conv_value = Convert::raw2xml($value); $conv_value = Convert::raw2xml($value);
} }
//Review the fix for similar node names overriding it's predecessor //Review the fix for similar node names overriding it's predecessor
if(array_key_exists($k, $data) == true) { if(array_key_exists($k, $data) == true) {
$data[$k] = $data[$k] . ",". $conv_value; $data[$k] = $data[$k] . ",". $conv_value;
} }
else { else {
$data[$k] = $conv_value; $data[$k] = $conv_value;
} }




Expand Down
28 changes: 14 additions & 14 deletions cli-script.php
Expand Up @@ -37,19 +37,19 @@
* fourth => val * fourth => val
*/ */
if(isset($_SERVER['argv'][2])) { if(isset($_SERVER['argv'][2])) {
$args = array_slice($_SERVER['argv'],2); $args = array_slice($_SERVER['argv'],2);
if(!isset($_GET)) $_GET = array(); if(!isset($_GET)) $_GET = array();
if(!isset($_REQUEST)) $_REQUEST = array(); if(!isset($_REQUEST)) $_REQUEST = array();
foreach($args as $arg) { foreach($args as $arg) {
if(strpos($arg,'=') == false) { if(strpos($arg,'=') == false) {
$_GET['args'][] = $arg; $_GET['args'][] = $arg;
} else { } else {
$newItems = array(); $newItems = array();
parse_str( (substr($arg,0,2) == '--') ? substr($arg,2) : $arg, $newItems ); parse_str( (substr($arg,0,2) == '--') ? substr($arg,2) : $arg, $newItems );
$_GET = array_merge($_GET, $newItems); $_GET = array_merge($_GET, $newItems);
} }
} }
$_REQUEST = array_merge($_REQUEST, $_GET); $_REQUEST = array_merge($_REQUEST, $_GET);
} }


// Set 'url' GET parameter // Set 'url' GET parameter
Expand All @@ -76,7 +76,7 @@
$url = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : null; $url = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : null;
if(!$url) { if(!$url) {
echo 'Please specify an argument to cli-script.php/sake. For more information, visit' echo 'Please specify an argument to cli-script.php/sake. For more information, visit'
. ' http://doc.silverstripe.org/framework/en/topics/commandline'; . ' http://doc.silverstripe.org/framework/en/topics/commandline';
die(); die();
} }


Expand Down
4 changes: 2 additions & 2 deletions conf/ConfigureFromEnv.php
Expand Up @@ -100,8 +100,8 @@
} }


// For schema enabled drivers: // For schema enabled drivers:
if(defined('SS_DATABASE_SCHEMA')) if(defined('SS_DATABASE_SCHEMA'))
$databaseConfig["schema"] = SS_DATABASE_SCHEMA; $databaseConfig["schema"] = SS_DATABASE_SCHEMA;
} }


if(defined('SS_SEND_ALL_EMAILS_TO')) { if(defined('SS_SEND_ALL_EMAILS_TO')) {
Expand Down
4 changes: 2 additions & 2 deletions control/ContentNegotiator.php
Expand Up @@ -45,7 +45,7 @@ public static function set_encoding($encoding) {
* that need to specify the character set make use of this function. * that need to specify the character set make use of this function.
*/ */
public static function get_encoding() { public static function get_encoding() {
return self::$encoding; return self::$encoding;
} }


/** /**
Expand Down Expand Up @@ -96,7 +96,7 @@ public static function process(SS_HTTPResponse $response) {
} else { } else {
// The W3C validator doesn't send an HTTP_ACCEPT header, but it can support xhtml. We put this special // The W3C validator doesn't send an HTTP_ACCEPT header, but it can support xhtml. We put this special
// case in here so that designers don't get worried that their templates are HTML4. // case in here so that designers don't get worried that their templates are HTML4.
if(isset($_SERVER['HTTP_USER_AGENT']) && substr($_SERVER['HTTP_USER_AGENT'], 0, 14) == 'W3C_Validator/') { if(isset($_SERVER['HTTP_USER_AGENT']) && substr($_SERVER['HTTP_USER_AGENT'], 0, 14) == 'W3C_Validator/') {
$chosenFormat = "xhtml"; $chosenFormat = "xhtml";


} else { } else {
Expand Down
4 changes: 2 additions & 2 deletions control/Controller.php
Expand Up @@ -164,7 +164,7 @@ public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
Debug::message("Request handler $body->class object to $this->class controller;" Debug::message("Request handler $body->class object to $this->class controller;"
. "rendering with template returned by $body->class::getViewer()"); . "rendering with template returned by $body->class::getViewer()");
} }
$body = $body->getViewer($request->latestParam('Action'))->process($body); $body = $body->getViewer($request->latestParam('Action'))->process($body);
} }


$this->response->setBody($body); $this->response->setBody($body);
Expand Down Expand Up @@ -367,7 +367,7 @@ public function render($params = null) {


return $template->process($obj); return $template->process($obj);
} }

/** /**
* Call this to disable site-wide basic authentication for a specific contoller. * Call this to disable site-wide basic authentication for a specific contoller.
* This must be called before Controller::init(). That is, you must call it in your controller's * This must be called before Controller::init(). That is, you must call it in your controller's
Expand Down
22 changes: 11 additions & 11 deletions control/Director.php
Expand Up @@ -348,8 +348,8 @@ public static function absoluteURL($url, $relativeToSiteBase = false) {
$url = dirname($_SERVER['REQUEST_URI'] . 'x') . '/' . $url; $url = dirname($_SERVER['REQUEST_URI'] . 'x') . '/' . $url;
} }


if(substr($url,0,4) != "http") { if(substr($url,0,4) != "http") {
if($url[0] != "/") $url = Director::baseURL() . $url; if($url[0] != "/") $url = Director::baseURL() . $url;
// Sometimes baseURL() can return a full URL instead of just a path // Sometimes baseURL() can return a full URL instead of just a path
if(substr($url,0,4) != "http") $url = self::protocolAndHost() . $url; if(substr($url,0,4) != "http") $url = self::protocolAndHost() . $url;
} }
Expand Down Expand Up @@ -630,21 +630,21 @@ public static function fileExists($file) {
/** /**
* Returns the Absolute URL of the site root. * Returns the Absolute URL of the site root.
*/ */
public static function absoluteBaseURL() { public static function absoluteBaseURL() {
return Director::absoluteURL(Director::baseURL()); return Director::absoluteURL(Director::baseURL());
} }

/** /**
* Returns the Absolute URL of the site root, embedding the current basic-auth credentials into the URL. * Returns the Absolute URL of the site root, embedding the current basic-auth credentials into the URL.
*/ */
public static function absoluteBaseURLWithAuth() { public static function absoluteBaseURLWithAuth() {
$s = ""; $s = "";
$login = ""; $login = "";


if(isset($_SERVER['PHP_AUTH_USER'])) $login = "$_SERVER[PHP_AUTH_USER]:$_SERVER[PHP_AUTH_PW]@"; if(isset($_SERVER['PHP_AUTH_USER'])) $login = "$_SERVER[PHP_AUTH_USER]:$_SERVER[PHP_AUTH_PW]@";


return Director::protocol() . $login . $_SERVER['HTTP_HOST'] . Director::baseURL(); return Director::protocol() . $login . $_SERVER['HTTP_HOST'] . Director::baseURL();
} }


/** /**
* Force the site to run on SSL. * Force the site to run on SSL.
Expand Down Expand Up @@ -843,7 +843,7 @@ public static function isDev($dontTouchDB = false) {
$result = $_GET['isDev']; $result = $_GET['isDev'];
} else { } else {
if($firstTimeCheckingGetVar && DB::connection_attempted()) { if($firstTimeCheckingGetVar && DB::connection_attempted()) {
echo "<p style=\"padding: 3px; margin: 3px; background-color: orange; echo "<p style=\"padding: 3px; margin: 3px; background-color: orange;
color: white; font-weight: bold\">Sorry, you can't use ?isDev=1 until your color: white; font-weight: bold\">Sorry, you can't use ?isDev=1 until your
Member and Group tables database are available. Perhaps your database Member and Group tables database are available. Perhaps your database
connection is failing?</p>"; connection is failing?</p>";
Expand Down
4 changes: 2 additions & 2 deletions control/HTTP.php
Expand Up @@ -171,8 +171,8 @@ public static function findByTagAndAttribute($content, $attributes) {
if($regexes) foreach($regexes as $regex) { if($regexes) foreach($regexes as $regex) {
if(preg_match_all($regex, $content, $matches)) { if(preg_match_all($regex, $content, $matches)) {
$result = array_merge_recursive($result, (isset($matches[2]) ? $matches[2] : $matches[1])); $result = array_merge_recursive($result, (isset($matches[2]) ? $matches[2] : $matches[1]));
} }
} }


return count($result) ? $result : null; return count($result) ? $result : null;
} }
Expand Down
48 changes: 24 additions & 24 deletions control/HTTPRequest.php
Expand Up @@ -296,21 +296,21 @@ public function removeHeader($header) {
public function getURL($includeGetVars = false) { public function getURL($includeGetVars = false) {
$url = ($this->getExtension()) ? $this->url . '.' . $this->getExtension() : $this->url; $url = ($this->getExtension()) ? $this->url . '.' . $this->getExtension() : $this->url;


if ($includeGetVars) { if ($includeGetVars) {
// if we don't unset $vars['url'] we end up with /my/url?url=my/url&foo=bar etc // if we don't unset $vars['url'] we end up with /my/url?url=my/url&foo=bar etc

$vars = $this->getVars(); $vars = $this->getVars();
unset($vars['url']); unset($vars['url']);


if (count($vars)) { if (count($vars)) {
$url .= '?' . http_build_query($vars); $url .= '?' . http_build_query($vars);
} }
} }
else if(strpos($url, "?") !== false) { else if(strpos($url, "?") !== false) {
$url = substr($url, 0, strpos($url, "?")); $url = substr($url, 0, strpos($url, "?"));
} }


return $url; return $url;
} }


/** /**
Expand Down Expand Up @@ -501,9 +501,9 @@ public function allParams() {
* @return string * @return string
*/ */
public function shiftAllParams() { public function shiftAllParams() {
$keys = array_keys($this->allParams); $keys = array_keys($this->allParams);
$values = array_values($this->allParams); $values = array_values($this->allParams);
$value = array_shift($values); $value = array_shift($values);


// push additional unparsed URL parts onto the parameter stack // push additional unparsed URL parts onto the parameter stack
if(array_key_exists($this->unshiftedButParsedParts, $this->dirParts)) { if(array_key_exists($this->unshiftedButParsedParts, $this->dirParts)) {
Expand Down Expand Up @@ -636,10 +636,10 @@ public function allParsed() {
*/ */
public function getIP() { public function getIP() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
//check ip from share internet //check ip from share internet
return $_SERVER['HTTP_CLIENT_IP']; return $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
//to check ip is pass from proxy //to check ip is pass from proxy
return $_SERVER['HTTP_X_FORWARDED_FOR']; return $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif(isset($_SERVER['REMOTE_ADDR'])) { } elseif(isset($_SERVER['REMOTE_ADDR'])) {
return $_SERVER['REMOTE_ADDR']; return $_SERVER['REMOTE_ADDR'];
Expand All @@ -655,12 +655,12 @@ public function getIP() {
* @return array * @return array
*/ */
public function getAcceptMimetypes($includeQuality = false) { public function getAcceptMimetypes($includeQuality = false) {
$mimetypes = array(); $mimetypes = array();
$mimetypesWithQuality = explode(',',$this->getHeader('Accept')); $mimetypesWithQuality = explode(',',$this->getHeader('Accept'));
foreach($mimetypesWithQuality as $mimetypeWithQuality) { foreach($mimetypesWithQuality as $mimetypeWithQuality) {
$mimetypes[] = ($includeQuality) ? $mimetypeWithQuality : preg_replace('/;.*/', '', $mimetypeWithQuality); $mimetypes[] = ($includeQuality) ? $mimetypeWithQuality : preg_replace('/;.*/', '', $mimetypeWithQuality);
} }
return $mimetypes; return $mimetypes;
} }


/** /**
Expand Down

0 comments on commit b0121b5

Please sign in to comment.