Skip to content
Snippets Groups Projects
Commit 974691ee authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by Elmar Ludwig
Browse files

use camcelCase instead of snake case, re #2030

Merge request studip/studip!1668
parent e605e048
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -523,7 +523,7 @@ class Router
private function normalizeDispatchURI($uri)
{
return $uri ?? \Request::path_info();
return $uri ?? \Request::pathInfo();
}
private function normalizeRequestMethod($method)
......
......@@ -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)) {
......
......@@ -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
......
......@@ -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());
......@@ -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}");
......@@ -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
......
......@@ -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'];
......
......@@ -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());
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment