Permalink
Browse files

Merge pull request #2347 from simonwelsh/3.1

Scrutinizer fixes
  • Loading branch information...
2 parents abe09c7 + 151baee commit 4af619e5a0248c6bf90c6b282ea3b8873e5dfad3 @chillu chillu committed Aug 21, 2013
View
@@ -3,3 +3,5 @@ tools:
-
scope: file
command: php tests/phpcs_runner.php %pathname%
+ filter:
+ excluded_paths: ["*/css/*", "css/*", "thirdparty/*", "*/jquery-changetracker/*", "parsers/HTML/BBCodeParser/*", "*/SSTemplateParser.php$", "docs/*", "*/images/*"]
@@ -49,8 +49,10 @@ public function testExtraCssAndJavascript() {
$this->session()->inst_set('loggedInAs', $admin->ID);
$response = $this->get('LeftAndMainTest_Controller');
- $this->assertRegExp('/tests\/assets\/LeftAndMainTest.css/i', $response->getBody(), "body should contain custom css");
- $this->assertRegExp('/tests\/assets\/LeftAndMainTest.js/i', $response->getBody(), "body should contain custom js");
+ $this->assertRegExp('/tests\/assets\/LeftAndMainTest.css/i', $response->getBody(),
+ "body should contain custom css");
+ $this->assertRegExp('/tests\/assets\/LeftAndMainTest.js/i', $response->getBody(),
+ "body should contain custom js");
}
/**
@@ -96,7 +96,6 @@ public function convertDataObjectWithoutHeader(DataObject $obj, $fields = null,
$items = $obj->$relName();
if ($items) {
foreach($items as $item) {
- //$href = Director::absoluteURL($this->config()->api_base . "$className/$id/$relName/$item->ID");
$href = Director::absoluteURL($this->config()->api_base . "$relClass/$item->ID");
$xml .= "<$relClass href=\"$href.xml\" id=\"{$item->ID}\"></$relClass>\n";
}
View
@@ -257,7 +257,7 @@ public static function factory($for, $frontend='Output', $frontendOptions=null)
foreach(array('any', $for) as $name) {
if(isset(self::$backend_picks[$name])) {
- if(self::$backend_picks[$name]['priority'] > $backend_priority) {
+ if(self::$backend_picks[$name]['priority'] > $backend_priority) {
$backend_name = self::$backend_picks[$name]['name'];
$backend_priority = self::$backend_picks[$name]['priority'];
}
View
@@ -75,7 +75,8 @@
if(!isset($databaseConfig) || !isset($databaseConfig['database']) || !$databaseConfig['database']) {
echo "\nPlease configure your database connection details. You can do this by creating a file
called _ss_environment.php in either of the following locations:\n\n";
- echo " - " . BASE_PATH . DIRECTORY_SEPARATOR . "_ss_environment.php\n - " . dirname(BASE_PATH) . DIRECTORY_SEPARATOR . "_ss_environment.php\n\n";
+ echo " - " . BASE_PATH . DIRECTORY_SEPARATOR . "_ss_environment.php\n - ";
+ echo dirname(BASE_PATH) . DIRECTORY_SEPARATOR . "_ss_environment.php\n\n";
echo <<<ENVCONTENT
Put the following content into this file:
@@ -4,20 +4,20 @@
* @subpackage testing
*/
class BehatFixtureFactory extends \FixtureFactory {
- public function createObject($name, $identifier, $data = null) {
- if(!$data) $data = array();
+ public function createObject($name, $identifier, $data = null) {
+ if(!$data) $data = array();
- // Copy identifier to some visible property unless its already defined.
- // Exclude files, since they generate their own named based on the file path.
- if(!$name != 'File' && !is_subclass_of($name, 'File')) {
- foreach(array('Name', 'Title') as $fieldName) {
- if(singleton($name)->hasField($fieldName) && !isset($data[$fieldName])) {
- $data[$fieldName] = $identifier;
- break;
- }
- }
- }
+ // Copy identifier to some visible property unless its already defined.
+ // Exclude files, since they generate their own named based on the file path.
+ if(!$name != 'File' && !is_subclass_of($name, 'File')) {
+ foreach(array('Name', 'Title') as $fieldName) {
+ if(singleton($name)->hasField($fieldName) && !isset($data[$fieldName])) {
+ $data[$fieldName] = $identifier;
+ break;
+ }
+ }
+ }
- return parent::createObject($name, $identifier, $data);
- }
-}
+ return parent::createObject($name, $identifier, $data);
+ }
+}
@@ -210,7 +210,8 @@ public function findExistingObject($record) {
if(is_string($duplicateCheck)) {
$SQL_fieldName = Convert::raw2sql($duplicateCheck);
- if(!isset($record[$SQL_fieldName]) || empty($record[$SQL_fieldName])) { //skip current duplicate check if field value is empty
+ if(!isset($record[$SQL_fieldName]) || empty($record[$SQL_fieldName])) {
+ //skip current duplicate check if field value is empty
continue;
}
View
@@ -501,12 +501,24 @@ public function tearDown() {
}
}
- public static function assertContains($needle, $haystack, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) {
+ public static function assertContains(
+ $needle,
+ $haystack,
+ $message = '',
+ $ignoreCase = FALSE,
+ $checkForObjectIdentity = TRUE
+ ) {
if ($haystack instanceof DBField) $haystack = (string)$haystack;
parent::assertContains($needle, $haystack, $message, $ignoreCase, $checkForObjectIdentity);
}
- public static function assertNotContains($needle, $haystack, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) {
+ public static function assertNotContains(
+ $needle,
+ $haystack,
+ $message = '',
+ $ignoreCase = FALSE,
+ $checkForObjectIdentity = TRUE
+ ) {
if ($haystack instanceof DBField) $haystack = (string)$haystack;
parent::assertNotContains($needle, $haystack, $message, $ignoreCase, $checkForObjectIdentity);
}
@@ -255,12 +255,14 @@ public function croppedResize($width, $height) {
$new->setBackgroundColor($backgroundColor);
if(($geo['width']/$width) < ($geo['height']/$height)){
- $new->cropImage($geo['width'], floor($height*$geo['width']/$width), 0, (($geo['height']-($height*$geo['width']/$width))/2));
+ $new->cropImage($geo['width'], floor($height*$geo['width']/$width),
+ 0, (($geo['height']-($height*$geo['width']/$width))/2));
}else{
- $new->cropImage(ceil($width*$geo['height']/$height), $geo['height'], (($geo['width']-($width*$geo['height']/$height))/2), 0);
+ $new->cropImage(ceil($width*$geo['height']/$height), $geo['height'],
+ (($geo['width']-($width*$geo['height']/$height))/2), 0);
}
$new->ThumbnailImage($width,$height,true);
return $new;
}
}
-}
+}
@@ -56,7 +56,9 @@ public function performReadonlyTransformation() {
}
public function Value() {
- return Convert::raw2xml($this->value ? _t('CheckboxField.YESANSWER', 'Yes') : _t('CheckboxField.NOANSWER', 'No'));
+ return Convert::raw2xml($this->value ?
+ _t('CheckboxField.YESANSWER', 'Yes') :
+ _t('CheckboxField.NOANSWER', 'No'));
}
}
@@ -181,7 +181,8 @@ public function setValue($value, $obj = null) {
public function saveInto(DataObjectInterface $record) {
$fieldname = $this->name;
$relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null;
- if($fieldname && $record && $relation && ($relation instanceof RelationList || $relation instanceof UnsavedRelationList)) {
+ if($fieldname && $record && $relation &&
+ ($relation instanceof RelationList || $relation instanceof UnsavedRelationList)) {
$idList = array();
if($this->value) foreach($this->value as $id => $bool) {
if($bool) {
@@ -66,7 +66,7 @@ class ConfirmedPasswordField extends FormField {
*
* @var FieldList
*/
- public $children;
+ public $children;
/**
* @param string $name
@@ -360,7 +360,8 @@ public function MediaForm() {
'<h4>' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.ADDURL', 'Add URL')) . '</h4>'),
$remoteURL = new TextField('RemoteURL', 'http://'),
new LiteralField('addURLImage',
- '<button class="action ui-action-constructive ui-button field add-url" data-icon="addMedia">'._t('HtmlEditorField.BUTTONADDURL', 'Add url').'</button>')
+ '<button class="action ui-action-constructive ui-button field add-url" data-icon="addMedia">' .
+ _t('HtmlEditorField.BUTTONADDURL', 'Add url').'</button>')
);
$remoteURL->addExtraClass('remoteurl');
@@ -640,7 +641,8 @@ protected function getFieldsForFlash($url, $file) {
*/
protected function getFieldsForImage($url, $file) {
if($file->File instanceof Image) {
- $formattedImage = $file->File->generateFormattedImage('SetWidth', Config::inst()->get('Image', 'asset_preview_width'));
+ $formattedImage = $file->File->generateFormattedImage('SetWidth',
+ Config::inst()->get('Image', 'asset_preview_width'));
$thumbnailURL = $formattedImage ? $formattedImage->URL : $url;
} else {
$thumbnailURL = $url;
@@ -179,7 +179,8 @@ public function saveInto(DataObjectInterface $record) {
if($this->multiple) {
$fieldname = $this->name;
$relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null;
- if($fieldname && $record && $relation && ($relation instanceof RelationList || $relation instanceof UnsavedRelationList)) {
+ if($fieldname && $record && $relation &&
+ ($relation instanceof RelationList || $relation instanceof UnsavedRelationList)) {
$idList = (is_array($this->value)) ? array_values($this->value) : array();
if(!$record->ID) {
$record->write(); // record needs to have an ID in order to set relationships
View
@@ -676,7 +676,8 @@ public static function get_time_format() {
),
'be' => array(
'name' => 'Belarusian',
- 'native' => '&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103; &#1084;&#1086;&#1074;&#1072;'
+ 'native' =>
+ '&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103; &#1084;&#1086;&#1074;&#1072;'
),
'bn' => array(
'name' => 'Bengali',
@@ -1024,7 +1025,8 @@ public static function get_time_format() {
),
'be_BY' => array(
'name' => 'Belarusian',
- 'native' => '&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103; &#1084;&#1086;&#1074;&#1072;'
+ 'native' =>
+ '&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103; &#1084;&#1086;&#1074;&#1072;'
),
'bn_BD' => array(
'name' => 'Bengali',
View
@@ -1157,7 +1157,7 @@ public function table() {
$result .= "<tr>";
foreach($record as $k => $v) {
$result .= "<th>" . Convert::raw2xml($k) . "</th> ";
- }
+ }
$result .= "</tr> \n";
}
@@ -1234,7 +1234,7 @@ public function next() {
*/
public function valid() {
if(!$this->queryHasBegun) $this->next();
- return $this->currentRecord !== false;
+ return $this->currentRecord !== false;
}
/**
View
@@ -98,13 +98,15 @@ public function validate(ValidationResult $validationResult) {
* should not change this.
* @param int $nodeCountThreshold See {@link self::$node_threshold_total}
* @param callable $nodeCountCallback Called with the node count, which gives the callback an opportunity
- * to intercept the query. Useful e.g. to avoid excessive children listings (Arguments: $parent, $numChildren)
+ * to intercept the query. Useful e.g. to avoid excessive children listings
+ * (Arguments: $parent, $numChildren)
*
* @return string
*/
public function getChildrenAsUL($attributes = "", $titleEval = '"<li>" . $child->Title', $extraArg = null,
$limitToMarked = false, $childrenMethod = "AllChildrenIncludingDeleted",
- $numChildrenMethod = "numChildren", $rootCall = true, $nodeCountThreshold = null, $nodeCountCallback = null) {
+ $numChildrenMethod = "numChildren", $rootCall = true,
+ $nodeCountThreshold = null, $nodeCountCallback = null) {
if(!is_numeric($nodeCountThreshold)) {
$nodeCountThreshold = Config::inst()->get('Hierarchy', 'node_threshold_total');
@@ -154,8 +156,8 @@ public function getChildrenAsUL($attributes = "", $titleEval = '"<li>" . $child-
$output .= $nodeCountWarning;
$child->markClosed();
} else {
- $output .= $child->getChildrenAsUL("", $titleEval, $extraArg, $limitToMarked, $childrenMethod,
- $numChildrenMethod, false, $nodeCountThreshold);
+ $output .= $child->getChildrenAsUL("", $titleEval, $extraArg, $limitToMarked,
+ $childrenMethod, $numChildrenMethod, false, $nodeCountThreshold);
}
} elseif($child->isTreeOpened()) {
// Since we're not loading children, don't mark it as open either
@@ -245,12 +245,14 @@ protected function extractTags($content) {
if ($i == 0) {
$err = 'Close tag "'.$tags[$i]['close'].'" is the first found tag, so has no related open tag';
- }
+ }
else if (!$tags[$i-1]['open']) {
- $err = 'Close tag "'.$tags[$i]['close'].'" preceded by another close tag "'.$tags[$i-1]['close'].'"';
+ $err = 'Close tag "'.$tags[$i]['close'].'" preceded by another close tag "'.
+ $tags[$i-1]['close'].'"';
}
else if ($tags[$i]['close'] != $tags[$i-1]['open']) {
- $err = 'Close tag "'.$tags[$i]['close'].'" doesn\'t match preceding open tag "'.$tags[$i-1]['open'].'"';
+ $err = 'Close tag "'.$tags[$i]['close'].'" doesn\'t match preceding open tag "'.
+ $tags[$i-1]['open'].'"';
}
if($err) {
@@ -332,7 +334,8 @@ protected function replaceAttributeTagsWithContent($htmlvalue) {
$tags = $this->extractTags($node->nodeValue);
if($tags) {
- $node->nodeValue = $this->replaceTagsWithText($node->nodeValue, $tags, function($idx, $tag) use ($parser){
+ $node->nodeValue = $this->replaceTagsWithText($node->nodeValue, $tags,
+ function($idx, $tag) use ($parser){
$content = $parser->callShortcode($tag['open'], $tag['attrs'], $tag['content']);
if ($content === false) {
@@ -381,7 +384,8 @@ protected function findParentsForMarkers($nodes) {
do {
$parent = $parent->parentNode;
}
- while($parent instanceof DOMElement && !in_array(strtolower($parent->tagName), self::$block_level_elements));
+ while($parent instanceof DOMElement &&
+ !in_array(strtolower($parent->tagName), self::$block_level_elements));
$node->setAttribute('data-parentid', count($parents));
$parents[] = $parent;
@@ -451,7 +455,8 @@ protected function moveMarkerToCompliantHome($node, $parent, $location) {
else if($location == self::INLINE) {
if(in_array(strtolower($node->tagName), self::$block_level_elements)) {
user_error(
- 'Requested to insert block tag '.$node->tagName.' inline - probably this will break HTML compliance',
+ 'Requested to insert block tag '.$node->tagName.
+ ' inline - probably this will break HTML compliance',
E_USER_WARNING
);
}
@@ -461,7 +466,7 @@ protected function moveMarkerToCompliantHome($node, $parent, $location) {
user_error('Unknown value for $location argument '.$location, E_USER_ERROR);
}
}
-
+
/**
* Given a node with represents a shortcode marker and some information about the shortcode, call the
* shortcode handler & replace the marker with the actual content
@@ -484,7 +489,7 @@ protected function replaceMarkerWithContent($node, $tag) {
$content = $tag['text'];
}
else {
- // self::$error_behavior == self::STRIP - NOP
+ // self::$error_behavior == self::STRIP - NOP
}
}
@@ -549,7 +554,8 @@ public function parse($content) {
if(!$parent) {
if($location !== self::INLINE) {
- user_error("Parent block for shortcode couldn't be found, but location wasn't INLINE", E_USER_ERROR);
+ user_error("Parent block for shortcode couldn't be found, but location wasn't INLINE",
+ E_USER_ERROR);
}
}
else {
View
@@ -113,11 +113,13 @@ public function getCMSFields() {
} elseif($record && $record->ID) {
// TODO Mark disabled once chosen.js supports it
// $groupsField->setDisabledItems(array($group->ID));
- $form->Fields()->replaceField('DirectGroups', $groupsField->performReadonlyTransformation());
+ $form->Fields()->replaceField('DirectGroups',
+ $groupsField->performReadonlyTransformation());
}
}
});
- $memberList = GridField::create('Members',false, $this->DirectMembers(), $config)->addExtraClass('members_grid');
+ $memberList = GridField::create('Members',false, $this->DirectMembers(), $config)
+ ->addExtraClass('members_grid');
// @todo Implement permission checking on GridField
//$memberList->setPermissions(array('edit', 'delete', 'export', 'add', 'inlineadd'));
$fields->addFieldToTab('Root.Members', $memberList);
@@ -689,7 +689,7 @@ public function changepassword() {
* @return Form Returns the lost password form
*/
public function ChangePasswordForm() {
- return Object::create('ChangePasswordForm', $this, 'ChangePasswordForm');
+ return Object::create('ChangePasswordForm', $this, 'ChangePasswordForm');
}
/**
Oops, something went wrong. Retry.

0 comments on commit 4af619e

Please sign in to comment.