Skip to content

Commit

Permalink
Require PHP 8.4+
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Jan 12, 2025
1 parent 10ff0d8 commit 4a69171
Show file tree
Hide file tree
Showing 22 changed files with 492 additions and 784 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: "8.3"
php-version: "8.4"
ini-values: memory_limit=-1
tools: phpcs, cs2pr
- name: Run PHP Code Sniffer
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.3"
php-version: "8.4"
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
strategy:
matrix:
php-version:
- "8.2"
- "8.3"
- "8.4"
steps:
- name: Checkout
Expand Down Expand Up @@ -41,7 +39,7 @@ jobs:
run: make test-coveralls

- name: Upload code coverage
if: ${{ matrix.php-version == '8.3' }}
if: ${{ matrix.php-version == '8.4' }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# CHANGELOG

## v7.0

### New Requirements

PHP 8.4+

### New features

None

### Deprecated Features

None

### Backward Incompatible Changes

None

### Other changes

None



## v4.x to v6.0

### New requirements
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PHP_VERSION=8.2
ARG PHP_VERSION=8.4
FROM php:${PHP_VERSION}-cli-bookworm

RUN <<-EOF
Expand Down
12 changes: 1 addition & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,7 @@ test-cleanup:
@rm -rf tests/sandbox/*

.PHONY: test-container
test-container: test-container-82

.PHONY: test-container-82
test-container-82:
@-docker-compose run --rm app82 bash
@docker-compose down -v

.PHONY: test-container-83
test-container-83:
@-docker-compose run --rm app83 bash
@docker-compose down -v
test-container: test-container-84

.PHONY: test-container-84
test-container-84:
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "icanboogie/http",
"type": "library",
"version": "6.0",
"version": "7.0",
"description": "Provides an API to handle HTTP requests.",
"keywords": [
"http",
Expand Down Expand Up @@ -29,10 +29,10 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.2",
"php": ">=8.4",
"ext-mbstring": "*",
"icanboogie/accessor": "^6.0",
"icanboogie/event": "^6.0"
"icanboogie/event": "^7.0"
},
"require-dev": {
"ext-fileinfo": "*",
Expand Down
24 changes: 1 addition & 23 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,10 @@
---
services:
app82:
build:
context: .
args:
PHP_VERSION: "8.2"
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-http'
volumes:
- .:/app:delegated
- ~/.composer:/root/.composer:delegated
working_dir: /app
app83:
build:
context: .
args:
PHP_VERSION: "8.3"
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-http'
volumes:
- .:/app:delegated
- ~/.composer:/root/.composer:delegated
working_dir: /app
app84:
build:
context: .
args:
PHP_VERSION: "8.4.0RC3"
PHP_VERSION: "8.4"
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-http'
volumes:
Expand Down
52 changes: 23 additions & 29 deletions lib/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@
* @property-read int|null $error Error code, one of `UPLOAD_ERR_*`.
* @property-read FormattedString|null $error_message A formatted message representing the error.
* @property-read string $pathname Pathname of the file.
* @property-read string $extension The extension of the file. If any, the dot is included e.g.
* ".zip".
* @property-read string $unsuffixed_name The name of the file without its extension.
* @property-read bool $is_uploaded `true` if the file is uploaded, `false` otherwise.
* @property-read bool $is_valid `true` if the file is valid, `false` otherwise.
* See: {@see get_is_valid()}.
*/
class File implements ToArray, FileOptions
{
Expand All @@ -48,10 +43,7 @@ class File implements ToArray, FileOptions
* @uses get_size
* @uses get_error
* @uses get_error_message
* @uses get_is_valid
* @uses get_pathname
* @uses get_extension
* @uses get_is_uploaded
*/
use AccessorTrait;

Expand Down Expand Up @@ -243,11 +235,12 @@ protected function get_error_message(): ?FormattedString
* A file is considered valid if it has no error code, if it has a size,
* if it has either a temporary name or a pathname and that the file actually exists.
*/
protected function get_is_valid(): bool
{
return !$this->error
&& $this->size
&& ($this->tmp_name || ($this->pathname && file_exists($this->pathname)));
public bool $is_valid {
get {
return !$this->error
&& $this->size
&& ($this->tmp_name || ($this->pathname && file_exists($this->pathname)));
}
}

private ?string $pathname = null;
Expand Down Expand Up @@ -334,32 +327,33 @@ public function to_array(): array
}

/**
* Returns the extension of the file, if any.
* The extension of the file, if any.
*
* **Note**: The extension includes the dot e.g. ".zip". The extension is always in lower case.
*/
protected function get_extension(): ?string
{
if (!$this->name) {
return null;
}
public ?string $extension {
get {
if (!$this->name) {
return null;
}

$extension = pathinfo($this->name, PATHINFO_EXTENSION);
$extension = pathinfo($this->name, PATHINFO_EXTENSION);

if (!$extension) {
return null;
}
if (!$extension) {
return null;
}

return '.' . strtolower($extension);
return '.' . strtolower($extension);
}
}

/**
* Checks if a file is uploaded.
* Whether the file was uploaded.
*/
protected function get_is_uploaded(): bool
{
return $this->tmp_name && is_uploaded_file($this->tmp_name);
}
public bool $is_uploaded
{
get => $this->tmp_name && is_uploaded_file($this->tmp_name);
}

/**
* Checks if the file matches a MIME class, a MIME type, or a file extension.
Expand Down
12 changes: 6 additions & 6 deletions lib/FileOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@ interface FileOptions
/**
* Name of the file.
*/
public const OPTION_NAME = 'name';
public const string OPTION_NAME = 'name';

/**
* MIME type of the file.
*/
public const OPTION_TYPE = 'type';
public const string OPTION_TYPE = 'type';

/**
* Size of the file.
*/
public const OPTION_SIZE = 'size';
public const string OPTION_SIZE = 'size';

/**
* Temporary filename.
*/
public const OPTION_TMP_NAME = 'tmp_name';
public const string OPTION_TMP_NAME = 'tmp_name';

/**
* Error code, one of `UPLOAD_ERR_*`.
*/
public const OPTION_ERROR = 'error';
public const string OPTION_ERROR = 'error';

/**
* Pathname of the file.
*/
public const OPTION_PATHNAME = 'pathname';
public const string OPTION_PATHNAME = 'pathname';
}
Loading

0 comments on commit 4a69171

Please sign in to comment.