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

Remove illuminate/collections dependency causing conflicts with later versions #7

Merged
merged 4 commits into from
Feb 7, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Configure PHP environment
uses: shivammathur/setup-php@v2
with:
Expand Down
19 changes: 3 additions & 16 deletions .github/workflows/tests-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1000
submodules: recursive
# ------------------------------------------------------------------------------
# Checkout slic
# ------------------------------------------------------------------------------
- name: Checkout slic
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: stellarwp/slic
ref: main
path: slic
fetch-depth: 1
# ------------------------------------------------------------------------------
# Prepare our composer cache directory
# ------------------------------------------------------------------------------
- name: Get Composer Cache Directory
id: get-composer-cache-dir
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
id: composer-cache
with:
path: ${{ steps.get-composer-cache-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

# ------------------------------------------------------------------------------
# Initialize slic
# ------------------------------------------------------------------------------
Expand Down
3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
}
],
"minimum-stability": "stable",
"require": {
"illuminate/collections": "^8.0"
},
"require-dev": {
"lucatume/wp-browser": "^3.5 || ^4.0",
"szepeviktor/phpstan-wordpress": "^1.1",
Expand Down
2 changes: 1 addition & 1 deletion docs/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ This is an automatically generated documentation for **Documentation**.


***
> Automatically generated on 2025-01-17
> Automatically generated on 2025-02-07
6 changes: 3 additions & 3 deletions docs/classes/StellarWP/Arrays/Arr.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public static except(array $array, array|string|int|float $keys): array
Determine if the given key exists in the provided array.

```php
public static exists(\ArrayAccess|\Illuminate\Support\Enumerable|array $array, string|int|float $key): bool
public static exists(\ArrayAccess|array $array, string|int|float $key): bool
```


Expand All @@ -371,7 +371,7 @@ public static exists(\ArrayAccess|\Illuminate\Support\Enumerable|array $array, s

| Parameter | Type | Description |
|-----------|------|-------------|
| `$array` | **\ArrayAccess|\Illuminate\Support\Enumerable|array** | |
| `$array` | **\ArrayAccess|array** | |
| `$key` | **string|int|float** | |


Expand Down Expand Up @@ -1691,4 +1691,4 @@ whose keys exist in every provided array, recursively.


***
> Automatically generated on 2025-01-17
> Automatically generated on 2025-02-07
24 changes: 19 additions & 5 deletions src/Arrays/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace StellarWP\Arrays;

use ArrayAccess;
use Illuminate\Support\Enumerable;
use Closure;
use InvalidArgumentException;

/**
Expand Down Expand Up @@ -302,7 +302,7 @@ public static function except( $array, $keys ) {
/**
* Determine if the given key exists in the provided array.
*
* @param \ArrayAccess|Enumerable|array $array
* @param \ArrayAccess|array $array
* @param string|int|float $key
*
* @return bool
Expand Down Expand Up @@ -348,7 +348,7 @@ public static function filter_prefixed( array $array, string $prefix ): array {
public static function first( $array, callable $callback = null, $default = null ) {
if ( is_null( $callback ) ) {
if ( empty( $array ) ) {
return value( $default );
return self::value( $default );
}

foreach ( $array as $item ) {
Expand All @@ -362,7 +362,7 @@ public static function first( $array, callable $callback = null, $default = null
}
}

return value( $default );
return self::value( $default );
}

/**
Expand Down Expand Up @@ -709,7 +709,7 @@ public static function join( $array, $glue, $finalGlue = '' ) {
*/
public static function last( $array, callable $callback = null, $default = null ) {
if ( is_null( $callback ) ) {
return empty( $array ) ? value( $default ) : end( $array );
return empty( $array ) ? self::value( $default ) : end( $array );
}

return static::first( array_reverse( $array, true ), $callback, $default );
Expand Down Expand Up @@ -1459,4 +1459,18 @@ public static function intersect_key_recursive( array $array, array ...$arrays )

return $array;
}

/**
* Return the default value of the given value.
*
* @template TValue
* @template TArgs
*
* @param TValue|\Closure(TArgs): TValue $value
* @param TArgs ...$args
* @return TValue
*/
private static function value( $value, ...$args ) {
return $value instanceof Closure ? $value( ...$args ) : $value;
}
}