Download the PHP package hypothesisphp/lens without Composer
On this page you can find all versions of the php package hypothesisphp/lens. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hypothesisphp/lens
More information about hypothesisphp/lens
Files in hypothesisphp/lens
Package lens
Short Description Lens is a reusable object that knows how to locate, read, and transform a specific piece of data inside any object or array.
License MIT
Homepage https://github.com/HypothesisPHP/Lens
Informations about the package lens
Lens
Lens is a reusable object that knows how to locate, read, and transform a specific piece of data inside any object or array.
Installation
Quick Start
Why Lens?
The Problem
Working with nested data in PHP is verbose and error-prone:
The Solution
Features
Read
Write (Immutable)
Transform
Mutable Mode
Batch Operations
Nullable & Default
Composition
Pipelines
Path Syntax
| Syntax | Example | Meaning |
|---|---|---|
| Property | name |
Access name property/key |
| Dotted | address.city |
Deep access |
| Index | orders.0 |
Array index |
| Wildcard | orders.* |
All elements |
| Quoted | "special.key" |
Key with dots |
| Escaped | foo\.bar |
Literal dot in key |
Exists & Unset
Works With
- Objects — public, protected, private properties
- Arrays — associative and indexed
- Mixed — objects containing arrays containing objects
- ArrayAccess —
ArrayObject, custom implementations - DTOs — readonly properties
- Value Objects — immutable objects
Documentation
| Topic | Description |
|---|---|
| Getting Started | Install and first steps |
| Path Syntax | All path expressions |
| Immutable vs Mutable | When to use each mode |
| Batch Operations | Single-clone batch changes |
| Composition | Combining lenses |
| Traversals | Focusing on multiple targets |
| Pipelines | Chaining transformations |
| Attributes | PHP 8 Attribute configuration |
| Extending | Custom strategies, plugins, macros |
| Performance | Optimization details |
| Static Analysis | PHPStan & Psalm |
| Migration Guide | Moving from other approaches |
| Architecture | Complete design document |
Extensibility
Custom Clone Strategy
Custom Metadata Provider
Macros
Plugins & Middleware
Static Analysis
Fully compatible with PHPStan (level max) and Psalm (level 1). Generic type annotations:
Requirements
- PHP 8.2+
ext-mbstring
Architecture
The library is modular and interface-driven. Every component is independently replaceable:
See ARCHITECTURE.md for the complete design document.
Testing
License
MIT License. See LICENSE.
Credits
Inspired by functional programming lenses (Haskell, Scala, Monocle) — redesigned for PHP.
All versions of lens with dependencies
ext-mbstring Version *