Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warning PHP 8.1 #10

Merged
merged 1 commit into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,24 @@ To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->

<!-- see http://www.phpunit.de/wiki/Documentation -->
<phpunit bootstrap="./vendor/autoload.php"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="./vendor/autoload.php"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">

<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>

<testsuites>
<testsuite name="Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>

convertDeprecationsToExceptions="true"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
8 changes: 4 additions & 4 deletions src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected function setQuery($query)

public function getQuery()
{
return http_build_query($this->query, null, "&", PHP_QUERY_RFC3986);
return http_build_query($this->query, "", "&", PHP_QUERY_RFC3986);
}

/**
Expand All @@ -149,13 +149,13 @@ public function getQueryPart($key)
return $this->getFromArray($this->query, $key);
}

private function getFromArray($array, $key)
private function getFromArray($array, $key, $default = null)
{
if (isset($array[$key])) {
return $array[$key];
}

return null;
return $default;
}

private $fragment;
Expand Down Expand Up @@ -238,7 +238,7 @@ public function __construct($uri = null)
$this->username = $user;
$this->password = rawurldecode($this->getFromArray($parsed, 'pass'));
$this->path = preg_replace('~^//~', '', $this->getFromArray($parsed, 'path'));
$this->setQuery($this->getFromArray($parsed, 'query'));
$this->setQuery($this->getFromArray($parsed, 'query', ""));
$this->fragment = $this->getFromArray($parsed, 'fragment');
}

Expand Down