Skip to content

Commit

Permalink
Merge pull request #10 from byjg/4.2.2
Browse files Browse the repository at this point in the history
Fix deprecation warning PHP 8.1
  • Loading branch information
byjg authored Mar 15, 2022
2 parents 61122f7 + 1f99fe7 commit 3e69f1c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
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

0 comments on commit 3e69f1c

Please sign in to comment.