Skip to content

Commit

Permalink
PHP 8.4 compatibility (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilario-pierbattista authored Dec 7, 2024
1 parent 9c68674 commit 754cec1
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 20 deletions.
5 changes: 2 additions & 3 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
ARG BASE_IMAGE=php:8.1-cli-alpine3.14
ARG BASE_IMAGE=php:8.1-cli-alpine
FROM ${BASE_IMAGE}

RUN php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer
RUN apk add --no-cache python3 \
&& ln -s /usr/bin/python3 /usr/bin/python
RUN apk add --no-cache python3
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- { php: 8.1, dependencies: "highest" }
- { php: 8.2, dependencies: "highest" }
- { php: 8.3, dependencies: "highest" }
- { php: 8.4, dependencies: "highest" }
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -39,8 +40,10 @@ jobs:
- { phpunit: 10, php: 8.1 }
- { phpunit: 10, php: 8.2 }
- { phpunit: 10, php: 8.3 }
- { phpunit: 10, php: 8.4 }
- { phpunit: 11, php: 8.2 }
- { phpunit: 11, php: 8.3 }
- { phpunit: 11, php: 8.4 }
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The project follows [semantic versioning](http://semver.org/). `BC` stands for a

## [Unreleased]
### Added
* Support for PHP 8.2
* Support for PHP 8.2, 8.3, 8.4
### Removed
* Support for PHP < 8.1
* Support for PHPUnit < 10
Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
.PHONY: run-php-8.1
run-php-8.1:
docker-compose run php-8.1 sh
docker compose run php-8.1 sh

.PHONY: run-php-8.2
run-php-8.2:
docker-compose run php-8.2 sh
docker compose run php-8.2 sh

.PHONY: run-php-8.3
run-php-8.3:
docker compose run php-8.3 sh

.PHONY: run-php-8.4
run-php-8.4:
docker compose run php-8.4 sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ In property-based testing, several properties that the System Under Test must re

## Compatibility

- PHP 8.1, 8.2, 8.3
- PHP 8.1, 8.2, 8.3, 8.4
- PHPUnit 10.x, 11.x

## Installation
Expand Down
22 changes: 20 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
build:
context: .docker
args:
BASE_IMAGE: php:8.1-cli-alpine3.14
BASE_IMAGE: php:8.1-cli-alpine
volumes:
- .:/usr/src/eris
user: 1000:1000
Expand All @@ -18,7 +18,25 @@ services:
build:
context: .docker
args:
BASE_IMAGE: php:8.2-cli-alpine3.16
BASE_IMAGE: php:8.2-cli-alpine
volumes:
- .:/usr/src/eris
user: 1000:1000
working_dir: /usr/src/eris
php-8.3:
build:
context: .docker
args:
BASE_IMAGE: php:8.3-cli-alpine
volumes:
- .:/usr/src/eris
user: 1000:1000
working_dir: /usr/src/eris
php-8.4:
build:
context: .docker
args:
BASE_IMAGE: php:8.4-cli-alpine
volumes:
- .:/usr/src/eris
user: 1000:1000
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/IntegerGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class IntegerGenerator implements Generator
{
private $mapFn;

public function __construct(callable $mapFn = null)
public function __construct(?callable $mapFn = null)
{
if (is_null($mapFn)) {
$this->mapFn = $this->identity();
Expand Down
2 changes: 1 addition & 1 deletion src/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function startPropertyVerification();
* @param null|Exception $exception tells if the test has failed and specifies the exact exception
* @return void
*/
public function endPropertyVerification($ordinaryEvaluations, $iterations, Exception $exception = null);
public function endPropertyVerification($ordinaryEvaluations, $iterations, ?Exception $exception = null);

/**
* @param array $generation of mixed values
Expand Down
4 changes: 2 additions & 2 deletions src/Listener/CollectFrequencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* @see Listeners::collectFrequencies()
*/
function collectFrequencies(callable $collectFunction = null)
function collectFrequencies(?callable $collectFunction = null)
{
return Listeners::collectFrequencies($collectFunction);
}
Expand Down Expand Up @@ -40,7 +40,7 @@ public function __construct($collectFunction = null)
$this->collectFunction = $collectFunction;
}

public function endPropertyVerification($ordinaryEvaluations, $iterations, Exception $exception = null)
public function endPropertyVerification($ordinaryEvaluations, $iterations, ?Exception $exception = null)
{
arsort($this->collectedValues, SORT_NUMERIC);
echo PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion src/Listener/EmptyListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function startPropertyVerification()
{
}

public function endPropertyVerification($ordinaryEvaluations, $iterations, Exception $exception = null)
public function endPropertyVerification($ordinaryEvaluations, $iterations, ?Exception $exception = null)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Listener/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function newGeneration(array $generation, $iteration)
));
}

public function endPropertyVerification($ordinaryEvaluations, $iterations, Exception $exception = null)
public function endPropertyVerification($ordinaryEvaluations, $iterations, ?Exception $exception = null)
{
fclose($this->fp);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Listener/MinimumEvaluations.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private function __construct($threshold)
$this->threshold = $threshold;
}

public function endPropertyVerification($ordinaryEvaluations, $iterations, Exception $exception = null)
public function endPropertyVerification($ordinaryEvaluations, $iterations, ?Exception $exception = null)
{
if ($exception) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Listeners.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

final class Listeners
{
public static function collectFrequencies(callable $collectFunction = null)
public static function collectFrequencies(?callable $collectFunction = null)
{
return new CollectFrequencies($collectFunction);
}
Expand Down
6 changes: 3 additions & 3 deletions src/TestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public function getTestCaseAttributes()
}

$methodAttributes = [];
foreach($reflectionClass->getMethods() as $method) {
if($method->getName() !== $this->name()) {
foreach ($reflectionClass->getMethods() as $method) {
if ($method->getName() !== $this->name()) {
continue;
}
$attributes = $method->getAttributes();

if(!empty($attributes)) {
if (!empty($attributes)) {
foreach ($attributes as $attribute) {
$methodAttributes[$attribute->getName()] = ($attribute)->newInstance();
}
Expand Down

0 comments on commit 754cec1

Please sign in to comment.