From 974691ee8ec6568b17d1066b377cc173df875709 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Mon, 27 Mar 2023 20:49:05 +0000 Subject: [PATCH] use camcelCase instead of snake case, re #2030 Merge request studip/studip!1668 --- lib/classes/Request.class.php | 6 +++--- lib/classes/restapi/Router.php | 2 +- public/api.php | 2 +- public/assets.php | 2 +- public/dispatch.php | 2 +- public/install.php | 2 +- public/plugins.php | 2 +- public/web_migrate.php | 2 +- tests/unit/lib/classes/RequestTest.php | 6 +++--- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/classes/Request.class.php b/lib/classes/Request.class.php index 27ed629595d..efdd2d6f5f4 100644 --- a/lib/classes/Request.class.php +++ b/lib/classes/Request.class.php @@ -150,7 +150,7 @@ class Request implements ArrayAccess, IteratorAggregate * Return the filename of the currently executing script. * @return string */ - public static function script_name(): string + public static function scriptName(): string { return $_SERVER['SCRIPT_NAME']; } @@ -159,9 +159,9 @@ class Request implements ArrayAccess, IteratorAggregate * Returns the complete path info including duplicated slashes. * $_SERVER['PATH_INFO'] will remove them. */ - public static function path_info(): string + public static function pathInfo(): string { - $script_name = self::script_name(); + $script_name = self::scriptName(); $script_name = preg_quote($script_name, '#'); $script_name = str_replace('/', '/+', $script_name); diff --git a/lib/classes/restapi/Router.php b/lib/classes/restapi/Router.php index 7650919f728..232e9fe9d2e 100644 --- a/lib/classes/restapi/Router.php +++ b/lib/classes/restapi/Router.php @@ -523,7 +523,7 @@ class Router private function normalizeDispatchURI($uri) { - return $uri ?? \Request::path_info(); + return $uri ?? \Request::pathInfo(); } private function normalizeRequestMethod($method) diff --git a/public/api.php b/public/api.php index 1376ae4cd56..762c140b587 100644 --- a/public/api.php +++ b/public/api.php @@ -45,7 +45,7 @@ namespace RESTAPI { // Initialize RESTAPI plugins \PluginEngine::getPlugins('RESTAPIPlugin'); - $uri = \Request::path_info(); + $uri = \Request::pathInfo(); // Check version if (defined('RESTAPI\\VERSION') && preg_match('~^/v(\d+)~i', $uri, $match)) { diff --git a/public/assets.php b/public/assets.php index 824f84c4102..a0baa6dcd05 100644 --- a/public/assets.php +++ b/public/assets.php @@ -15,7 +15,7 @@ require_once '../lib/bootstrap.php'; // Obtain request information -$uri = ltrim(Request::path_info(), '/'); +$uri = ltrim(Request::pathInfo(), '/'); list($type, $id) = explode('/', $uri, 2); // Setup response diff --git a/public/dispatch.php b/public/dispatch.php index 3bd9291cb20..68d03996bef 100644 --- a/public/dispatch.php +++ b/public/dispatch.php @@ -22,4 +22,4 @@ require '../lib/bootstrap.php'; URLHelper::setBaseUrl($GLOBALS['ABSOLUTE_URI_STUDIP']); $dispatcher = app(\Trails_Dispatcher::class); -$dispatcher->dispatch(Request::path_info()); +$dispatcher->dispatch(Request::pathInfo()); diff --git a/public/install.php b/public/install.php index c10f928f46a..52f4bf01a52 100644 --- a/public/install.php +++ b/public/install.php @@ -55,7 +55,7 @@ if (!function_exists('_')) { $GLOBALS['template_factory'] = new Flexi_TemplateFactory('../templates/'); # get plugin class from request -$dispatch_to = ltrim(Request::path_info(), '/'); +$dispatch_to = ltrim(Request::pathInfo(), '/'); $dispatcher = new Trails_Dispatcher( '../app', $_SERVER['SCRIPT_NAME'], 'admin/install'); $dispatcher->dispatch("admin/install/{$dispatch_to}"); diff --git a/public/plugins.php b/public/plugins.php index 368113dc9e3..99373a053fd 100644 --- a/public/plugins.php +++ b/public/plugins.php @@ -27,7 +27,7 @@ try { require_once 'lib/seminar_open.php'; // get plugin class from request - $dispatch_to = Request::path_info(); + $dispatch_to = Request::pathInfo(); list($plugin_class, $unconsumed) = PluginEngine::routeRequest($dispatch_to); // handle legacy forum plugin URLs diff --git a/public/web_migrate.php b/public/web_migrate.php index 02eeb956e08..79fba05449e 100644 --- a/public/web_migrate.php +++ b/public/web_migrate.php @@ -34,7 +34,7 @@ $_language_path = init_i18n($_SESSION['_language']); $GLOBALS['template_factory'] = new Flexi_TemplateFactory('../templates/'); # get plugin class from request -$dispatch_to = Request::path_info() ?: ''; +$dispatch_to = Request::pathInfo() ?: ''; $dispatcher = app(\Trails_Dispatcher::class); $dispatcher->trails_uri = $_SERVER['SCRIPT_NAME']; diff --git a/tests/unit/lib/classes/RequestTest.php b/tests/unit/lib/classes/RequestTest.php index 00351968839..dd1adc9bc28 100644 --- a/tests/unit/lib/classes/RequestTest.php +++ b/tests/unit/lib/classes/RequestTest.php @@ -112,20 +112,20 @@ class RequestTest extends \Codeception\Test\Unit public function testScriptName(): void { $this->setScriptName('/index.php'); - $this->assertEquals('/index.php', Request::script_name()); + $this->assertEquals('/index.php', Request::scriptName()); } /** * @depends testPath * @depends testScriptName - * @covers Request::path_info + * @covers Request::pathInfo * @dataProvider PathProvider */ public function testPathInfo(string $request_uri, string $script_name, string $expected): void { $this->setScriptName($script_name); $this->setRequestUri($request_uri); - $this->assertEquals($expected, Request::path_info()); + $this->assertEquals($expected, Request::pathInfo()); } /** -- GitLab