Skip to content
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.0', '8.1', '8.2', '8.3','8.4']
php-versions: ['8.3','8.4']
coverage: ['xdebug']
code-style: ['no']
code-analysis: ['no']
rector-check: ['no']
include:
- php-versions: '7.4'
- php-versions: '8.2'
coverage: 'xdebug'
code-style: 'yes'
code-analysis: 'yes'
Expand Down Expand Up @@ -73,5 +73,5 @@ jobs:
run: vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-clover clover.xml

- name: Code Coverage
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@v6
if: matrix.coverage != 'none'
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ composer.lock

# Tests
tests/cov/
.phpunit.result.cache
tests/.phpunit.cache
tests/.phpunit.result.cache
.php_cs.cache
.php-cs-fixer.cache
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"homepage" : "https://github.com/fruux/sabre-http",
"license" : "BSD-3-Clause",
"require" : {
"php" : "^7.4 || ^8.0",
"php" : "^8.2",
"ext-mbstring" : "*",
"ext-ctype" : "*",
"ext-curl" : "*",
Expand All @@ -18,7 +18,7 @@
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpstan/extension-installer": "^1.4",
"phpunit/phpunit" : "^9.6",
"phpunit/phpunit" : "^10.5",
Copy link
Copy Markdown
Member

@staabm staabm May 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could even go phpunit 11+ with php 8.2+
(but maybe in a separate PR)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could even go phpunit 11+ with php 8.2+ (but maybe in a separate PR)

True. For some reason I only went to PHPunit10 in the other repos. So I will be consistent for now.

"rector/rector": "^2.4"
},
"suggest" : {
Expand Down Expand Up @@ -74,6 +74,9 @@
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
},
"platform": {
"php": "8.2"
}
}
}
2 changes: 1 addition & 1 deletion lib/Auth/AWS.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ protected function getAmzHeaders(): string
$amzHeaders = [];
$headers = $this->request->getHeaders();
foreach ($headers as $headerName => $headerValue) {
if (0 === strpos(strtolower($headerName), 'x-amz-')) {
if (str_starts_with(strtolower($headerName), 'x-amz-')) {
$amzHeaders[strtolower($headerName)] = str_replace(["\r\n"], [' '], $headerValue[0])."\n";
}
}
Expand Down
34 changes: 14 additions & 20 deletions lib/Auth/AbstractAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,23 @@
*/
abstract class AbstractAuth
{
/**
* Authentication realm.
*/
protected string $realm;

/**
* Request object.
*/
protected RequestInterface $request;

/**
* Response object.
*/
protected ResponseInterface $response;

/**
* Creates the object.
*/
public function __construct(string $realm, RequestInterface $request, ResponseInterface $response)
{
$this->realm = $realm;
$this->request = $request;
$this->response = $response;
public function __construct(
/**
* Authentication realm.
*/
protected string $realm,
/**
* Request object.
*/
protected RequestInterface $request,
/**
* Response object.
*/
protected ResponseInterface $response,
) {
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ public function __construct()
{
// See https://github.com/sabre-io/http/pull/115#discussion_r241292068
// Preserve compatibility for sub-classes that implement their own method `parseCurlResult`
$separatedHeaders = self::class === get_class($this);
$separatedHeaders = self::class === static::class;

$this->curlSettings = [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_NOBODY => false,
CURLOPT_USERAGENT => 'sabre-http/'.Version::VERSION.' (http://sabre.io/)',
];
if ($separatedHeaders) {
$this->curlSettings[CURLOPT_HEADERFUNCTION] = [$this, 'receiveCurlHeader'];
$this->curlSettings[CURLOPT_HEADERFUNCTION] = $this->receiveCurlHeader(...);
} else {
$this->curlSettings[CURLOPT_HEADER] = true;
}
Expand Down
13 changes: 5 additions & 8 deletions lib/ClientHttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@
*/
class ClientHttpException extends \Exception implements HttpException
{
/**
* Response object.
*/
protected ResponseInterface $response;

/**
* Constructor.
*/
public function __construct(ResponseInterface $response)
public function __construct(/**
* Response object.
*/
protected ResponseInterface $response)
{
$this->response = $response;
parent::__construct($response->getStatusText(), $response->getStatus());
parent::__construct($this->response->getStatusText(), $this->response->getStatus());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function getPath(): string
$uri = Uri\normalize($uri);
$baseUri = Uri\normalize($this->getBaseUrl());

if (0 === strpos($uri, $baseUri)) {
if (str_starts_with($uri, $baseUri)) {
// We're not interested in the query part (everything after the ?).
[$uri] = explode('?', $uri);

Expand Down Expand Up @@ -260,7 +260,7 @@ public function __toString(): string
foreach ($this->getHeaders() as $key => $value) {
foreach ($value as $v) {
if ('Authorization' === $key) {
[$v] = explode(' ', $v, 2);
[$v] = explode(' ', (string) $v, 2);
$v .= ' REDACTED';
}
$out .= $key.': '.$v."\r\n";
Expand Down
17 changes: 8 additions & 9 deletions lib/RequestDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@
class RequestDecorator implements RequestInterface
{
use MessageDecoratorTrait;
/**
* The inner request object.
*
* All method calls will be forwarded here.
*/
protected RequestInterface $inner;

/**
* Constructor.
*/
public function __construct(RequestInterface $inner)
{
$this->inner = $inner;
public function __construct(
/**
* The inner request object.
*
* All method calls will be forwarded here.
*/
protected RequestInterface $inner,
) {
}

/**
Expand Down
17 changes: 8 additions & 9 deletions lib/ResponseDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@
class ResponseDecorator implements ResponseInterface
{
use MessageDecoratorTrait;
/**
* The inner request object.
*
* All method calls will be forwarded here.
*/
protected ResponseInterface $inner;

/**
* Constructor.
*/
public function __construct(ResponseInterface $inner)
{
$this->inner = $inner;
public function __construct(
/**
* The inner request object.
*
* All method calls will be forwarded here.
*/
protected ResponseInterface $inner,
) {
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Sapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public static function createFromServerArray(array $serverArray): Request
break;

default:
if ('HTTP_' === substr($key, 0, 5)) {
if (str_starts_with($key, 'HTTP_')) {
// It's an HTTP header

// Normalizing it to be prettier
Expand Down
8 changes: 4 additions & 4 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ function parseDate(string $dateString)
}

// append implicit GMT timezone to ANSI C time format
if (false === strpos($dateString, ' GMT')) {
if (!str_contains($dateString, ' GMT')) {
$dateString .= ' GMT';
}

try {
return new \DateTime($dateString, new \DateTimeZone('UTC'));
} catch (\Exception $e) {
} catch (\Exception) {
return false;
}
}
Expand Down Expand Up @@ -109,15 +109,15 @@ function negotiateContentType(?string $acceptHeaderValue, array $availableOption
}

$proposals = array_map(
'Sabre\HTTP\parseMimeType',
\Sabre\HTTP\parseMimeType(...),
explode(',', $acceptHeaderValue)
);

// Ensuring array keys are reset.
$availableOptions = array_values($availableOptions);

$options = array_map(
'Sabre\HTTP\parseMimeType',
\Sabre\HTTP\parseMimeType(...),
$availableOptions
);

Expand Down
18 changes: 0 additions & 18 deletions phpstan-ignore-by-php-version.neon.php

This file was deleted.

6 changes: 0 additions & 6 deletions phpstan-ignore-php74.neon

This file was deleted.

6 changes: 0 additions & 6 deletions phpstan-ignore-php8.neon

This file was deleted.

7 changes: 4 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
includes:
- phpstan-ignore-by-php-version.neon.php

parameters:
level: 6
ignoreErrors:
Expand All @@ -20,3 +17,7 @@ parameters:
message: "#^.* will always evaluate to true\\.$#"
count: 4
path: tests/*
-
message: "#^Left side of || is always false.$#"
count: 23
path: lib/Client.php
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
__DIR__.'/lib',
__DIR__.'/tests',
])
->withPhpSets(false, false, false, false, true)
->withPhpSets(false, true)
->withTypeCoverageLevel(0)
->withDeadCodeLevel(0)
->withCodeQualityLevel(0);
2 changes: 1 addition & 1 deletion tests/HTTP/Auth/AWSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function testValidRequest(): void
public function test401(): void
{
$this->auth->requireLogin();
$test = preg_match('/^AWS$/', $this->response->getHeader('WWW-Authenticate'), $matches);
$test = preg_match('/^AWS$/', (string) $this->response->getHeader('WWW-Authenticate'), $matches);
self::assertTrue(1 === $test, 'The WWW-Authenticate response didn\'t match our pattern');
}

Expand Down
15 changes: 6 additions & 9 deletions tests/HTTP/Auth/DigestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,14 @@ private function getServerTokens(int $qop = Digest::QOP_AUTH): array
{
$this->auth->requireLogin();

switch ($qop) {
case Digest::QOP_AUTH: $qopstr = 'auth';
break;
case Digest::QOP_AUTHINT: $qopstr = 'auth-int';
break;
default: $qopstr = 'auth,auth-int';
break;
}
$qopstr = match ($qop) {
Digest::QOP_AUTH => 'auth',
Digest::QOP_AUTHINT => 'auth-int',
default => 'auth,auth-int',
};

$test = preg_match('/Digest realm="'.self::REALM.'",qop="'.$qopstr.'",nonce="([0-9a-f]*)",opaque="([0-9a-f]*)"/',
$this->response->getHeader('WWW-Authenticate'), $matches);
(string) $this->response->getHeader('WWW-Authenticate'), $matches);

self::assertTrue(1 === $test, 'The WWW-Authenticate response didn\'t match our pattern. We received: '.$this->response->getHeader('WWW-Authenticate'));

Expand Down
2 changes: 1 addition & 1 deletion tests/HTTP/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public function testSendClientError(): void
try {
$client->send($request);
self::fail('send() should have thrown an exception');
} catch (ClientException $e) {
} catch (ClientException) {
}
self::assertTrue($called);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/HTTP/FunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testGetHeaderValuesOnValues2(array $result, array $values1, arra
/**
* @return array<int, array<int, array<int, string>>>
*/
public function getHeaderValuesDataOnValues2(): array
public static function getHeaderValuesDataOnValues2(): array
{
return [
[
Expand Down Expand Up @@ -54,7 +54,7 @@ public function testGetHeaderValues($input, array $output): void
/**
* @return array<int, mixed>
*/
public function getHeaderValuesData(): array
public static function getHeaderValuesData(): array
{
return [
[
Expand Down Expand Up @@ -97,7 +97,7 @@ public function testPrefer($input, array $output): void
/**
* @return array<int, mixed>
*/
public function preferData(): array
public static function preferData(): array
{
return [
[
Expand Down
Loading