Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with PHP 8 #22

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Tests

on:
pull_request:
push:

jobs:
run:
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'
steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}

- name: Install dependencies
run: composer install

- name: Run tests
run: composer test
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Non-standard PHP Library (NSPL) is a collection of modules that are meant to sol

- [nspl\f](#nsplf) - provides functions that act on other functions. Helps to write code in functional programming paradigm
- [nspl\op](#nsplop) - provides functions that perform standard PHP operations and can be passed as callbacks to higher-order functions. Mimics Python's [operator](https://docs.python.org/2/library/operator.html) module
- [nspl\a](#nspla) - provides missing array functions which also can be applied to traversable sequences
- [nspl\a](#nspla) - provides missing array functions which also can be applied to iterable sequences
- [nspl\a\lazy](#nsplalazy) - provides lazy versions of functions from ```\nspl\a```
- [nspl\args](#nsplargs) - validates function arguments (will be moved into a separate package in version 2.0)
- [nspl\ds](#nsplds) - provides non-standard data structures and methods to work with them
Expand Down Expand Up @@ -415,7 +415,7 @@ Check more ```\nspl\op``` examples [here](https://github.com/ihor/Nspl/blob/mast

## nspl\a

Provides missing array functions which also can be applied to traversable sequences
Provides missing array functions which also can be applied to iterable sequences

##### all($sequence, $predicate)

Expand Down Expand Up @@ -664,28 +664,28 @@ assert(['a', 'b', 'c'] === keys(array('a' => 1, 'b' => 2, 'c' => 3)));

##### in($item, $sequence)

Checks if the item is present in array or traversable object
Checks if the item is present in iterable (array or traversable object)
```php
assert(true === in(1, [1, 2, 3]);
```

##### diff($sequence1, $sequence2)

Computes the difference of arrays or traversable objects
Computes the difference of iterables (arrays or traversable objects)
```php
assert([1] === diff([1, 2, 3], new ArrayObject([2, 3, 4]));
```

##### intersect($sequence1, $sequence2)

Computes the intersection of arrays or traversable objects
Computes the intersection of iterables (arrays or traversable objects)
```php
assert([2, 3] === intersect([1, 2, 3], new ArrayObject([2, 3, 4]));
```

##### cartesianProduct($sequences)

Computes the cartesian product of two or more arrays or traversable objects
Computes the cartesian product of two or more iterables (arrays or traversable objects)
```php
assert([
[1, 'a'],
Expand Down Expand Up @@ -740,7 +740,7 @@ Check more ```\nspl\a``` examples [here](https://github.com/ihor/Nspl/blob/maste
## nspl\a\lazy
Provides lazy versions of functions from [nspl\a](#nspla)

This module might be useful when you don't need to process all the values from an array or any other traversable sequence. To understand how these lazy functions work let's have a look at the following example.
This module might be useful when you don't need to process all the values from an iterable (array or any other traversable sequence). To understand how these lazy functions work let's have a look at the following example.

Let's define a function which wraps a generator function and logs all the values it yields. It will help up us to see the order of function calls:
```php
Expand Down Expand Up @@ -937,7 +937,8 @@ array_ | Checks that argument is an array
object | Checks that argument is an object | OR
callable_ | Checks that argument is callable | OR
arrayKey | Checks that argument can be an array key | OR
traversable | Checks that argument can be traversed with foreach | OR
iterable_ | Checks that argument can be iterated with foreach | OR
~~traversable~~ | Deprecated in favour of `iterable_` | OR
arrayAccess | Checks that argument supports array index access | OR
nonEmpty | Checks that argument is not empty | AND
positive | Checks that argument is positive (> 0) | AND
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"files": ["autoload.php"]
},
"require-dev": {
"phpunit/phpunit": "~5.0"
"phpunit/phpunit": "~7.0 || ~8.0 || ~9.0"
},
"require": {
"php": ">=7.1.0"
Expand All @@ -22,5 +22,8 @@
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"scripts": {
"test": "phpunit --verbose tests/"
}
}
Loading