Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  add support for immutable 5
  use blackbox 5
  use psalm 5
  test against php 8.3
  • Loading branch information
Baptouuuu committed Sep 16, 2023
2 parents 95befc6 + ff89936 commit f62167f
Show file tree
Hide file tree
Showing 35 changed files with 83 additions and 60 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['8.1', '8.2']
php-version: ['8.2', '8.3']
dependencies: ['lowest', 'highest']
name: 'PHPUnit'
steps:
Expand All @@ -33,7 +33,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['8.1', '8.2']
php-version: ['8.2', '8.3']
dependencies: ['lowest', 'highest']
name: 'Coverage'
steps:
Expand All @@ -60,7 +60,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.1', '8.2']
php-version: ['8.2', '8.3']
dependencies: ['lowest', 'highest']
name: 'Psalm'
steps:
Expand All @@ -81,7 +81,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.1']
php-version: ['8.2']
name: 'CS'
steps:
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
composer.lock
vendor
.phpunit.result.cache
.phpunit.cache
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 6.4.0 - 2023-09-16

### Added

- Support for `innmind/immutable:~5.0`

### Removed

- Support for PHP `8.1`

## 6.3.0 - 2023-04-30

### Added
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"issues": "http://github.com/Innmind/Http/issues"
},
"require": {
"php": "~8.1",
"php": "~8.2",
"innmind/url": "~4.0",
"innmind/immutable": "~4.13",
"innmind/immutable": "~4.15|~5.0",
"innmind/filesystem": "^6.3.2",
"innmind/time-continuum": "~3.0",
"innmind/stream": "~4.0",
Expand All @@ -36,10 +36,10 @@
},
"require-dev": {
"psr/http-message": "^1.0",
"phpunit/phpunit": "^9.5.14",
"vimeo/psalm": "~4.21",
"phpunit/phpunit": "~10.2",
"vimeo/psalm": "~5.12",
"nikic/php-parser": "^4.13.2",
"innmind/black-box": "^4.17",
"innmind/black-box": "~5.5",
"innmind/coding-standard": "~2.0",
"symfony/process": "^6.2"
}
Expand Down
25 changes: 15 additions & 10 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" printerClass="Innmind\BlackBox\PHPUnit\ResultPrinterV9" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>.</directory>
</include>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" cacheDirectory=".phpunit.cache">
<extensions>
<bootstrap class="Innmind\BlackBox\PHPUnit\Extension">
</bootstrap>
</extensions>
<coverage/>
<php>
<env name="BLACKBOX_SET_SIZE" value="1"/>
</php>
Expand All @@ -17,4 +13,13 @@
<directory>./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>.</directory>
</include>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</source>
</phpunit>
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<psalm
errorLevel="1"
resolveFromConfigFile="true"
findUnusedCode="false"
findUnusedBaselineEntry="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand Down
2 changes: 1 addition & 1 deletion src/Content/Multipart.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function reduce($carry, callable $reducer)
public function size(): Maybe
{
// +2 for carriage return and -- (for last boundary)
$boundary = $this->boundaryStr()->toEncoding('ASCII')->length() + 2;
$boundary = $this->boundaryStr()->toEncoding(Str\Encoding::ascii)->length() + 2;

if ($this->parts->empty()) {
return Maybe::just(new Size($boundary + $boundary));
Expand Down
2 changes: 1 addition & 1 deletion src/Content/Multipart/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function size(): Maybe
$this
->chunks()
->fold(new Concat)
->toEncoding('ASCII')
->toEncoding(Str\Encoding::ascii)
->length(),
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Content/Multipart/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function size(): Maybe
$headers = $this
->headers()
->fold(new Concat)
->toEncoding('ASCII')
->toEncoding(Str\Encoding::ascii)
->length();

return $this
Expand Down
1 change: 1 addition & 0 deletions src/Factory/Header/AcceptCharsetFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function __invoke(Str $name, Str $value): Maybe

/**
* @psalm-suppress NamedArgumentNotAllowed
* @psalm-suppress InvalidArgument
* @var Maybe<Header>
*/
return Maybe::all(...$values->toList())->map(
Expand Down
1 change: 1 addition & 0 deletions src/Factory/Header/AcceptEncodingFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function __invoke(Str $name, Str $value): Maybe

/**
* @psalm-suppress NamedArgumentNotAllowed
* @psalm-suppress InvalidArgument
* @var Maybe<Header>
*/
return Maybe::all(...$values->toList())->map(
Expand Down
6 changes: 5 additions & 1 deletion src/Factory/Header/AcceptFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function __invoke(Str $name, Str $value): Maybe

/**
* @psalm-suppress NamedArgumentNotAllowed
* @psalm-suppress InvalidArgument
* @var Maybe<Header>
*/
return Maybe::all(...$values->toList())->map(
Expand Down Expand Up @@ -90,7 +91,10 @@ private function buildParams(Str $params): Maybe
return Maybe::just([]);
}

/** @var Maybe<list<Parameter>> */
/**
* @psalm-suppress InvalidArgument
* @var Maybe<list<Parameter>>
*/
return Maybe::all(...$params->toList())->map(
static fn(Parameter ...$params) => $params,
);
Expand Down
1 change: 1 addition & 0 deletions src/Factory/Header/AcceptLanguageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function __invoke(Str $name, Str $value): Maybe

/**
* @psalm-suppress NamedArgumentNotAllowed
* @psalm-suppress InvalidArgument
* @var Maybe<Header>
*/
return Maybe::all(...$values->toList())->map(
Expand Down
1 change: 1 addition & 0 deletions src/Factory/Header/AllowFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function __invoke(Str $name, Str $value): Maybe

/**
* @psalm-suppress NamedArgumentNotAllowed
* @psalm-suppress InvalidArgument
* @var Maybe<Header>
*/
return Maybe::all(...$values->toList())->map(
Expand Down
5 changes: 4 additions & 1 deletion src/Factory/Header/CacheControlFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ public function __invoke(Str $name, Str $value): Maybe
return Maybe::nothing();
}

/** @var Maybe<Header> */
/**
* @psalm-suppress InvalidArgument
* @var Maybe<Header>
*/
return Maybe::all(...$values->toList())->map(
static fn(CacheControlValue ...$values) => new CacheControl(...$values),
);
Expand Down
1 change: 1 addition & 0 deletions src/Factory/Header/ContentLanguageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function __invoke(Str $name, Str $value): Maybe

/**
* @psalm-suppress NamedArgumentNotAllowed
* @psalm-suppress InvalidArgument
* @var Maybe<Header>
*/
return Maybe::all(...$values->toList())->map(
Expand Down
1 change: 1 addition & 0 deletions src/Factory/Header/CookieFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function __invoke(Str $name, Str $value): Maybe

/**
* @psalm-suppress NamedArgumentNotAllowed
* @psalm-suppress InvalidArgument
* @var Maybe<Header>
*/
return Maybe::all(...$values->toList())->map(
Expand Down
2 changes: 2 additions & 0 deletions src/Factory/Header/LinkFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public function __invoke(Str $name, Str $value): Maybe

/**
* @psalm-suppress NamedArgumentNotAllowed
* @psalm-suppress InvalidArgument
* @var Maybe<Header>
*/
return Maybe::all(...$links->toList())->map(
Expand Down Expand Up @@ -105,6 +106,7 @@ private function buildParams(Str $params): Maybe

/**
* @psalm-suppress MixedArgumentTypeCoercion
* @psalm-suppress InvalidArgument
* @var Maybe<Map<string, Parameter\Parameter>>
*/
return Maybe::all(...$params->toList())->map(
Expand Down
1 change: 0 additions & 1 deletion src/Header/ContentLengthValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public function __construct(int $length)
throw new DomainException((string) $length);
}

/** @var 0|positive-int */
$this->length = $length;
}

Expand Down
4 changes: 2 additions & 2 deletions src/ResponseSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ final class ResponseSender implements Sender
/**
* @param callable(File\Content): Sequence<Str> $chunk
*/
public function __construct(Clock $clock, callable $chunk = new Chunk)
public function __construct(Clock $clock, callable $chunk = null)
{
$this->clock = $clock;
$this->chunk = $chunk;
$this->chunk = $chunk ?? new Chunk;
}

public function __invoke(Response $response): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Factory/Header/HostFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testReturnNothingWhenNotExpectedHeader()
));
}

public function cases(): array
public static function cases(): array
{
return [
['www.w3.org:8080'],
Expand Down
29 changes: 10 additions & 19 deletions tests/File/InputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public function testForeach()
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
)->between(1, 10))
->then(function($lines) {
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
$content = Input::of(Stream::open(Path::of('/tmp/test_content')));
Expand Down Expand Up @@ -77,8 +76,7 @@ public function testMap()
->forAll(
Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
),
)->between(1, 10),
$this->strings(),
)
->then(function($lines, $replacement) {
Expand Down Expand Up @@ -106,8 +104,7 @@ public function testFlatMap()
->forAll(
Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
),
)->between(1, 10),
$this->strings(),
)
->then(function($lines, $newLine) {
Expand All @@ -132,8 +129,7 @@ public function testFilter()
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
)->between(1, 10))
->then(function($lines) {
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
$content = Input::of(Stream::open(Path::of('/tmp/test_content')));
Expand All @@ -154,8 +150,7 @@ public function testLines()
->forAll(
Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
),
)->between(1, 10),
$this->strings(),
)
->then(function($lines, $replacement) {
Expand Down Expand Up @@ -190,8 +185,7 @@ public function testReduce()
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
)->between(1, 10))
->then(function($lines) {
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
$content = Input::of(Stream::open(Path::of('/tmp/test_content')));
Expand All @@ -211,8 +205,7 @@ public function testToString()
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
)->between(1, 10))
->then(function($lines) {
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
$content = Input::of(Stream::open(Path::of('/tmp/test_content')));
Expand All @@ -226,10 +219,9 @@ public function testSize()
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(0, 10),
))
)->between(0, 10))
->then(function($lines) {
$expectedSize = Str::of(\implode("\n", $lines))->toEncoding('ASCII')->length();
$expectedSize = Str::of(\implode("\n", $lines))->toEncoding(Str\Encoding::ascii)->length();
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
$content = Input::of(Stream::open(Path::of('/tmp/test_content')));

Expand All @@ -248,8 +240,7 @@ public function testThrowWhenTryingToLoadInputTwice()
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
)->between(1, 10))
->then(function($lines) {
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
$content = Input::of(Stream::open(Path::of('/tmp/test_content')));
Expand Down
2 changes: 1 addition & 1 deletion tests/Header/AcceptCharsetValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testThrowWhenInvalidAcceptCharsetValue($value)
new AcceptCharsetValue($value, new Quality(1));
}

public function invalids(): array
public static function invalids(): array
{
return [
['@'],
Expand Down
2 changes: 1 addition & 1 deletion tests/Header/AcceptEncodingValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testThrowWhenInvalidAcceptEncodingValue($value)
new AcceptEncodingValue($value, new Quality(1));
}

public function invalids(): array
public static function invalids(): array
{
return [
['@'],
Expand Down
2 changes: 1 addition & 1 deletion tests/Header/AcceptLanguageValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testThrowWhenInvalidAcceptLanguageValue($value)
new AcceptLanguageValue($value, new Quality(1));
}

public function invalids(): array
public static function invalids(): array
{
return [
['@'],
Expand Down
Loading

0 comments on commit f62167f

Please sign in to comment.