From 6dc41e50a06f80b893d7dbbe303f676b51bfb37a Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Tue, 26 Mar 2019 16:29:58 +1300 Subject: [PATCH] MINOR Linting fixes --- src/Forms/GridField/GridFieldLevelup.php | 4 +-- src/includes/constants.php | 40 +++++++++++++----------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/Forms/GridField/GridFieldLevelup.php b/src/Forms/GridField/GridFieldLevelup.php index d16d41a88..90a2f0003 100644 --- a/src/Forms/GridField/GridFieldLevelup.php +++ b/src/Forms/GridField/GridFieldLevelup.php @@ -86,9 +86,9 @@ class GridFieldLevelup implements GridField_HTMLProvider )); $template = SSViewer::get_templates_by_class($this, '', __CLASS__); - return array( + return [ 'before' => $forTemplate->renderWith($template), - ); + ]; } public function setAttributes($attrs) diff --git a/src/includes/constants.php b/src/includes/constants.php index a619db5f2..e4e300ffa 100644 --- a/src/includes/constants.php +++ b/src/includes/constants.php @@ -41,11 +41,12 @@ 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']) + && preg_match( + '#^(?.*)(/|\\\\)vendor(/|\\\\)composer(/|\\\\)autoload_real.php#', + $backtraceItem['file'], + $matches + )) { return realpath($matches['base']) ?: DIRECTORY_SEPARATOR; } } @@ -132,23 +133,24 @@ if (!defined('BASE_URL')) { // When htaccess redirects from /base to /base/public folder, we need to only include /public // in the BASE_URL if it's also present in the request - if ($baseURL - && PUBLIC_DIR - && isset($_SERVER['REQUEST_URI']) - && substr($baseURL, -strlen(PUBLIC_DIR)) === PUBLIC_DIR + if (!$baseURL + || !PUBLIC_DIR + || !isset($_SERVER['REQUEST_URI']) + || substr($baseURL, -strlen(PUBLIC_DIR)) !== PUBLIC_DIR ) { - $requestURI = $_SERVER['REQUEST_URI']; - // Check if /base/public or /base are in the request - foreach ([$baseURL, dirname($baseURL)] as $candidate) { - if (stripos($requestURI, $candidate) === 0) { - return $candidate; - } - } - // Ambiguous - return ''; + return $baseURL; } - return $baseURL; + $requestURI = $_SERVER['REQUEST_URI']; + // Check if /base/public or /base are in the request + foreach ([$baseURL, dirname($baseURL)] as $candidate) { + if (stripos($requestURI, $candidate) === 0) { + return $candidate; + } + } + + // Ambiguous + return ''; })); }