From 46b9530d88a654912190e6af249ac4d4196944a4 Mon Sep 17 00:00:00 2001 From: Serge Latyntcev Date: Fri, 18 Oct 2019 15:31:39 +1300 Subject: [PATCH] PSR2 linting fixes --- src/Core/CoreKernel.php | 11 ++++++----- src/ORM/DataObject.php | 11 +++++------ src/Security/PermissionCheckboxSetField.php | 14 +++++++------- src/includes/constants.php | 18 +++++++++++------- tests/php/ORM/DataListTest.php | 6 ++---- 5 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/Core/CoreKernel.php b/src/Core/CoreKernel.php index ceb3ac352..934e30028 100644 --- a/src/Core/CoreKernel.php +++ b/src/Core/CoreKernel.php @@ -285,18 +285,19 @@ class CoreKernel implements Kernel // Build error response $dv = new DebugView(); - $body = - $dv->renderHeader() . + $body = implode([ + $dv->renderHeader(), $dv->renderInfo( "Configuration Error", Director::absoluteBaseURL() - ) . + ), $dv->renderParagraph( 'You need to replace your _ss_environment.php file with a .env file, or with environment variables.

' . 'See the ' . 'Environment Management docs for more information.' - ) . - $dv->renderFooter(); + ), + $dv->renderFooter() + ]); // Raise error $response = new HTTPResponse($body, 500); diff --git a/src/ORM/DataObject.php b/src/ORM/DataObject.php index e0ed2aeb8..4a74a35ae 100644 --- a/src/ORM/DataObject.php +++ b/src/ORM/DataObject.php @@ -2102,12 +2102,11 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity // If we haven't been written yet, we can't save these relations, so use a list that handles this case if (!$id) { if (!isset($this->unsavedRelations[$componentName])) { - $this->unsavedRelations[$componentName] = - new UnsavedRelationList( - $manyManyComponent['parentClass'], - $componentName, - $manyManyComponent['childClass'] - ); + $this->unsavedRelations[$componentName] = new UnsavedRelationList( + $manyManyComponent['parentClass'], + $componentName, + $manyManyComponent['childClass'] + ); } return $this->unsavedRelations[$componentName]; } diff --git a/src/Security/PermissionCheckboxSetField.php b/src/Security/PermissionCheckboxSetField.php index ef039bd4b..3f91e33e7 100644 --- a/src/Security/PermissionCheckboxSetField.php +++ b/src/Security/PermissionCheckboxSetField.php @@ -268,15 +268,15 @@ class PermissionCheckboxSetField extends FormField } } if ($this->readonly) { + $message = _t( + 'SilverStripe\\Security\\Permission.UserPermissionsIntro', + 'Assigning groups to this user will adjust the permissions they have.' + . ' See the groups section for details of permissions on individual groups.' + ); + return "\n"; } else { diff --git a/src/includes/constants.php b/src/includes/constants.php index 44dbc9a1f..a64f2948a 100644 --- a/src/includes/constants.php +++ b/src/includes/constants.php @@ -41,13 +41,17 @@ if (!defined('BASE_PATH')) { define('BASE_PATH', call_user_func(function () { // Determine BASE_PATH based on the composer autoloader foreach (debug_backtrace() as $backtraceItem) { - if (isset($backtraceItem['file']) - && preg_match( - '#^(?.*)(/|\\\\)vendor(/|\\\\)composer(/|\\\\)autoload_real.php#', - $backtraceItem['file'], - $matches - ) - ) { + if (!isset($backtraceItem['file'])) { + continue; + } + + $matched = preg_match( + '#^(?.*)(/|\\\\)vendor(/|\\\\)composer(/|\\\\)autoload_real.php#', + $backtraceItem['file'], + $matches + ); + + if ($matched) { return realpath($matches['base']) ?: DIRECTORY_SEPARATOR; } } diff --git a/tests/php/ORM/DataListTest.php b/tests/php/ORM/DataListTest.php index baecfeaf7..e3daaabc1 100755 --- a/tests/php/ORM/DataListTest.php +++ b/tests/php/ORM/DataListTest.php @@ -1039,11 +1039,9 @@ class DataListTest extends SapphireTest ->leftJoin( 'DataObjectTest_Team', '"DataObjectTest_Team"."ID" = "DataObjectTest_TeamComment"."TeamID"' - )->filter( - array( + )->filter([ 'Title' => 'Team 1' - ) - ); + ]); $this->assertEquals(2, $list->count()); $values = $list->column('Name');