> For the complete documentation index, see [llms.txt](https://senselab.gitbook.io/senselab-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://senselab.gitbook.io/senselab-docs/vendor/sanmai/pipeline/docs/reference/changelog.md).

# Changelog

This document outlines the version history and key changes for the Pipeline library.

## Version 7.x

### Key Features

* **New Methods**: Added `tap()`, `chunkBy()`, and `cursor()` for more expressive pipelines.
* **Enhanced peek()**: Now returns a Pipeline instance for fluent API chaining.
* **PHP 8.5 Support**: Full compatibility with PHP 8.5.
* **JIT Compatibility**: Workaround for PHP JIT NAN bug.

### New Methods in 7.x

* **`tap(callable $callback)`** (7.2): Execute side effects without modifying values. Useful for logging or debugging.
* **`chunkBy(callable $callback)`** (7.3): Create chunks with variable sizes based on a callback.
* **`cursor()`** (7.6): Returns a forward-only iterator that maintains position across loop breaks.

### Breaking Changes

* **`toArray()` now requires a parameter**: Use `toList()` for a simple array or `toAssoc()` for an associative array.
* **`toArrayPreservingKeys()` removed**: Use `toAssoc()` instead.

## Version 6.x

### Key Features

* **PHP 8.2+ Requirement**: The minimum required PHP version has been updated to 8.2.
* **Strict Filtering**: The `filter()` method now includes a `strict` mode for more precise control over data cleaning.
* **New Convenience Methods**: Added `first()`, `last()`, `toList()`, and `toAssoc()`.
* **Improved Type Safety**: Enhanced type annotations and static analysis support for PHPStan and Psalm.
* **Performance Optimizations**: The `cast()` method uses `array_map()` for arrays, improving performance.

### Breaking Changes from 5.x

* The minimum required PHP version is now 8.2.
* Some internal method signatures have been updated to improve type safety.

### Deprecations in 6.x

* `toArray()`: Deprecated, use `toList()` or `toAssoc()` instead.
* `toArrayPreservingKeys()`: Deprecated, use `toAssoc()` instead.

## Migration Guide

### Migrating from v6.x to v7.x

**Array Conversion (Breaking Change)**

The `toArray()` method now requires a boolean parameter. Replace all previous usages as follows:

```php
// Before: toArray() or toArray(false) - get indexed array
$result = take([1, 2, 3])->toArray();
$result = take([1, 2, 3])->toArray(false);

// After: use toList()
$result = take([1, 2, 3])->toList();


// Before: toArray(true) - get associative array with preserved keys
$result = take($data)->toArray(true);

// After: use toAssoc()
$result = take($data)->toAssoc();
```

**toArrayPreservingKeys() Removed**

```php
// Before (v6.x)
$result = take($data)->toArrayPreservingKeys();

// After (v7.x)
$result = take($data)->toAssoc();
```

**New Features to Consider**

After migrating, consider using these new methods for cleaner code:

```php
// tap() for side effects without modifying values
take($users)
    ->tap(fn($user) => logger()->info("Processing: {$user->name}"))
    ->map(fn($user) => $user->email)
    ->toList();

// chunkBy() for variable-size chunks
take($records)
    ->chunkBy(fn($record) => $record->category)
    ->each(fn($chunk) => processCategory($chunk));

// cursor() for pauseable iteration
$cursor = take($largeDataset)->cursor();
foreach ($cursor as $item) {
    process($item);
    if (needsPause()) {
        break; // Can continue later from same position
    }
}
// Continue iteration later...
foreach ($cursor as $item) {
    process($item);
}
```

### Migrating from v5.x to v6.x

**Array Conversion**

* Replace `->toArray()` or `->toArray(false)` with `->toList()`.
* Replace `->toArray(true)` or `->toArrayPreservingKeys()` with `->toAssoc()`.

**Filtering**

To maintain the old filtering behavior (which removes all falsy values), no changes are needed. To use the new, safer strict filtering, add the `strict: true` parameter:

```php
// Old behavior (removes all falsy values)
$result = take([0, '', false, null])->filter()->toList(); // []

// New strict mode (removes only null and false)
$result = take([0, '', false, null])->filter(strict: true)->toList(); // [0, '']
```

## Future Development

The library follows semantic versioning. Future development will focus on:

* Performance and memory optimizations
* Enhanced type safety
* Additional statistical methods

For the latest updates, please refer to the [GitHub repository](https://github.com/sanmai/pipeline).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://senselab.gitbook.io/senselab-docs/vendor/sanmai/pipeline/docs/reference/changelog.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
