Repository navigation
1.1.0 - Add conditional sift macros and sift_when helper
Added
-
Conditional “sift” feature for building arrays/iterables from nested data while conditionally excluding values.
- New internal singleton
ArtisanToolbox\Core\Support\SiftMarkerused as a sentinel to mark values for exclusion. - New utility
ArtisanToolbox\Core\Support\Sifterimplementing recursive sift behavior:- Filters out
SiftMarkerinstances. - Recursively transforms supported nested structures (arrays,
Collection,LazyCollection, and other traversables). - Provides:
Sifter::toArray(iterable)Sifter::collection(Collection $collection)Sifter::lazyCollection(LazyCollection $collection)
- Filters out
- New internal singleton
-
New Laravel macros registered in
CoreServiceProvider::boot():Illuminate\Support\Arr::sift()→ returnsSifter::toArray($items)Illuminate\Support\Collection::sift()→ returnsSifter::collection($this)Illuminate\Support\LazyCollection::sift()→ returnsSifter::lazyCollection($this)
-
New global helper:
ArtisanToolbox\Core\sift_when(bool $condition, mixed $value): mixed- Added via Composer autoloading of
src/helpers.php(autoload.files), making the helper available at Composer autoload time. - Behavior:
sift_when(false, $value)returnsSiftMarker::instance()so the value is removed bysift()when iterables are sifted.sift_when(true, $value)returns$valuedirectly.- If
$valueis aClosure, it is executed only when$conditionis true.
- Added via Composer autoloading of
-
Tests
- Added
tests/Feature/ArrSiftTest.phpcovering macro registration, inclusion/exclusion viasift_when, closure short-circuiting, recursive marker discarding across nested supported iterables (including generators), key preservation, and non-mutating/lazy behavior.
- Added
Changed
-
PHPStan configuration workflow
- Updated
phpstan.neon.distto addparameters.configDirectoriespointing atconfig. - This allows PHPStan to load additional configuration fragments from
config(while keeping the existingpathsconfiguration). - Impact: analysis/merging can change if new PHPStan config fragments exist under
config. - No runtime behavior changes—this is static analysis configuration only.
- Updated
-
Version constant
- Bumped
Core::VERSIONfrom1.0.0to1.1.0.
- Bumped
-
Documentation / developer workflow
- Updated
README.mdandCHANGELOG.mdwith usage examples for combiningArr::sift()/Collection->sift()/LazyCollection->sift()withsift_when(). - Updated the core development skills guide (
resources/boost/.../SKILL.md) with a step describing conditional array building and key/type preservation.
- Updated
-
Git ignore updates
.gitignorenow ignoresconfig/maintainer.phpandconfig/maintainer_secrets.php, which may affect developer workflows that expect those files to be committed.
Compatibility / Migration Notes
- Potential macro collisions: If other packages define
siftmacros onArr,Collection, orLazyCollection, Laravel macro behavior may cause overwrites/overlaps depending on registration order. - Composer autoload side effects: Adding
src/helpers.phptoautoload.filesmeans the helper file is loaded automatically at Composer autoload time; ensure it’s safe for your environment. - PHPStan behavior changes: If you add PHPStan fragment files under
config, they may alter analysis results due to the newconfigDirectoriessetting. Core::VERSIONchecks: Consumers inspecting theCore::VERSIONstring will now observe1.1.0.