NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist
Packagist, #2792 most downloaded on Packagist
Unleash the Power of Optics in your code!
Latest stable
1.2.0
Last release 1 months ago
16 Oct 2026
Release timing varies
gaps range from 2 weeks to 8 months
Nearly every release is documented
notes for 24 of 24 stable releases
Nothing withdrawn
no release was ever pulled
3 years old
24 releases · first in 2023
Drag across the ruler to compare, or tap a release to open it.
Add property_is_initialized by @veewee in https://github.com/veewee/reflecta/pull/41
Full Changelog: https://github.com/veewee/reflecta/compare/1.1.0...1.2.0
Set properties without throwing for unknown names on dynamic classes by @veewee in https://github.com/veewee/reflecta/pull/37
Full Changelog: https://github.com/veewee/reflecta/compare/1.0.1...1.1.0
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Full Changelog: 1.0.1...1.1.0
Keep unnecessary artefacts out of releases by @raphaelstolt in https://github.com/veewee/reflecta/pull/33
Full Changelog: https://github.com/veewee/reflecta/compare/1.0.0...1.0.1
Full Changelog: 1.0.0...1.0.1
Migrate Iso/Lens from SA to STAB form (Iso ) by @veewee in https://github.com/veewee/reflecta/pull/31
Full Changelog: https://github.com/veewee/reflecta/compare/0.19.0...1.0.0
This release migrates Iso and Lens from the two-parameter form to the
four-parameter STAB form. The change is almost entirely at the type
level. Runtime method signatures are unchanged, so most code keeps working
without edits. You only need to act if you write explicit Psalm/PHPDoc type
annotations for optics, implement the interfaces yourself, or rely on
compose() rejecting empty input.
New to STAB? Read the 🧬 STAB optics walkthrough for the why behind the four parameters.
| Before | After |
|---|---|
Iso<S, A> |
Iso<S, T, A, B> |
Lens<S, A> |
Lens<S, T, A, B> |
IsoInterface<S, A> |
IsoInterface<S, T, A, B> |
LensInterface<S, A> |
LensInterface<S, T, A, B> |
S and A keep their old meaning (the whole, and the focus). T and B are
the outgoing counterparts that let a write change the type. If your optic
never changes type on write, repeat the parameters: Lens<S, S, A, A>.
Iso and Lens (and their interfaces) now carry S, T, A, B:
/** @var Lens<Person, Person, string, string> */ // non-type-changing
/** @var Lens<Person, AnonymizedPerson, string, HashedName> */ // type-changing
The concrete Iso/Lens classes are invariant on all four slots; the
IsoInterface/LensInterface are covariant on all four. See the next
section for what that distinction means in practice.
The variance differs between the concrete types and the interfaces, and that is deliberate:
Iso and Lens use @template (invariant). The four slots
must match exactly. This keeps the constructor callables sound: set both
consumes B and produces T, so the concrete type can't safely vary on
those slots.IsoInterface and LensInterface use @template-covariant. A
LensInterface<Cat, Cat, string, string> is accepted where a
LensInterface<Animal, Animal, string, string> is expected, so you can store
and pass optics around by their interface.So when you want that subtype flexibility, type your stored properties,
parameters, and return types against the interface (LensInterface<...> or
IsoInterface<...>) rather than the concrete class. A property typed as
Lens<Animal, ...> rejects a Lens<Cat, ...>; the same property typed as
LensInterface<Animal, ...> accepts it.
// invariant: only an exact Lens<Animal,...> fits
/** @var Lens<Animal, Animal, string, string> */
// covariant: a LensInterface<Cat,...> is also accepted
/** @var LensInterface<Animal, Animal, string, string> */
The signatures now allow a write to produce a different type:
Lens::set(S, B): TLens::update(S, callable(A): B): TIso::from(B): TAt runtime these take exactly the same arguments as before; only the declared
types widened. Existing non-type-changing usage (B = A, T = S) is
unaffected.
compose() accepts empty inputIso\compose() and Lens\compose() now take array<...> instead of
non-empty-array<...>. Composition is a monoid:
If you previously relied on Psalm flagging an empty compose() call, that
check is gone.
optional() return type widened// before
LensInterface<S, A|null>
// after
LensInterface<S|null, T|null, A|null, B|null>
AdjacentTemplateValidator removedThe custom Psalm plugin that detected compose() boundary mismatches is gone.
Boundary mismatches are now caught by standard Psalm inference from the STAB
signatures. No configuration change is needed; just expect the diagnostics to
come from Psalm core rather than the plugin.
Nothing. set, update, from, compose and friends behave identically at
runtime.
Update two-parameter annotations to four. For the common non-type-changing case, duplicate:
-/** @var Lens<Person, string> */
+/** @var Lens<Person, Person, string, string> */
-/** @param IsoInterface<Foo, Bar> $iso */
+/** @param IsoInterface<Foo, Foo, Bar, Bar> $iso */
If your optic genuinely changes type on write, fill in the real T/B:
/** @var Lens<Person, AnonymizedPerson, string, HashedName> */
IsoInterface / LensInterface yourselfAdd the T and B template parameters and update the method signatures
(set, trySet, update, tryUpdate, from, tryFrom, optional,
compose, inverse, asLens) to match the new interface. See
src/Lens/LensInterface.php and src/Iso/IsoInterface.php for the reference
shapes.
compose() rejecting empty arraysAdd your own non-empty check before calling compose() if you still need it.
Run your static analyzer after bumping the dependency:
composer update veewee/reflecta
vendor/bin/psalm
Most fallout shows up as InvalidArgument or MismatchingDocblockParamType on
optic annotations. Apply the two-to-four parameter expansion above to fix them.
Full Changelog: 0.19.0...1.0.0
This release migrates Iso and Lens from the two-parameter form to the
four-parameter STAB form. The change is almost entirely at the type
level. Runtime method signatures are unchanged, so most code keeps working
without edits. You only need to act if you write explicit Psalm/PHPDoc type
annotations for optics, implement the interfaces yourself, or rely on
compose() rejecting empty input.
New to STAB? Read the 🧬 STAB optics walkthrough for the
why behind the four parameters.
| Before | After |
|---|---|
Iso<S, A> |
Iso<S, T, A, B> |
Lens<S, A> |
Lens<S, T, A, B> |
IsoInterface<S, A> |
IsoInterface<S, T, A, B> |
LensInterface<S, A> |
LensInterface<S, T, A, B> |
S and A keep their old meaning (the whole, and the focus). T and B are
the outgoing counterparts that let a write change the type. If your optic
never changes type on write, repeat the parameters: Lens<S, S, A, A>.
Iso and Lens (and their interfaces) now carry S, T, A, B:
/** @var Lens<Person, Person, string, string> */ // non-type-changing
/** @var Lens<Person, AnonymizedPerson, string, HashedName> */ // type-changingThe concrete Iso/Lens classes are invariant on all four slots; the
IsoInterface/LensInterface are covariant on all four. See the next
section for what that distinction means in practice.
The variance differs between the concrete types and the interfaces, and that is
deliberate:
Iso and Lens use @template (invariant). The four slotsset bothB and produces T, so the concrete type can't safely vary onIsoInterface and LensInterface use @template-covariant. ALensInterface<Cat, Cat, string, string> is accepted where aLensInterface<Animal, Animal, string, string> is expected, so you can storeSo when you want that subtype flexibility, type your stored properties,
parameters, and return types against the interface (LensInterface<...> or
IsoInterface<...>) rather than the concrete class. A property typed as
Lens<Animal, ...> rejects a Lens<Cat, ...>; the same property typed as
LensInterface<Animal, ...> accepts it.
// invariant: only an exact Lens<Animal,...> fits
/** @var Lens<Animal, Animal, string, string> */
// covariant: a LensInterface<Cat,...> is also accepted
/** @var LensInterface<Animal, Animal, string, string> */The signatures now allow a write to produce a different type:
Lens::set(S, B): TLens::update(S, callable(A): B): TIso::from(B): TAt runtime these take exactly the same arguments as before; only the declared
types widened. Existing non-type-changing usage (B = A, T = S) is
unaffected.
compose() accepts empty inputIso\compose() and Lens\compose() now take array<...> instead of
non-empty-array<...>. Composition is a monoid:
If you previously relied on Psalm flagging an empty compose() call, that
check is gone.
optional() return type widened// before
LensInterface<S, A|null>
// after
LensInterface<S|null, T|null, A|null, B|null>AdjacentTemplateValidator removedThe custom Psalm plugin that detected compose() boundary mismatches is gone.
Boundary mismatches are now caught by standard Psalm inference from the STAB
signatures. No configuration change is needed; just expect the diagnostics to
come from Psalm core rather than the plugin.
Nothing. set, update, from, compose and friends behave identically at
runtime.
Update two-parameter annotations to four. For the common non-type-changing
case, duplicate:
-/** @var Lens<Person, string> */
+/** @var Lens<Person, Person, string, string> */
-/** @param IsoInterface<Foo, Bar> $iso */
+/** @param IsoInterface<Foo, Foo, Bar, Bar> $iso */If your optic genuinely changes type on write, fill in the real T/B:
/** @var Lens<Person, AnonymizedPerson, string, HashedName> */IsoInterface / LensInterface yourselfAdd the T and B template parameters and update the method signatures
(set, trySet, update, tryUpdate, from, tryFrom, optional,
compose, inverse, asLens) to match the new interface. See
src/Lens/LensInterface.php and src/Iso/IsoInterface.php for the reference
shapes.
compose() rejecting empty arraysAdd your own non-empty check before calling compose() if you still need it.
Run your static analyzer after bumping the dependency:
composer update veewee/reflecta
vendor/bin/psalmMost fallout shows up as InvalidArgument or MismatchingDocblockParamType on
optic annotations. Apply the two-to-four parameter expansion above to fix them.
Fix compose() boundary detection under covariant Iso/Lens templates by @veewee in https://github.com/veewee/reflecta/pull/30
Full Changelog: https://github.com/veewee/reflecta/compare/0.18.0...0.19.0
Split into PSL components and Bump PHP to 84 by @veewee in https://github.com/veewee/reflecta/pull/27
Full Changelog: https://github.com/veewee/reflecta/compare/0.17.0...0.18.0
Optimize properties_set to clone once instead of per property by @veewee in https://github.com/veewee/reflecta/pull/26
Full Changelog: https://github.com/veewee/reflecta/compare/0.16.0...0.17.0
Replace azjezz/psl with php-standard-library/php-standard-library by @veewee in https://github.com/veewee/reflecta/pull/25
Full Changelog: https://github.com/veewee/reflecta/compare/0.15.0...0.16.0
Allow PSL 5.x by @veewee in https://github.com/veewee/reflecta/pull/24
Full Changelog: https://github.com/veewee/reflecta/compare/0.14.0...0.15.0
Upgrade PHP project to support PHP 8.5 by @veewee in https://github.com/veewee/reflecta/pull/23
Full Changelog: https://github.com/veewee/reflecta/compare/0.13.0...0.14.0
Infer properties_get and properties_set settings. by @veewee in https://github.com/veewee/reflecta/pull/22
Full Changelog: https://github.com/veewee/reflecta/compare/0.12.0...0.13.0
Let psalm known assignments of unknown properties by @veewee in https://github.com/veewee/reflecta/pull/21
Full Changelog: https://github.com/veewee/reflecta/compare/0.11.0...0.12.0
Introduce readonly lenses by @veewee in https://github.com/veewee/reflecta/pull/20
Full Changelog: https://github.com/veewee/reflecta/compare/0.10.0...0.11.0
Add PHP 8.4 support by @veewee in https://github.com/veewee/reflecta/pull/19
Full Changelog: https://github.com/veewee/reflecta/compare/0.9.0...0.10.0
Bump PSL by @veewee in https://github.com/veewee/reflecta/pull/18
Full Changelog: https://github.com/veewee/reflecta/compare/0.8.1...0.9.0
Remove duplicate properties indexing by @veewee in https://github.com/veewee/reflecta/pull/16
Full Changelog: https://github.com/veewee/reflecta/compare/0.8.0...0.8.1
Only filter properties when predicate is set by @veewee in https://github.com/veewee/reflecta/pull/15
Full Changelog: https://github.com/veewee/reflecta/compare/0.7.0...0.8.0
Introduce native function invocation rule + Speed up finding a single… by @veewee in https://github.com/veewee/reflecta/pull/14
Full Changelog: https://github.com/veewee/reflecta/compare/0.6.0...0.7.0
Refactored class aproach by @veewee in https://github.com/veewee/reflecta/pull/11
Full Changelog: https://github.com/veewee/reflecta/compare/0.5.0...0.6.0
Small type improvements by @veewee in https://github.com/veewee/reflecta/pull/7
Full Changelog: https://github.com/veewee/reflecta/compare/0.4.0...0.5.0
Export interfaces for Lenses and Isos by @veewee in https://github.com/veewee/reflecta/pull/6
Full Changelog: https://github.com/veewee/reflecta/compare/0.3.0...0.4.0
Fix typo in the docs by @jdreesen in https://github.com/veewee/reflecta/pull/2
Full Changelog: https://github.com/veewee/reflecta/compare/0.2.0...0.3.0
Support dynamic objects and class attributes by @veewee in https://github.com/veewee/reflecta/pull/1
Full Changelog: https://github.com/veewee/reflecta/compare/0.1.0...0.2.0
* Initial release Full Changelog: https://github.com/veewee/reflecta/commits/0.1.0
Full Changelog: https://github.com/veewee/reflecta/commits/0.1.0
One column per quarter.