Skip to content

Commit 0e1cf3e

Browse files
committed
Require PHP 8.4+
1 parent 5f066eb commit 0e1cf3e

File tree

9 files changed

+42
-122
lines changed

9 files changed

+42
-122
lines changed

.github/workflows/code-style.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
uses: shivammathur/setup-php@v2
1515
with:
1616
coverage: none
17-
php-version: "8.3"
17+
php-version: "8.4"
1818
ini-values: memory_limit=-1
1919
tools: phpcs, cs2pr
2020
- name: Run PHP Code Sniffer

.github/workflows/static-analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Install PHP
1515
uses: shivammathur/setup-php@v2
1616
with:
17-
php-version: "8.3"
17+
php-version: "8.4"
1818
ini-values: memory_limit=-1
1919
tools: composer:v2
2020
- name: Cache dependencies

.github/workflows/test.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ jobs:
1111
strategy:
1212
matrix:
1313
php-version:
14-
- "8.2"
15-
- "8.3"
1614
- "8.4"
1715
steps:
1816
- name: Checkout
@@ -41,7 +39,7 @@ jobs:
4139
run: make test-coveralls
4240

4341
- name: Upload code coverage
44-
if: ${{ matrix.php-version == '8.3' }}
42+
if: ${{ matrix.php-version == '8.4' }}
4543
env:
4644
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4745
run: |

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG PHP_VERSION=8.2
1+
ARG PHP_VERSION=8.4
22
FROM php:${PHP_VERSION}-cli-bookworm
33

44
RUN <<-EOF

Makefile

+1-11
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,7 @@ test-cleanup:
3131
@rm -rf tests/sandbox/*
3232

3333
.PHONY: test-container
34-
test-container: test-container-82
35-
36-
.PHONY: test-container-82
37-
test-container-82:
38-
@-docker-compose run --rm app82 bash
39-
@docker-compose down -v
40-
41-
.PHONY: test-container-83
42-
test-container-83:
43-
@-docker-compose run --rm app83 bash
44-
@docker-compose down -v
34+
test-container: test-container-84
4535

4636
.PHONY: test-container-84
4737
test-container-84:

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "icanboogie/http",
33
"type": "library",
4-
"version": "6.0",
4+
"version": "7.0",
55
"description": "Provides an API to handle HTTP requests.",
66
"keywords": [
77
"http",
@@ -29,10 +29,10 @@
2929
"minimum-stability": "dev",
3030
"prefer-stable": true,
3131
"require": {
32-
"php": ">=8.2",
32+
"php": ">=8.4",
3333
"ext-mbstring": "*",
3434
"icanboogie/accessor": "^6.0",
35-
"icanboogie/event": "^6.0"
35+
"icanboogie/event": "^7.0"
3636
},
3737
"require-dev": {
3838
"ext-fileinfo": "*",

docker-compose.yaml

+1-23
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,10 @@
11
---
22
services:
3-
app82:
4-
build:
5-
context: .
6-
args:
7-
PHP_VERSION: "8.2"
8-
environment:
9-
PHP_IDE_CONFIG: 'serverName=icanboogie-http'
10-
volumes:
11-
- .:/app:delegated
12-
- ~/.composer:/root/.composer:delegated
13-
working_dir: /app
14-
app83:
15-
build:
16-
context: .
17-
args:
18-
PHP_VERSION: "8.3"
19-
environment:
20-
PHP_IDE_CONFIG: 'serverName=icanboogie-http'
21-
volumes:
22-
- .:/app:delegated
23-
- ~/.composer:/root/.composer:delegated
24-
working_dir: /app
253
app84:
264
build:
275
context: .
286
args:
29-
PHP_VERSION: "8.4.0RC3"
7+
PHP_VERSION: "8.4"
308
environment:
319
PHP_IDE_CONFIG: 'serverName=icanboogie-http'
3210
volumes:

lib/Headers.php

+23-58
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,8 @@
6969
class Headers implements ArrayAccess, IteratorAggregate
7070
{
7171
/**
72-
* @uses get_cache_control
73-
* @uses set_cache_control
74-
* @uses get_content_disposition
75-
* @uses set_content_disposition
76-
* @uses get_content_length
77-
* @uses set_content_length
78-
* @uses get_content_type
79-
* @uses set_content_type
8072
* @uses get_date
8173
* @uses set_date
82-
* @uses get_etag
83-
* @uses set_etag
8474
* @uses get_expires
8575
* @uses set_expires
8676
* @uses get_if_modified_since
@@ -332,45 +322,30 @@ public function getIterator(): ArrayIterator
332322
return new ArrayIterator($this->fields);
333323
}
334324

335-
private function get_cache_control(): Headers\CacheControl
336-
{
337-
return $this->offsetGet(self::HEADER_CACHE_CONTROL);
338-
}
339-
340-
private function set_cache_control(mixed $value): void
341-
{
342-
$this->offsetSet(self::HEADER_CACHE_CONTROL, $value);
343-
}
344-
345-
private function get_content_length(): ?int
346-
{
347-
return $this->offsetGet(self::HEADER_CONTENT_LENGTH);
348-
}
349-
350-
private function set_content_length(?int $value): void
351-
{
352-
$this->offsetSet(self::HEADER_CONTENT_LENGTH, $value);
353-
}
354-
355-
private function get_content_disposition(): Headers\ContentDisposition
356-
{
357-
return $this->offsetGet(self::HEADER_CONTENT_DISPOSITION);
325+
public Headers\CacheControl $cache_control {
326+
get => $this->offsetGet(self::HEADER_CACHE_CONTROL);
327+
set { $this->offsetSet(self::HEADER_CACHE_CONTROL, $value); }
358328
}
359329

360-
private function set_content_disposition(mixed $value): void
361-
{
362-
$this->offsetSet(self::HEADER_CONTENT_DISPOSITION, $value);
330+
public ?int $content_length {
331+
get => $this->offsetGet(self::HEADER_CONTENT_LENGTH);
332+
set { $this->offsetSet(self::HEADER_CONTENT_LENGTH, $value); }
363333
}
364334

365-
private function get_content_type(): Headers\ContentType
366-
{
367-
return $this->offsetGet(self::HEADER_CONTENT_TYPE);
335+
public Headers\ContentDisposition $content_disposition {
336+
get => $this->offsetGet(self::HEADER_CONTENT_DISPOSITION);
337+
set { $this->offsetSet(self::HEADER_CONTENT_DISPOSITION, $value); }
368338
}
369339

370-
private function set_content_type(mixed $value): void
371-
{
372-
$this->offsetSet(self::HEADER_CONTENT_TYPE, $value);
340+
public Headers\ContentType|string|null $content_type {
341+
get => $this->offsetGet(self::HEADER_CONTENT_TYPE);
342+
set { $this->offsetSet(self::HEADER_CONTENT_TYPE, $value); }
373343
}
344+
//
345+
// public Headers\Date|string|null $date {
346+
// get => $this->offsetGet(self::HEADER_DATE);
347+
// set { $this->offsetSet(self::HEADER_DATE, $value); }
348+
// }
374349

375350
private function get_date(): Headers\Date
376351
{
@@ -382,14 +357,9 @@ private function set_date(mixed $value): void
382357
$this->offsetSet(self::HEADER_DATE, $value);
383358
}
384359

385-
private function get_etag(): ?string
386-
{
387-
return $this->offsetGet(self::HEADER_ETAG);
388-
}
389-
390-
private function set_etag(?string $value): void
391-
{
392-
$this->offsetSet(self::HEADER_ETAG, $value);
360+
public ?string $etag {
361+
get => $this->offsetGet(self::HEADER_ETAG);
362+
set { $this->offsetSet(self::HEADER_ETAG, $value); }
393363
}
394364

395365
private function get_expires(): Headers\Date
@@ -432,14 +402,9 @@ private function set_last_modified(mixed $value): void
432402
$this->offsetSet(self::HEADER_LAST_MODIFIED, $value);
433403
}
434404

435-
private function get_location(): ?string
436-
{
437-
return $this->offsetGet(self::HEADER_LOCATION);
438-
}
439-
440-
private function set_location(?string $value): void
441-
{
442-
$this->offsetSet(self::HEADER_LOCATION, $value);
405+
public ?string $location {
406+
get => $this->offsetGet(self::HEADER_LOCATION);
407+
set { $this->offsetSet(self::HEADER_LOCATION, $value); }
443408
}
444409

445410
private function get_retry_after(): int|Headers\Date|null

lib/Headers/HeaderParameter.php

+10-21
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace ICanBoogie\HTTP\Headers;
1313

14-
use ICanBoogie\Accessor\AccessorTrait;
15-
1614
use function ICanBoogie\remove_accents;
1715
use function mb_convert_encoding;
1816
use function mb_detect_encoding;
@@ -27,29 +25,17 @@
2725
/**
2826
* Representation of a header parameter.
2927
*
30-
* @property-read string $attribute The attribute of the parameter.
31-
* @property-read string $charset The charset of the parameter's value.
32-
*
33-
* @link https://tools.ietf.org/html/rfc2231
34-
* @link https://tools.ietf.org/html/rfc5987
35-
* @link https://greenbytes.de/tech/tc2231/#attwithfn2231utf8
28+
* @see https://tools.ietf.org/html/rfc2231
29+
* @see https://tools.ietf.org/html/rfc5987
30+
* @see https://greenbytes.de/tech/tc2231/#attwithfn2231utf8
3631
*/
3732
class HeaderParameter
3833
{
3934
/**
40-
* @uses get_attribute
41-
* @uses get_charset
35+
* The charset of the parameter's value.
4236
*/
43-
use AccessorTrait;
44-
45-
protected function get_attribute(): string
46-
{
47-
return $this->attribute;
48-
}
49-
50-
protected function get_charset(): string
51-
{
52-
return mb_detect_encoding($this->value) ?: 'ISO-8859-1';
37+
public string $charset {
38+
get => mb_detect_encoding($this->value) ?: 'ISO-8859-1';
5339
}
5440

5541
/**
@@ -129,8 +115,11 @@ public static function to_ascii(string $str): string
129115
return preg_replace('/[^\x20-\x7F]+/', '', $str);
130116
}
131117

118+
/**
119+
*@property-read string $attribute The attribute of the parameter.
120+
*/
132121
public function __construct(
133-
protected string $attribute,
122+
public readonly string $attribute,
134123
public ?string $value = null,
135124
public ?string $language = null
136125
) {

0 commit comments

Comments
 (0)