Skip to content

Commit 3a20bec

Browse files
authored
Merge pull request #1 from tithely/php-8
MEM-151 support php-8.4
2 parents 5f5ddb6 + 8e91a3b commit 3a20bec

36 files changed

Lines changed: 165 additions & 99 deletions

.github/workflows/test.yaml

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
11
name: Test
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: '*'
48

59
jobs:
610
test:
7-
name: PHP ${{ matrix.php-version }} (${{ matrix.experimental && 'experimental' || 'full support' }})
11+
name: PHP ${{ matrix.php-version }}
812

9-
runs-on: ubuntu-18.04
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 10
1015

1116
strategy:
12-
fail-fast: false
1317
matrix:
1418
php-version:
15-
- 7.1
16-
- 7.2
17-
- 7.3
18-
- 7.4
19-
- 8.0
20-
experimental: [false]
21-
include:
22-
- php-version: 8.1
23-
experimental: true
24-
25-
continue-on-error: ${{ matrix.experimental }}
19+
- 8.4
2620
steps:
2721
- name: Checkout
28-
uses: actions/checkout@v2
22+
uses: actions/checkout@v5
2923

3024
- name: Install PHP with extensions
3125
uses: shivammathur/setup-php@v2
@@ -34,11 +28,21 @@ jobs:
3428
coverage: pcov
3529
tools: composer:v2
3630

37-
- name: Install Composer dependencies
38-
uses: ramsey/composer-install@v1
31+
- name: Validate composer.json and composer.lock
32+
run: composer validate
33+
34+
- name: Cache Composer packages
35+
id: composer-cache
36+
uses: actions/cache@v3
3937
with:
40-
composer-options: --prefer-dist
41-
continue-on-error: ${{ matrix.experimental }}
38+
path: vendor
39+
key: ${{ runner.os }}-${{ matrix.php-versions }}-composer-${{ hashFiles('**/composer.json') }}
40+
restore-keys: |
41+
${{ runner.os }}-${{ matrix.php-versions }}-composer
42+
43+
- name: Install dependencies
44+
if: steps.composer-cache.outputs.cache-hit != 'true'
45+
run: composer install --prefer-dist --no-progress
4246

4347
- name: Setup PCOV
4448
run: |
@@ -47,9 +51,4 @@ jobs:
4751
continue-on-error: true
4852

4953
- name: Run Tests
50-
run: composer tests
51-
continue-on-error: ${{ matrix.experimental }}
52-
53-
- name: Check coding style
54-
run: composer coding-style
55-
continue-on-error: ${{ matrix.experimental }}
54+
run: composer test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ phpcs.xml
66
phpunit.xml
77
.idea/
88
.phpunit.result.cache
9+
.php-cs-fixer.cache

.php_cs.dist renamed to .php-cs-fixer.dist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
return PhpCsFixer\Config::create()
3+
return (new PhpCsFixer\Config())
44
->setRiskyAllowed(true)
55
->setRules([
66
'native_function_invocation' => true,

composer.json

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "lstrojny/functional-php",
2+
"name": "tithely/functional-php",
33
"description": "Functional primitives for PHP",
44
"keywords": [
55
"functional"
@@ -17,12 +17,12 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^7.1|~8"
20+
"php": "^8.4"
2121
},
2222
"require-dev": {
2323
"squizlabs/php_codesniffer": "~3.0",
24-
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.5",
25-
"friendsofphp/php-cs-fixer": "^2.17"
24+
"phpunit/phpunit": "^9.6",
25+
"friendsofphp/php-cs-fixer": "v3.84"
2626
},
2727
"autoload": {
2828
"psr-4": {
@@ -132,8 +132,16 @@
132132
}
133133
},
134134
"scripts": {
135-
"tests": "vendor/bin/phpunit",
136-
"coding-style": "vendor/bin/phpcs && vendor/bin/php-cs-fixer fix --dry-run --diff --config=.php_cs.dist",
137-
"clear": "rm -rf vendor/"
135+
"test": "vendor/bin/phpunit",
136+
"test:84": "docker exec -w /app functional_php_84 ./vendor/bin/phpunit --colors=always --no-coverage",
137+
"lint:scan": "vendor/bin/php-cs-fixer fix src --config=.php-cs-fixer.dist.php --dry-run",
138+
"lint:fix": "vendor/bin/php-cs-fixer fix src --config=.php-cs-fixer.dist.php",
139+
"clear": "rm -rf vendor/",
140+
"clean-vendor": "rm -rf vendor && rm -rf composer.lock",
141+
"docker:start": "docker compose -p functional_php -f docker/docker-compose.yml up -d",
142+
"docker:stop": "docker compose -p functional_php -f docker/docker-compose.yml down",
143+
"docker:rebuild": "docker compose -p functional_php -f docker/docker-compose.yml build --force-rm && docker-compose -p functional_php -f docker/docker-compose.yml up -d --remove-orphans",
144+
"docker:rebuild:nocache": "docker compose -p functional_php -f docker/docker-compose.yml build --force-rm --no-cache && docker-compose -p functional_php -f docker/docker-compose.yml up -d --remove-orphans",
145+
"docker:shell": "docker exec -w /app -it functional_php_84 /bin/bash"
138146
}
139147
}

docker/custom.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
post_max_size = 100M
2+
max_execution_time = 300

docker/docker-compose.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
services:
2+
functional_php_84:
3+
build:
4+
dockerfile: docker/php/84.Dockerfile
5+
context: ../
6+
container_name: functional_php_84
7+
volumes:
8+
- ../:/app
9+
networks:
10+
- tithely_hub_code-network
11+
environment:
12+
- CONF_DISABLED=xdebug
13+
- PCOV_ENABLED=1
14+
- PCOV_DIRECTORY=/app
15+
networks:
16+
tithely_hub_code-network:
17+
external: true

docker/php/84.Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM tithely/php:8.4-apache-dev
2+
3+
#------------------------------
4+
# Begin changes below this note
5+
#------------------------------
6+
7+
# Install custom packages
8+
RUN apt-get update -qq && \
9+
apt-get install -qq \
10+
vim
11+
12+
# Copy custom php.ini settings
13+
COPY docker/custom.ini /usr/local/etc/php/conf.d/custom_overrides.ini

src/Functional/CompareObjectHashOn.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* Returns a comparison function that can be used with e.g. `usort()`
1515
*
1616
* @param callable $comparison A function that compares the two values. Pick e.g. strcmp() or strnatcasecmp()
17-
* @param callable $keyFunction A function that takes an argument and returns the value that should be compared
17+
* @param callable|null $keyFunction A function that takes an argument and returns the value that should be compared
1818
* @return callable
1919
* @no-named-arguments
2020
*/
21-
function compare_object_hash_on(callable $comparison, callable $keyFunction = null)
21+
function compare_object_hash_on(callable $comparison, ?callable $keyFunction = null)
2222
{
2323
$keyFunction = $keyFunction ? compose($keyFunction, 'spl_object_hash') : 'spl_object_hash';
2424

src/Functional/CompareOn.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* Returns a comparison function that can be used with e.g. `usort()`
1515
*
1616
* @param callable $comparison A function that compares the two values. Pick e.g. strcmp() or strnatcasecmp()
17-
* @param callable $reducer A function that takes an argument and returns the value that should be compared
17+
* @param callable|null $reducer A function that takes an argument and returns the value that should be compared
1818
* @return callable
1919
* @no-named-arguments
2020
*/
21-
function compare_on(callable $comparison, callable $reducer = null)
21+
function compare_on(callable $comparison, ?callable $reducer = null)
2222
{
2323
if ($reducer === null) {
2424
return static function ($left, $right) use ($comparison) {

src/Functional/Concat.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* Concatenates zero or more strings
1515
*
16-
* @param string[] ...$strings
16+
* @param string ...$strings
1717
* @return string
1818
* @no-named-arguments
1919
*/

0 commit comments

Comments
 (0)