Skip to content

Commit df44e36

Browse files
authored
Support PHP 8 (#238)
Most of the work was done by @phanan, thank you!
1 parent 64241f3 commit df44e36

File tree

200 files changed

+2107
-1645
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+2107
-1645
lines changed

.github/workflows/test.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ jobs:
1616
- 7.2
1717
- 7.3
1818
- 7.4
19+
- 8.0
1920
experimental: [false]
2021
include:
21-
- php-version: 8.0
22+
- php-version: 8.1
2223
experimental: true
2324

2425
continue-on-error: ${{ matrix.experimental }}
@@ -43,7 +44,7 @@ jobs:
4344
run: |
4445
composer require pcov/clobber
4546
vendor/bin/pcov clobber
46-
continue-on-error: ${{ matrix.experimental }}
47+
continue-on-error: true
4748

4849
- name: Run Tests
4950
run: composer tests

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ vendor/
44
composer.lock
55
phpcs.xml
66
phpunit.xml
7+
.idea/
8+
.phpunit.result.cache

.php_cs.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ return PhpCsFixer\Config::create()
55
->setRules([
66
'native_function_invocation' => true,
77
])
8-
->setFinder(PhpCsFixer\Finder::create()->exclude('tests')->in(__DIR__));
8+
->setFinder(PhpCsFixer\Finder::create()->in(__DIR__));

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2011-2017 Lars Strojny
3+
Copyright (c) 2011-2021 Lars Strojny
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Test](https://github.com/lstrojny/functional-php/actions/workflows/test.yaml/badge.svg)](https://github.com/lstrojny/functional-php/actions/workflows/test.yaml)
44

55
*NOTE:* functional-php used to come with a C extension that implemented most of the functions natively. As the
6-
performance differences weren’t that huge compared to the maintenance cost it has been removed.
6+
performance differences weren’t that huge compared to the maintenance cost it has been removed.
77

88
A set of functional primitives for PHP, heavily inspired by [Scala’s traversable
99
collection](http://www.scala-lang.org/archives/downloads/distrib/files/nightly/docs/library/scala/collection/Traversable.html),

composer.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"name": "lstrojny/functional-php",
33
"description": "Functional primitives for PHP",
4-
"keywords": ["functional"],
4+
"keywords": [
5+
"functional"
6+
],
57
"license": "MIT",
68
"authors": [
79
{
@@ -15,15 +17,17 @@
1517
}
1618
],
1719
"require": {
18-
"php": "~7|~8"
20+
"php": "^7.1|~8"
1921
},
2022
"require-dev": {
21-
"phpunit/phpunit": "~7",
2223
"squizlabs/php_codesniffer": "~3.0",
23-
"friendsofphp/php-cs-fixer": "^2.14"
24+
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.5",
25+
"friendsofphp/php-cs-fixer": "^2.17"
2426
},
2527
"autoload": {
26-
"psr-4": {"Functional\\": "src/Functional"},
28+
"psr-4": {
29+
"Functional\\": "src/Functional"
30+
},
2731
"files": [
2832
"src/Functional/Ary.php",
2933
"src/Functional/Average.php",
@@ -121,7 +125,9 @@
121125
]
122126
},
123127
"autoload-dev": {
124-
"psr-4": {"Functional\\Tests\\": "tests/Functional"}
128+
"psr-4": {
129+
"Functional\\Tests\\": "tests/Functional"
130+
}
125131
},
126132
"scripts": {
127133
"tests": "vendor/bin/phpunit",

phpunit.xml.dist

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
<?xml version="1.0"?>
12
<!--
2-
* Copyright (C) 2011-2017 by Lars Strojny <lstrojny@php.net>
3+
* Copyright (C) 2011-2021 by Lars Strojny <lstrojny@php.net>
34
*
45
* Permission is hereby granted, free of charge, to any person obtaining a copy
56
* of this software and associated documentation files (the "Software"), to deal
@@ -19,39 +20,32 @@
1920
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2021
* THE SOFTWARE.
2122
-->
22-
<phpunit
23-
backupGlobals="false"
24-
backupStaticAttributes="false"
25-
bootstrap="vendor/autoload.php"
26-
convertWarningsToExceptions="true"
27-
convertNoticesToExceptions="true"
28-
beStrictAboutTestsThatDoNotTestAnything="true"
29-
beStrictAboutOutputDuringTests="true"
30-
verbose="true"
31-
colors="true">
32-
<filter>
33-
<whitelist>
34-
<directory suffix=".php">src/Functional</directory>
35-
</whitelist>
36-
</filter>
37-
38-
<testsuites>
39-
<testsuite name="unit-tests">
40-
<directory>tests/Functional/</directory>
41-
</testsuite>
42-
</testsuites>
43-
44-
<logging>
45-
<log type="coverage-html" target="build/coverage"
46-
lowUpperBound="35" highLowerBound="70"/>
47-
<log type="coverage-clover" target="build/logs/clover.xml"/>
48-
<log type="junit" target="build/logs/junit.xml"/>
49-
</logging>
50-
51-
<php>
52-
<ini name="error_reporting" value="-1"/>
53-
<ini name="date.timezone" value="UTC"/>
54-
<ini name="display_errors" value="on"/>
55-
</php>
56-
23+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
25+
bootstrap="vendor/autoload.php"
26+
beStrictAboutOutputDuringTests="true"
27+
verbose="true"
28+
colors="true">
29+
<coverage>
30+
<include>
31+
<directory suffix=".php">src/Functional</directory>
32+
</include>
33+
<report>
34+
<clover outputFile="build/logs/clover.xml"/>
35+
<html outputDirectory="build/coverage" lowUpperBound="35" highLowerBound="70"/>
36+
</report>
37+
</coverage>
38+
<testsuites>
39+
<testsuite name="unit-tests">
40+
<directory>tests/Functional/</directory>
41+
</testsuite>
42+
</testsuites>
43+
<logging>
44+
<junit outputFile="build/logs/junit.xml"/>
45+
</logging>
46+
<php>
47+
<ini name="error_reporting" value="-1"/>
48+
<ini name="date.timezone" value="UTC"/>
49+
<ini name="display_errors" value="on"/>
50+
</php>
5751
</phpunit>

src/Functional/Ary.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/**
1717
* Call $func with only abs($count) arguments, taken either from the
1818
* left or right depending on the sign
19+
* @no-named-arguments
1920
*/
2021
function ary(callable $func, int $count): callable
2122
{

src/Functional/Average.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* @package Functional-php
55
* @author Lars Strojny <lstrojny@php.net>
6-
* @copyright 2011-2017 Lars Strojny
6+
* @copyright 2011-2021 Lars Strojny
77
* @license https://opensource.org/licenses/MIT MIT
88
* @link https://github.com/lstrojny/functional-php
99
*/
@@ -18,6 +18,7 @@
1818
*
1919
* @param Traversable|array $collection
2020
* @return null|float|int
21+
* @no-named-arguments
2122
*/
2223
function average($collection)
2324
{

src/Functional/ButLast.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* @package Functional-php
55
* @author Lars Strojny <lstrojny@php.net>
6-
* @copyright 2011-2017 Lars Strojny
6+
* @copyright 2011-2021 Lars Strojny
77
* @license https://opensource.org/licenses/MIT MIT
88
* @link https://github.com/lstrojny/functional-php
99
*/
@@ -18,6 +18,7 @@
1818
*
1919
* @param Traversable|array $collection
2020
* @return array
21+
* @no-named-arguments
2122
*/
2223
function but_last($collection)
2324
{

0 commit comments

Comments
 (0)