Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
8acb6ae
Update dependencies.
oliverearl Oct 8, 2025
7dbbbbf
Update test coverage command to enforce minimum coverage threshold
oliverearl Oct 8, 2025
029e8fe
Standardise workflow names for clarity and consistency, and make nece…
oliverearl Oct 8, 2025
258a65b
Update PHP and Laravel requirements in README to reflect version changes
oliverearl Oct 8, 2025
be2fa87
Add strict types declaration to PHP files for improved type safety
oliverearl Oct 8, 2025
9c4f5ae
Refactor FixedArrayFunctionsServiceProvider namespace and update comp…
oliverearl Oct 8, 2025
964734c
Refactor TestCase class to use Config facade for setting database con…
oliverearl Oct 8, 2025
95e942e
Enhance type annotations in FixedArray class for improved type safety…
oliverearl Oct 8, 2025
ea408b3
Update docblock in FixedArray class to use @mixin for improved clarity
oliverearl Oct 8, 2025
23e07ec
Rename FixedArrayFunctionsServiceProvider to FixedArrayServiceProvide…
oliverearl Oct 8, 2025
11440ed
Add phpstan/phpstan-mockery dependency to composer.json for enhanced …
oliverearl Oct 8, 2025
83da052
Start to remove old chunks of the old codebase
oliverearl Oct 8, 2025
9ebc097
Start to establish a new test base
oliverearl Oct 8, 2025
74207b4
Adjust Larastan setting
oliverearl Oct 8, 2025
b4ba507
Add inspection suppression for PhpPluralMixed in FixedArray.php
oliverearl Oct 8, 2025
16b2e7c
Reindex array values in FixedArray::filter to avoid null-filled gaps
oliverearl Oct 8, 2025
26d668d
Add exception documentation for FixedArray methods
oliverearl Oct 8, 2025
9ac0551
Refactor FixedArray::push to simplify value insertion logic
oliverearl Oct 8, 2025
396b734
Pint
oliverearl Oct 8, 2025
b4335d2
Add exception documentation for FixedArray::resize method
oliverearl Oct 8, 2025
4637e41
An entirely new comprehensive re-write of the fixed array logic test …
oliverearl Oct 8, 2025
a79a449
Add shift and unshift methods to FixedArray for item manipulation
oliverearl Oct 8, 2025
afdd497
Add reverse method to FixedArray for reversing item order
oliverearl Oct 8, 2025
77ec6c1
Add slice method to FixedArray for extracting portions of the array
oliverearl Oct 8, 2025
1c3b4d2
Add unique method to FixedArray for removing duplicate values
oliverearl Oct 8, 2025
d999848
Add find, findKey, and findIndex methods to FixedArray for element re…
oliverearl Oct 8, 2025
7c5c2c0
Add flatten method to FixedArray for nested array handling
oliverearl Oct 8, 2025
7fbc626
Add chunk method to FixedArray for splitting arrays into chunks
oliverearl Oct 8, 2025
5c902d2
Add chunkWhile method to FixedArray for conditional array chunking
oliverearl Oct 8, 2025
047f2f3
Add strict types declaration to FixedArrayTest for improved type safety
oliverearl Oct 8, 2025
4246b29
Fix callback return type in find method test for correct boolean eval…
oliverearl Oct 8, 2025
1998b4f
Add fill, random, and sort methods to FixedArray with corresponding t…
oliverearl Oct 8, 2025
02b0ba7
Add suppression for unhandled exception inspection in FixedArrayTest
oliverearl Oct 8, 2025
9f84d4a
Add shuffle method to FixedArray for cryptographically secure randomness
oliverearl Oct 8, 2025
aea3886
Gacha Gacha Pin Pin, I am Gachapin
oliverearl Oct 8, 2025
8d2a863
Update README.md to include new methods and descriptions for FixedArray
oliverearl Oct 8, 2025
e4405bd
Improve shuffle test in FixedArrayTest to ensure order changes
oliverearl Oct 8, 2025
4f4041e
Add WIP fluent interface for FixedArray and related tests
oliverearl Oct 8, 2025
0ad3e8c
Add alias method toFixedArray in FixedArrayable for improved usability
oliverearl Oct 8, 2025
b674b60
Change nullify method in FixedArray to return the modified array
oliverearl Oct 8, 2025
228f62a
Add new methods to FixedArrayable for enhanced functionality, just ne…
oliverearl Oct 8, 2025
b23d714
Refactor FixedArray and FixedArrayable methods to improve parameter o…
oliverearl Oct 10, 2025
40a19fc
Add tests for FixedArrayable and introduce helper function for fixed …
oliverearl Oct 10, 2025
964e564
Add helper function to create a new FixedArrayable instance
oliverearl Oct 10, 2025
5b04eee
Update GitHub funding username in FUNDING.yml
oliverearl Oct 10, 2025
6fd2c12
Update test coverage command to require 100% coverage
oliverearl Oct 10, 2025
f218372
Update return types and improve dsfargeg method for FixedArrayable
oliverearl Oct 10, 2025
2d03dd1
Update docblock for getArray method to clarify return type
oliverearl Oct 10, 2025
b1e5d84
Fix remaining phpstan errors
oliverearl Oct 10, 2025
380001f
Enhance test workflow to conditionally generate coverage reports and …
oliverearl Oct 10, 2025
2925491
Enhance test workflow to conditionally generate coverage reports and …
oliverearl Oct 10, 2025
61f4a91
Minor attempt to fix CI building problems
oliverearl Oct 10, 2025
da55122
Minor attempt to fix CI building problems x2
oliverearl Oct 10, 2025
0ad4263
Minor attempt to fix CI building problems x3
oliverearl Oct 10, 2025
36ce0ae
Revert code. Gotta try something else.
oliverearl Oct 10, 2025
0351a37
Let's nix coverage and see where that gets us.
oliverearl Oct 10, 2025
daa6729
Updating files from skeleton package
oliverearl Oct 10, 2025
b187266
Another fix attempt
oliverearl Dec 9, 2025
4311d0a
Add 8.5 support
oliverearl Dec 9, 2025
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/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
github: oliverearl
ko_fi: oliverearl
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: dependabot-auto-merge
name: Dependabot Auto-Merge
on: pull_request_target

permissions:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Fix PHP code style issues
name: Linting (Pint)

on:
push:
Expand All @@ -19,7 +19,7 @@ jobs:
with:
ref: ${{ github.head_ref }}

- name: Fix PHP code style issues
- name: Run Laravel Pint and fix styling issues
uses: aglipanci/laravel-pint-action@2.6

- name: Commit changes
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PHPStan
name: Static Analysis (Larastan)

on:
push:
Expand All @@ -24,5 +24,5 @@ jobs:
- name: Install composer dependencies
uses: ramsey/composer-install@v3

- name: Run PHPStan
- name: Run Larastan
run: ./vendor/bin/phpstan --error-format=github
18 changes: 12 additions & 6 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: run-tests
name: Automated Testing (Pest)

on:
push:
Expand All @@ -17,14 +17,12 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.4, 8.3]
laravel: [12.*, 11.*]
stability: [prefer-lowest, prefer-stable]
php: [8.4, 8.5]
laravel: [12.*]
stability: [prefer-stable]
include:
- laravel: 12.*
testbench: 10.*
- laravel: 11.*
testbench: 9.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand Down Expand Up @@ -54,3 +52,11 @@ jobs:

- name: Execute tests
run: vendor/bin/pest --ci

- name: Check Type Coverage
if: matrix.stability == 'prefer-stable'
run: vendor/bin/pest --type-coverage=100

- name: Check Profanity
if: matrix.stability == 'prefer-stable'
run: vendor/bin/pest --profanity
2 changes: 1 addition & 1 deletion .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Update Changelog"
name: Update Changelog

on:
release:
Expand Down
76 changes: 46 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ large sets of data.

## Requirements

Currently, requires PHP 8.3 or above, and Laravel 11+.
Currently, requires PHP 8.4 or above, and Laravel 12+.

## Installation

Expand Down Expand Up @@ -79,35 +79,51 @@ $everything = FixedArray::merge(

## Full list of working methods

| Method | Description | Example |
|:---------------|:----------------------------------------------------------------------------|--------------------------------------------------------------:|
| add | Alias for push. | `FixedArray::add('bacon', $arr)` |
| addFrom | Add an array or collection of items to an array. | `FixedArray::addFrom([1, 2, 3], $arr)` |
| contains | Checks whether an item exists in a given array. | `FixedArray::contains('needle', $haystack)` |
| count | Returns the number of items in a given array. | `FixedArray::count($array)` |
| create | Creates a new fixed array. | `FixedArray::create(10)` |
| each | Apply a callback to each item in the array without modifying the original. | `FixedArray::each($array, fn () => var_dump($value))` |
| filter | Applies a filter to a given fixed array. | `FixedArray::filter($array, fn ($value) => $value % 2 === 0)` |
| first | Returns the first element of the array. | `FixedArray::first($array)` |
| fromArray | Creates a new fixed array from a standard array. | `FixedArray::fromArray([1, 2, 3])` |
| fromCollection | Creates a new fixed array from an Illuminate collection. | `FixedArray::fromCollection(collect([1, 2, 3])` |
| getSize | Alias for count. | `FixedArray::getSize($array)` |
| isFixedArray | Returns whether a given item is a fixed array. | `FixedArray::isFixedArray($potentialArray)` |
| last | Returns the last element in an array. | `FixedArray::last($array)` |
| map | Applies a callback to each item in the array and returns it. | `FixedArray::map($array, fn ($value) => (string) $value)` |
| merge | Merges given arrays, fixed arrays, or collections into a given fixed array. | `FixedArray::merge($array, $array2, $array3)` |
| nullify | Overwrite all elements in an array with `null`. | `FixedArray::nullify($array)` |
| offsetExists | Returns whether a given array offset exists. | `FixedArray::offsetExists(3, $haystack)` |
| offsetGet | Retrieves the value at a given array offset. | `FixedArray::offsetGet(3, $haystack)` |
| offsetNull | Replaces the value at a given array offset with `null`. | `FixedArray::offsetNull(3, $haystack)` |
| offsetSet | Replaces the value at a given array offset with a provided value. | `FixedArray::offsetSet(3, $value, $haystack)` |
| pop | Pops the latest value from the array. | `FixedArray::pop($array)` |
| push | Pushes a given value to the first available space on the array. | `FixedArray::push($value, $array)` |
| resize | Alias for setSize. | `FixedArray::resize(10, $array)` |
| second | Returns the second value from the array. | `FixedArray::second($array)` |
| setSize | Resizes the array to a given size. | `FixedArray::setSize(10, $array)` |
| toArray | Converts a fixed array into a standard array. | `FixedArray::toArray($array)` |
| toCollection | Converts a fixed array into an Illuminate collection. | `FixedArray::toCollection($array)` |
| Method | Description |
|:---------------|:--------------------------------------------------------------------|
| add | Alias for push. |
| addFrom | Add an array or collection of items to a fixed array. |
| chunk | Split a fixed array into chunks of a given size. |
| chunkWhile | Split a fixed array into chunks while a callback returns true. |
| contains | Check whether an item exists in a fixed array. |
| create | Create a new fixed array of a given size. |
| dsfargeg | DSFARGEG |
| each | Apply a callback to each item without modifying the original array. |
| fill | Fill the array with a single value. |
| filter | Filter the array using a callback. |
| find | Return the first element matching a callback. |
| findKey | Return the key of the first element matching a callback. |
| findIndex | Alias for findKey. |
| first | Return the first element of the array. |
| fluent | Creates a new fluent interface for chaining methods. |
| flatten | Flatten nested arrays, collections, and fixed arrays. |
| fromArray | Create a fixed array from a standard array. |
| fromCollection | Create a fixed array from an Illuminate collection. |
| getSize | Return the number of elements in the array. |
| isFixedArray | Check whether a value is a fixed array. |
| last | Return the last element of the array. |
| map | Apply a callback to each item and return a new array. |
| merge | Merge multiple arrays, fixed arrays, or collections. |
| nullify | Replace all elements with null. |
| offsetExists | Check if an index exists in the array. |
| offsetGet | Get the value at a specific index. |
| offsetNull | Set a specific index to null. |
| offsetSet | Set a value at a specific index. |
| pop | Remove and return the last element. |
| push | Add a value to the first available space. |
| random | Return a random element from the array. |
| resize | Alias for setSize. |
| reverse | Reverse the order of elements. |
| second | Return the second element. |
| setSize | Resize the array to a given size. |
| shift | Remove and return the first element. |
| shuffle | Shuffle the array in a secure manner. |
| slice | Return a subset of the array. |
| sort | Sort the array optionally using a callback. |
| toArray | Convert the fixed array into a standard PHP array. |
| toCollection | Convert the fixed array into an Illuminate collection. |
| unique | Remove duplicate values from the array. |
| unshift | Prepend one or more values to the array. |

## Testing

Expand Down
35 changes: 20 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@
}
],
"require": {
"php": "^8.3",
"spatie/laravel-package-tools": "^1.16",
"illuminate/contracts": "^11.0|^12.0"
"php": "^8.4",
"spatie/laravel-package-tools": "^1.92",
"illuminate/contracts": "^12.0"
},
"require-dev": {
"laravel/pint": "^1.14",
"nunomaduro/collision": "^8.1.1",
"larastan/larastan": "^2.9|^3.0",
"larastan/larastan": "^3.7",
"laravel/pint": "^1.25",
"nunomaduro/collision": "^8.8.2",
"orchestra/testbench": "^10.1.0",
"pestphp/pest": "^3.0",
"pestphp/pest-plugin-arch": "^3.0",
"pestphp/pest-plugin-laravel": "^3.0",
"pestphp/pest": "^4.0",
"pestphp/pest-plugin-laravel": "^4.0",
"pestphp/pest-plugin-profanity": "^4.1",
"pestphp/pest-plugin-type-coverage": "*",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-deprecation-rules": "^1.1|^2.0",
"phpstan/phpstan-phpunit": "^1.3|^2.0",
"spatie/laravel-ray": "^1.35"
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-mockery": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"roave/security-advisories": "dev-latest"
},
"autoload": {
"psr-4": {
Expand All @@ -51,9 +54,11 @@
"scripts": {
"post-autoload-dump": "@composer run prepare",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"analyse": "vendor/bin/phpstan analyse",
"analyse": "vendor/bin/phpstan analyse --memory-limit=2G",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"test:coverage": "vendor/bin/pest --coverage --min=100 --memory-limit=2G",
"test:type-coverage": "vendor/bin/pest --type-coverage",
"test:profanity": "vendor/bin/pest --profanity",
"format": "vendor/bin/pint"
},
"config": {
Expand All @@ -66,7 +71,7 @@
"extra": {
"laravel": {
"providers": [
"Petrobolos\\FixedArray\\FixedArrayFunctionsServiceProvider"
"Petrobolos\\FixedArray\\Providers\\FixedArrayServiceProvider"
],
"aliases": {
"FixedArray": "Petrobolos\\FixedArrayFunctions\\Facades\\FixedArray"
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ includes:
- phpstan-baseline.neon

parameters:
level: 5
level: 9
paths:
- src
tmpDir: build/phpstan
Expand Down
50 changes: 29 additions & 21 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
<?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" 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="Petrobolos 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
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="false"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<testsuites>
<testsuite name="Petrobolos Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
9 changes: 6 additions & 3 deletions src/Facades/FixedArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
use Illuminate\Support\Facades\Facade;
use Petrobolos\FixedArray\FixedArray as BaseFixedArray;

/**
* @see FixedArray
*/
/** @mixin \Petrobolos\FixedArray\FixedArray */
class FixedArray extends Facade
{
/**
* Get the registered name of the component.
*
* @return class-string<BaseFixedArray>
*/
protected static function getFacadeAccessor(): string
{
return BaseFixedArray::class;
Expand Down
Loading