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

Minimum PHP 7.4 #74

Merged
merged 4 commits into from
Aug 17, 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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
php-versions: ['8.0', '8.1']
coverage: ['pcov']
code-analysis: ['no']
include:
- php-versions: '7.1'
- php-versions: '7.4'
coverage: 'none'
code-analysis: 'yes'
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ composer.lock
tests/cov/
tests/.phpunit.result.cache
.php_cs.cache
.php-cs-fixer.cache
7 changes: 4 additions & 3 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

$config = PhpCsFixer\Config::create();
$config->getFinder()
$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__);
Copy link
Member

Choose a reason for hiding this comment

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

append([__FILE__])


$config = new PhpCsFixer\Config();
$config->setRules([
'@PSR1' => true,
'@Symfony' => true
]);

$config->setFinder($finder);
return $config;
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"homepage": "http://sabre.io/uri/",
"license": "BSD-3-Clause",
"require": {
"php": "^7.1 || ^8.0"
"php": "^7.4 || ^8.0"
},
"authors": [
{
Expand Down Expand Up @@ -37,9 +37,9 @@
}
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~2.19.3",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0"
"friendsofphp/php-cs-fixer": "^3.9",
"phpstan/phpstan": "^1.8",
"phpunit/phpunit" : "^9.0"
},
"scripts": {
"phpstan": [
Expand Down
2 changes: 1 addition & 1 deletion lib/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ class Version
/**
* Full version number.
*/
const VERSION = '2.2.3';
public const VERSION = '2.3.0';
}
6 changes: 5 additions & 1 deletion lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function resolve(string $basePath, string $newPath): string
$newPathParts = [];
foreach ($pathParts as $pathPart) {
switch ($pathPart) {
//case '' :
// case '' :
case '.':
break;
case '..':
Expand Down Expand Up @@ -322,6 +322,10 @@ function ($matches) {
$uri
);

if (null === $uri) {
throw new InvalidUriException('Invalid, or could not parse URI');
Comment on lines +325 to +326
Copy link
Contributor Author

@phil-davis phil-davis Aug 11, 2022

Choose a reason for hiding this comment

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

Note: this keeps phpstan happy, otherwise it gets worried that preg_replace_callback might return null and that would cause trouble in later code that uses $uri. I couldn't find a value for the input parameter $uri that will actually cause null - I have to pass in a string (otherwise PHP will get an error on the call itself). So this seems untestable. And thus we get the Codecov warning.

}

$result = [
'scheme' => null,
'host' => null,
Expand Down
10 changes: 5 additions & 5 deletions tests/Uri/BuildTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace Sabre\Uri;

class BuildTest extends \PHPUnit\Framework\TestCase
use PHPUnit\Framework\TestCase;

class BuildTest extends TestCase
{
/**
* @dataProvider buildUriData
*
* @param string $value
*/
public function testBuild($value): void
public function testBuild(string $value): void
{
/** @var array<string, int|string> $parsedUrl */
$parsedUrl = parse_url($value);
Expand All @@ -25,7 +25,7 @@ public function testBuild($value): void
/**
* @return array<int, array<int, string>>
*/
public function buildUriData()
public function buildUriData(): array
{
return [
['http://example.org/'],
Expand Down
13 changes: 6 additions & 7 deletions tests/Uri/NormalizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

namespace Sabre\Uri;

class NormalizeTest extends \PHPUnit\Framework\TestCase
use PHPUnit\Framework\TestCase;

class NormalizeTest extends TestCase
{
/**
* @dataProvider normalizeData
*
* @param string $in
* @param string $out
*/
public function testNormalize($in, $out): void
public function testNormalize(string $in, string $out): void
{
$this->assertEquals(
$out,
Expand All @@ -23,7 +22,7 @@ public function testNormalize($in, $out): void
/**
* @return array<int, array<int, string>>
*/
public function normalizeData()
public function normalizeData(): array
{
return [
['https://example.org/', 'https://example.org/'],
Expand All @@ -41,7 +40,7 @@ public function normalizeData()
['http://example.org:80/', 'http://example.org/'],
// See issue #6. parse_url corrupts strings like this, but only on
// macs.
//[ 'http://example.org/有词法别名.zh','http://example.org/%E6%9C%89%E8%AF%8D%E6%B3%95%E5%88%AB%E5%90%8D.zh'],
// [ 'http://example.org/有词法别名.zh','http://example.org/%E6%9C%89%E8%AF%8D%E6%B3%95%E5%88%AB%E5%90%8D.zh'],
];
}
}
16 changes: 8 additions & 8 deletions tests/Uri/ParseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

namespace Sabre\Uri;

class ParseTest extends \PHPUnit\Framework\TestCase
use PHPUnit\Framework\TestCase;

class ParseTest extends TestCase
{
/**
* @dataProvider parseData
*
* @param string $in
* @param string $out
* @param array<int, array<int, array<string, int|string|null>|string>> $out
*/
public function testParse($in, $out): void
public function testParse(string $in, array $out): void
{
$this->assertEquals(
$out,
Expand All @@ -23,10 +24,9 @@ public function testParse($in, $out): void
/**
* @dataProvider parseData
*
* @param string $in
* @param string $out
* @param array<int, array<int, array<string, int|string|null>|string>> $out
*/
public function testParseFallback($in, $out): void
public function testParseFallback(string $in, array $out): void
{
$result = _parse_fallback($in);
$result = $result + [
Expand Down Expand Up @@ -54,7 +54,7 @@ public function testParseFallbackShouldThrowInvalidUriException(): void
}

/**
* @return array<int, array<int, string|array>>
* @return array<int, array<int, array<string, int|string|null>|string>>
*/
public function parseData(): array
{
Expand Down
10 changes: 4 additions & 6 deletions tests/Uri/ResolveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@

namespace Sabre\Uri;

class ResolveTest extends \PHPUnit\Framework\TestCase
use PHPUnit\Framework\TestCase;

class ResolveTest extends TestCase
{
/**
* @dataProvider resolveData
*
* @param string $base
* @param string $update
* @param string $expected
*
* @throws InvalidUriException
*/
public function testResolve($base, $update, $expected): void
public function testResolve(string $base, string $update, string $expected): void
{
$this->assertEquals(
$expected,
Expand Down
4 changes: 3 additions & 1 deletion tests/Uri/SplitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace Sabre\Uri;

class SplitTest extends \PHPUnit\Framework\TestCase
use PHPUnit\Framework\TestCase;

class SplitTest extends TestCase
{
public function testSplit(): void
{
Expand Down