Skip to content

Commit

Permalink
Test against PHP 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Sep 20, 2024
1 parent 1feee90 commit a6e7ace
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 45 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ on:

jobs:
phpcs:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ on:
jobs:
phpstan:
name: phpstan
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.composer/cache
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ on:
jobs:
phpunit:
name: phpunit
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -24,7 +25,7 @@ jobs:
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.composer/cache
Expand Down
2 changes: 1 addition & 1 deletion MIGRATION.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Migration
# Changelog

## v2.x to v6.0

Expand Down
52 changes: 31 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
ARG PHP_VERSION
FROM php:${PHP_VERSION}-cli-buster
FROM php:${PHP_VERSION}-cli-bookworm

RUN apt-get update && \
apt-get install -y autoconf pkg-config && \
pecl channel-update pecl.php.net && \
pecl install xdebug && \
RUN <<-EOF
apt-get update
apt-get install -y autoconf pkg-config
pecl channel-update pecl.php.net
pecl install xdebug
docker-php-ext-enable opcache xdebug
EOF

RUN echo '\
xdebug.client_host=host.docker.internal\n\
xdebug.mode=develop\n\
xdebug.start_with_request=yes\n\
' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN <<-EOF
cat <<-SHELL >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
xdebug.client_host=host.docker.internal
xdebug.mode=develop
xdebug.start_with_request=yes
SHELL

RUN echo '\
display_errors=On\n\
error_reporting=E_ALL\n\
date.timezone=UTC\n\
' >> /usr/local/etc/php/conf.d/php.ini
cat <<-SHELL >> /usr/local/etc/php/conf.d/php.ini
display_errors=On
error_reporting=E_ALL
date.timezone=UTC
SHELL
EOF

ENV COMPOSER_ALLOW_SUPERUSER 1

RUN apt-get update && \
apt-get install unzip && \
curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet && \
mv composer.phar /usr/local/bin/composer && \
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"\n' >> /root/.bashrc
RUN <<-EOF
apt-get update
apt-get install unzip
curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet
mv composer.phar /usr/local/bin/composer
cat <<-SHELL >> /root/.bashrc
export PATH="$HOME/.composer/vendor/bin:$PATH"
SHELL
EOF

RUN composer global require -n squizlabs/php_codesniffer
RUN composer global require squizlabs/php_codesniffer

ENV COMPOSER_ROOT_VERSION 6.0.0
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The icanboogie/common package is free software.
It is released under the terms of the following BSD License.

Copyright (c) 2007-2023 by Olivier Laviale
Copyright (c) 2007-present by Olivier Laviale
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ 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

.PHONY: lint
lint:
@XDEBUG_MODE=off phpcs -s
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ The project is continuously tested by [GitHub actions](https://github.com/ICanBo
## Code of Conduct

This project adheres to a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in
this project and its community, you are expected to uphold this code.
this project and its community, you're expected to uphold this code.



## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
See [CONTRIBUTING](CONTRIBUTING.md) for details.



Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"ext-mbstring": "*"
},
"require-dev": {
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.0"
"phpstan/phpstan": "^1.12.4",
"phpunit/phpunit": "^10.0|^11.0"
},
"autoload": {
"psr-4": {
Expand Down
12 changes: 11 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
version: "3.2"
services:
app81:
build:
Expand All @@ -23,3 +22,14 @@ services:
- .:/app:delegated
- ~/.composer:/root/.composer:delegated
working_dir: /app
app83:
build:
context: .
args:
PHP_VERSION: "8.3"
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-common'
volumes:
- .:/app:delegated
- ~/.composer:/root/.composer:delegated
working_dir: /app
18 changes: 10 additions & 8 deletions lib/array.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
*
* A stable sorting algorithm maintains the relative order of values with equal keys.
*
* The array is always sorted in ascending order but one can use the array_reverse() function to
* The array is always sorted in ascending order, but one can use the array_reverse() function to
* reverse the array. Also, keys are preserved, even numeric ones, use the array_values() function
* to create an array with an ascending index.
*
* @param array<int|string, mixed> $array
*
* @deprecated Since PHP 8.0, sorting is stable https://wiki.php.net/rfc/stable_sorting
* @deprecated Sorting has been stable since PHP 8.0 https://wiki.php.net/rfc/stable_sorting
*/
function stable_sort(array &$array, callable $picker = null): void
{
Expand Down Expand Up @@ -287,7 +287,7 @@ function exact_array_merge_recursive(array ...$arrays): array
}

/**
* Creates a dictionary from an iterable according to specified key selector function
* Creates a dictionary from an iterable according to the specified key selector function
* and optional element selector function.
*
* @template TKey of int|non-empty-string
Expand All @@ -300,22 +300,23 @@ function exact_array_merge_recursive(array ...$arrays): array
*
* @return ($element_selector is null ? array<TKey|int, TSource> : array<TKey, TElement>)
*/
function iterable_to_dictionary(iterable $it, callable $key_selector, callable $element_selector = null): array
function iterable_to_dictionary(iterable $it, callable $key_selector, ?callable $element_selector = null): array
{
$ar = [];
$element_selector ??= fn ($source) => $source;

foreach ($it as $source) {
/** @var TElement $element */
$key = $key_selector($source);
$element = $element_selector ? $element_selector($source) : $source;
$element = $element_selector($source);
$ar[$key] = $element;
}

return $ar;
}

/**
* Groups the elements of a sequence according to a specified key selector function
* Groups the elements of a sequence according to the specified key selector function
* and optionally projects the elements for each group by using a specified function.
*
* @template TKey of int|non-empty-string
Expand All @@ -328,14 +329,15 @@ function iterable_to_dictionary(iterable $it, callable $key_selector, callable $
*
* @return ($element_selector is null ? array<TKey, array<TSource>> : array<TKey, array<TElement>>)
*/
function iterable_to_groups(iterable $it, callable $key_selector, callable $element_selector = null): array
function iterable_to_groups(iterable $it, callable $key_selector, ?callable $element_selector = null): array
{
$ar = [];
$element_selector ??= fn ($source) => $source;

foreach ($it as $source) {
/** @var TElement $element */
$key = $key_selector($source);
$element = $element_selector ? $element_selector($source) : $source;
$element = $element_selector($source);
$ar[$key][] = $element;
}

Expand Down
4 changes: 3 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
beStrictAboutCoverageMetadata="true"
Expand All @@ -7,6 +7,8 @@
cacheDirectory=".phpunit.cache"
colors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
executionOrder="depends,defects"
>
<coverage/>
Expand Down

0 comments on commit a6e7ace

Please sign in to comment.