Skip to content

Commit

Permalink
Merge pull request #81 from Hi-Folks/feat/upgade-php83
Browse files Browse the repository at this point in the history
Feat/upgade php83
  • Loading branch information
roberto-butti authored May 23, 2024
2 parents 5b55b64 + 423b599 commit 340799a
Show file tree
Hide file tree
Showing 22 changed files with 202 additions and 225 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ jobs:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:

- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.6.0
uses: dependabot/fetch-metadata@v2.1.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Auto-merge Dependabot PRs for semver-minor updates
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Auto-merge Dependabot PRs for semver-patch updates
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
run: gh pr merge --auto --merge "$PR_URL"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: "Run Laravel Pint"
uses: aglipanci/laravel-pint-action@2.3.0
uses: aglipanci/laravel-pint-action@2.0.0

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Fix styling
4 changes: 2 additions & 2 deletions .github/workflows/run-tests-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: [ '8.2' ]
php-versions: [ '8.3' ]
dependency-stability: [ 'prefer-none' ]

name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install PHP versions
uses: shivammathur/setup-php@v2
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.0, 8.1, 8.2]
php: [8.1, 8.2, 8.3]
exclude:
- os: windows-latest
php: 8.0
- os: windows-latest
php: 8.1
- os: windows-latest
php: 8.2

name: P${{ matrix.php }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ phpunit.xml
psalm.xml
vendor
.php-cs-fixer.cache

/.phpunit.cache
.DS_Store
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Changelog

## 0.1.2 - WIP
## 1.0.0 - 2024-05-23
- PHPStan Level 6, thanks to @RoadSigns
- Updating Pint action for the GitHub Actions
- Adding Rector with UP_TO_PHP_80, DEAD_CODE, CODE_QUALITY, EARLY_RETURN, TYPE_DECLARATION, PRIVATIZATION options
- Upgrading dependencies (Rector 1, PHP 8.3, some GitHub Actions, ...)
- Adding Rector with UP_TO_PHP_81, DEAD_CODE, CODE_QUALITY, EARLY_RETURN, TYPE_DECLARATION, PRIVATIZATION options

## 0.1.1 - 2022-12-08
Welcome to PHP 8.2.
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ You can install the package via composer:
composer require hi-folks/array
```

> Currently, this package is under development. It's **not** "production ready". It is to be considered "not production ready" until it is in version v0.0.x. When version 0.1.x will be released, it means that the package is considered stable.

## Usage

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
}
],
"require": {
"php": "^8.0"
"php": "^8.1|^8.2|^8.3"
},
"require-dev": {
"laravel/pint": "^1.2",
"pestphp/pest": "^1.22",
"pestphp/pest": "^2",
"phpstan/phpstan": "^1.6",
"rector/rector": "^0.15.0"
"rector/rector": "^1"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion examples/cheatsheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
print_result($arr->find(fn ($element, $index): bool => $element > 1 && $index > 1));
// 3
$arr = Arr::make(['foo', 'bar', 'baz']);
print_result($arr->find(fn ($element): bool => str_contains($element, 'a')));
print_result($arr->find(fn ($element): bool => str_contains((string) $element, 'a')));
// 'bar'

// Returns the shadow copied part of the array to another location and keeps its length
Expand Down
4 changes: 2 additions & 2 deletions examples/sets.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require './vendor/autoload.php';
require __DIR__ . '/vendor/autoload.php';

use HiFolks\DataType\Arr;

Expand All @@ -10,5 +10,5 @@
$arrB = Arr::make([1, 2, 5, 6, 7]);

echo " --- Intersection" . PHP_EOL;
$intersection = $arrA->filter(fn ($x) => $arrB->includes($x));
$intersection = $arrA->filter(fn ($x): bool => $arrB->includes($x));
echo $intersection->toString() . PHP_EOL;
58 changes: 21 additions & 37 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<testsuites>
<testsuite name="HiFolks Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="HiFolks Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80,
LevelSetList::UP_TO_PHP_81,
SetList::DEAD_CODE,
SetList::CODE_QUALITY,
SetList::EARLY_RETURN,
Expand Down
10 changes: 2 additions & 8 deletions src/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static function from(iterable|string $arrayLike, ?Closure $mapFn = null):
$arrayLike = iterator_to_array($arrayLike);
}

$array = self::make((array) $arrayLike);
$array = self::make($arrayLike);

if (! is_callable($mapFn)) {
return $array;
Expand Down Expand Up @@ -268,7 +268,6 @@ public function pop(): mixed
/**
* Add element to start of Arr and return new length
*
* @param mixed $element the elements to add to the front of the array
* @return int the new length of the array upon which the method was called.
*/
public function unshift(mixed ...$element): int
Expand Down Expand Up @@ -371,7 +370,6 @@ public function slice(int $start, int $end = null): Arr
/**
* Returns index of first occurrence of element in arr
*
* @param mixed $searchElement the element to search
* @return string|int|bool the index of element found. If it is not found, false is returned
*/
public function indexOf(mixed $searchElement): string|int|bool
Expand All @@ -382,7 +380,6 @@ public function indexOf(mixed $searchElement): string|int|bool
/**
* Returns index of last occurrence of element in Arr
*
* @param mixed $searchElement the element to search
* @return string|int|bool the index of element found. If it is not found, false is returned
*/
public function lastIndexOf(mixed $searchElement): string|int|bool
Expand Down Expand Up @@ -481,7 +478,7 @@ public function flat(): self
{
$array = array_reduce(
$this->arr,
fn ($result, $element) => array_merge($result, is_array($element) ? [...$element] : [$element]),
fn ($result, $element): array => array_merge($result, is_array($element) ? [...$element] : [$element]),
[]
);

Expand Down Expand Up @@ -518,7 +515,6 @@ public function flatMap(callable $callback): self
/**
* Changes all elements in range from $start for $count, to the specified value
*
* @param mixed $value the value to fill the array with
* @param int $start start index (from 0)
* @param int|null $end end index (default, the end of array)
*/
Expand Down Expand Up @@ -587,7 +583,6 @@ public function sort(): Arr
*
* @param int $start the index at which to start changing the array
* @param int|null $deleteCount an integer indicating the number of elements in the array to remove from $start
* @param mixed $newElements The elements to add to the array, beginning from $start
* @return Arr an array containing the deleted elements
*/
public function splice(int $start, int $deleteCount = null, mixed $newElements = []): Arr
Expand All @@ -606,7 +601,6 @@ public function toString(): string
/**
* Returns true if the input is an array
*
* @param mixed $input the input value, to test if it is an array
* @return bool true if $input is an array, false otherwise
*/
public static function isArray(mixed $input): bool
Expand Down
4 changes: 2 additions & 2 deletions src/Classes/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ class Operation
{
public static function add(int|string $field, int|float $value): Closure
{
return fn ($element) => $value + $element[$field];
return fn ($element): int|float => $value + $element[$field];
}

public static function double(int|string $field): Closure
{
return fn ($element) => $element[$field] * 2;
return fn ($element): int|float => $element[$field] * 2;
}
}
Loading

0 comments on commit 340799a

Please sign in to comment.