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

PHP 8 Compatibility #104

Merged
merged 11 commits into from
Jun 6, 2021
Merged
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
8 changes: 8 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ branches:
strict: true
contexts:
- "Static Analysis (ubuntu-latest, 7.4)"
- "Static Analysis (ubuntu-latest, 8.0)"
- "Static Analysis (windows-latest, 7.4)"
- "Static Analysis (windows-latest, 8.0)"
AlexandruGG marked this conversation as resolved.
Show resolved Hide resolved
- "Static Analysis (macOS-latest, 7.4)"
- "Static Analysis (macOS-latest, 8.0)"
- "Unit Tests (ubuntu-latest, 7.4)"
- "Unit Tests (ubuntu-latest, 8.0)"
- "Unit Tests (windows-latest, 7.4)"
- "Unit Tests (windows-latest, 8.0)"
- "Unit Tests (macOS-latest, 7.4)"
- "Unit Tests (macOS-latest, 8.0)"
- "Mutation Testing (ubuntu-latest, 7.4)"
- "Mutation Testing (ubuntu-latest, 8.0)"
- "Code Style (ubuntu-latest, 7.4)"
- "Code Style (ubuntu-latest, 8.0)"

restrictions: null
required_linear_history: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4']
php-versions: ['7.4', '8.0']

steps:
- name: Set git to use LF
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mutation-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4']
php-versions: ['7.4', '8.0']

steps:
- name: Set git to use LF
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['7.4']
php-versions: ['7.4', '8.0']

steps:
- name: Set git to use LF
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['7.4']
php-versions: ['7.4', '8.0']

steps:
- name: Set git to use LF
Expand Down
9 changes: 8 additions & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
build:
nodes:
analysis:
php74:
environment:
php:
version: 7.4
tests:
override:
- php-scrutinizer-run
php80:
environment:
php:
version: 8.0
tests:
override:
- php-scrutinizer-run
drupol marked this conversation as resolved.
Show resolved Hide resolved

filter:
paths:
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ asyncMap

Asynchronously apply one or more supplied callbacks to every item of a collection and use the return value.

.. warning:: This method requires `ampphp/parallel-functions <https://github.com/amphp/parallel-functions>`_ to be installed.
.. warning:: This method requires `amphp/parallel-functions <https://github.com/amphp/parallel-functions>`_ to be installed.

.. warning::
This operation is non-deterministic, we cannot ensure the order of the elements at the end. Additionally,
Expand Down
17 changes: 14 additions & 3 deletions spec/loophp/collection/CollectionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use ArrayIterator;
use ArrayObject;
use Closure;
use Error;
use Exception;
use Generator;
use InvalidArgumentException;
Expand All @@ -27,6 +28,7 @@
use stdClass;
use const INF;
use const PHP_EOL;
use const PHP_VERSION_ID;

class CollectionSpec extends ObjectBehavior
{
Expand Down Expand Up @@ -226,9 +228,18 @@ public function it_can_asyncMap(): void
return $v * 2;
};

$this::fromIterable(['c' => 3, 'b' => 2, 'a' => 1])
->asyncMap($callback1, $callback2)
->shouldIterateAs(['a' => 2, 'b' => 4, 'c' => 6]);
$this->beConstructedThrough('fromIterable', [['c' => 3, 'b' => 2, 'a' => 1]]);

if (PHP_VERSION_ID >= 80000) {
$this
->asyncMap($callback1, $callback2)
->shouldThrow(Error::class)
->during('all');
} else {
$this
->asyncMap($callback1, $callback2)
->shouldIterateAs(['a' => 2, 'b' => 4, 'c' => 6]);
}
}

public function it_can_be_constructed_from_a_file(): void
Expand Down
4 changes: 2 additions & 2 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ public function append(...$items): CollectionInterface
return new self(Append::of()(...$items), $this->getIterator());
}

public function apply(callable ...$callables): CollectionInterface
public function apply(callable ...$callbacks): CollectionInterface
AlexandruGG marked this conversation as resolved.
Show resolved Hide resolved
{
return new self(Apply::of()(...$callables), $this->getIterator());
return new self(Apply::of()(...$callbacks), $this->getIterator());
}

public function associate(
Expand Down
6 changes: 3 additions & 3 deletions src/Contract/Operation/Applyable.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ interface Applyable
/**
* Execute a callback for each element of the collection.
*
* @param callable(T, TKey, Iterator<TKey, T>): bool ...$callables
* @param callable(T, TKey, Iterator<TKey, T>): bool ...$callbacks
drupol marked this conversation as resolved.
Show resolved Hide resolved
*
* @return \loophp\collection\Collection<TKey, T>
* @return Collection<TKey, T>
*/
public function apply(callable ...$callables): Collection;
public function apply(callable ...$callbacks): Collection;
}
2 changes: 1 addition & 1 deletion src/Operation/Apply.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __invoke(): Closure
{
return
/**
* @param callable(T, TKey, Iterator<TKey, T>):bool ...$callbacks
* @param callable(T, TKey, Iterator<TKey, T>): bool ...$callbacks
*
* @return Closure(Iterator<TKey, T>): Generator<TKey, T>
*/
Expand Down