Merge pull request #3180 from Icinga/feature/url-static-self

Url: prefer static over self
This commit is contained in:
lippserd 2018-01-16 10:52:25 +01:00 committed by GitHub
commit 705f3a49d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -105,10 +105,10 @@ class Url
public static function fromRequest($params = array(), $request = null) public static function fromRequest($params = array(), $request = null)
{ {
if ($request === null) { if ($request === null) {
$request = self::getRequest(); $request = static::getRequest();
} }
$url = new Url(); $url = new static();
$url->setPath(ltrim($request->getPathInfo(), '/')); $url->setPath(ltrim($request->getPathInfo(), '/'));
// $urlParams = UrlParams::fromQueryString($request->getQuery()); // $urlParams = UrlParams::fromQueryString($request->getQuery());
@ -161,7 +161,7 @@ class Url
public static function fromPath($url, array $params = array(), $request = null) public static function fromPath($url, array $params = array(), $request = null)
{ {
if ($request === null) { if ($request === null) {
$request = self::getRequest(); $request = static::getRequest();
} }
if (! is_string($url)) { if (! is_string($url)) {
@ -171,7 +171,7 @@ class Url
); );
} }
$urlObject = new Url(); $urlObject = new static();
if ($url === '#') { if ($url === '#') {
$urlObject->setPath($url); $urlObject->setPath($url);
@ -250,7 +250,7 @@ class Url
*/ */
public static function urlAddFilterOptional($url, $filter, $optional) public static function urlAddFilterOptional($url, $filter, $optional)
{ {
$url = Url::fromPath($url); $url = static::fromPath($url);
$f = $filter; $f = $filter;
if (isset($optional)) { if (isset($optional)) {
$f = Filter::matchAll($filter, $optional); $f = Filter::matchAll($filter, $optional);
@ -782,8 +782,8 @@ class Url
*/ */
public function matches($url) public function matches($url)
{ {
if (! $url instanceof Url) { if (! $url instanceof static) {
$url = Url::fromPath($url); $url = static::fromPath($url);
} }
return (string) $url === (string) $this; return (string) $url === (string) $this;
} }