Skip to content

Commit

Permalink
Allow and fix php 8.1 (#55)
Browse files Browse the repository at this point in the history
* Allow and fix php 8.1

* Allow and fix php 8.1

* Fix types issues from phpstan

* Ignore error in PlainArray

* Remove scrutinizer badge and update installation docs

Co-authored-by: Dawid Łakomski <[email protected]>
  • Loading branch information
bronek89 and dlakomski authored May 24, 2022
1 parent 224f4e8 commit bd9d80b
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '7.4', '8.0' ]
php-versions: [ '8.0', '8.1' ]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@
[![License](https://poser.pugx.org/gowork/values/license)](https://packagist.org/packages/gowork/values)
[![Latest Stable Version](https://poser.pugx.org/gowork/values/v)](//packagist.org/packages/gowork/values)
[![Maintainability](https://api.codeclimate.com/v1/badges/b4fde36fad9d09cce9eb/maintainability)](https://codeclimate.com/github/gowork/values/maintainability)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/gowork/values/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/gowork/values/?branch=master)

## Installation

It works on PHP >=7.4. This library is available on Composer/Packagist as `gowork/values`. To install it execute:
It works on PHP >=8.0. This library is available on Composer/Packagist as `gowork/values`. To install it execute:

```shell
composer require gowork/values ^0.4
composer require gowork/values ^0.6
```

or manually update your `composer.json` with:
```json
{
(...)
"require": {
"gowork/values": "^0.4"
"gowork/values": "^0.6"
}
(...)
}
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
}
],
"require": {
"php": "^7.4 || ^8.0"
"php": "^8.0"
},
"require-dev": {
"phpspec/phpspec": "^6.1 || ^7.0",
"phpspec/phpspec": "^7.0",
"phpstan/phpstan": "^1.0",
"phpbench/phpbench": "@dev",
"phpunit/phpunit": "^8.5 || ^9.0",
"phpunit/phpunit": "^9.0",
"phpstan/extension-installer": "^1.0",
"vimeo/psalm": "^4.0",
"friends-of-phpspec/phpspec-code-coverage": "^6.0"
Expand Down
1 change: 1 addition & 0 deletions src/ArrayValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function flatMap(callable $transformer): ArrayValue;
public function groupBy(callable $reducer): AssocValue;

/**
* @param int<1, max> $size
* @phpstan-return ArrayValue<array<int, TValue>>
*/
public function chunk(int $size): ArrayValue;
Expand Down
6 changes: 5 additions & 1 deletion src/Arrayable/Chunk.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ final class Chunk implements Arrayable
{
/** @var Arrayable<TValue> */
private Arrayable $arrayable;
/** @var int<1, max> */
private int $size;

/** @param Arrayable<TValue> $arrayable */
/**
* @param Arrayable<TValue> $arrayable
* @param int<1, max> $size
*/
public function __construct(Arrayable $arrayable, int $size)
{
$this->arrayable = $arrayable;
Expand Down
5 changes: 3 additions & 2 deletions src/AssocArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use GW\Value\Associable\Values;
use GW\Value\Associable\WithItem;
use GW\Value\Associable\Without;
use Traversable;
use function array_key_exists;
use function count;
use function in_array;
Expand Down Expand Up @@ -313,9 +314,9 @@ public function toAssocArray(): array
}

/**
* @return iterable<TKey, TValue>
* @return Traversable<TKey, TValue>
*/
public function getIterator(): iterable
public function getIterator(): Traversable
{
yield from $this->items->toAssocArray();
}
Expand Down
5 changes: 3 additions & 2 deletions src/InfiniteIterableValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace GW\Value;

use Traversable;
use function count;
use const PHP_INT_MAX;

Expand Down Expand Up @@ -528,9 +529,9 @@ static function (iterable $iterable): iterable {
}

/**
* @phpstan-return iterable<TKey, TValue>
* @phpstan-return Traversable<TKey, TValue>
*/
public function getIterator(): iterable
public function getIterator(): Traversable
{
yield from $this->stack->iterate();
}
Expand Down
2 changes: 2 additions & 0 deletions src/PlainArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ public function groupBy(callable $reducer): AssocValue
/** @phpstan-var array<TNewKey, ArrayValue<TValue>> $groupsWrapped */
$groupsWrapped = array_map([Wrap::class, 'array'], $groups);

/** @phpstan-ignore-next-line it looks like false-positive */
return Wrap::assocArray($groupsWrapped);
}

/**
* @param int<1, max> $size
* @phpstan-return PlainArray<array<int, TValue>>
*/
public function chunk(int $size): PlainArray
Expand Down
1 change: 1 addition & 0 deletions src/PlainStringsArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public function groupBy(callable $reducer): AssocValue
}

/**
* @param int<1, max> $size
* @return ArrayValue<array<int, StringValue>>
*/
public function chunk(int $size): ArrayValue
Expand Down
1 change: 1 addition & 0 deletions src/StringsArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ public function toArrayValue(): ArrayValue;
public function toAssocValue(): AssocValue;

/**
* @param int<1, max> $size
* @phpstan-return ArrayValue<array<int, StringValue>>
*/
public function chunk(int $size): ArrayValue;
Expand Down

0 comments on commit bd9d80b

Please sign in to comment.