Sign in

Romain Canon

@romain-canon.com
68 followers 172 following 92 posts

🐘 PHP developer, OSS enthusiast. github.com/romm mastodon.social/@Romm x.com/Rommsteinz

PostsRepliesMedia
Romain Canon @romain-canon.com · 11/08/2026
The mapper meets a type it cannot parse yet? Override it with `@valinor-var`, `@valinor-param` or `@valinor-return`. PHPStan and Psalm keep using their own annotations.
PHP code showing a phpstan-param annotation with a conditional type, and a valinor-param annotation overriding it with int or null.
100
Romain Canon @romain-canon.com · 11/08/2026
A `@template` annotation can now declare a default type with `=`. This is what makes templates adoptable incrementally: existing references keep resolving to the default, and can be made more precise later.
PHP code showing a Page class with two templates, TMeta declaring a default type with an equals sign, and comments showing that Page of string falls back to the default.
100
Romain Canon @romain-canon.com · 11/08/2026
Generics now work with PHP internal classes: `ArrayObject`, `ArrayIterator`, the SPL structures, the `Ds` collections… They cannot declare `@template` themselves, so the library ships generic signatures for them.
PHP code mapping an array of sizes to the generic type ArrayObject of string keys and integer values.
100
Romain Canon @romain-canon.com · 11/08/2026
Three new normalizer configurators: `NormalizeKeyTo` renames a key in the output, `NormalizeToSingleValue` flattens single-property objects, and `IgnoreOnNormalization` keeps sensitive data out of the normalized result.
PHP code showing an IgnoreOnNormalization attribute on a password property, which is then absent from the normalized array.
100
Romain Canon @romain-canon.com · 11/08/2026
Map a property from a specific source key with `#[MapFromKey('zipCode')]`. The underlying protocol is open to userland: any attribute declaring a `mapKey()` method and carrying `#[AsConverter]` can remap keys, for instance to strip a prefix shared by several properties.
PHP code showing a MapFromKey attribute feeding the postalCode property from the zipCode source key.
100
Romain Canon @romain-canon.com · 11/08/2026
Scalar value casting, with fine-grained control: cast a single property with `#[MapAsInt]`, `#[MapAsBool]`, `#[MapAsFloat]` or `#[MapAsString]`, or enable casting for one type everywhere with `allowCastingToInteger()` and friends. Strictness stays untouched for everything else.
PHP code showing MapAsInt and MapAsBool attributes casting the string '42' to an integer and 'on' to true during mapping.
100
Romain Canon @romain-canon.com · 11/08/2026
Mapper configurators now come out of the box: `MapToDateTimeFromFormat`, `MapExplodedStringToList`, `MapArrayToList` and `MapFromJson`. Use them globally with `configureWith()`, or locally as an attribute on a single property.
PHP code showing a MapToDateTimeFromFormat attribute on a DateTimeInterface property, and a mapper call turning the string '08/11/1971' into a date.
100
Romain Canon @romain-canon.com · 11/08/2026
🔔 Valinor 2.6.0 is out! #PHP This release is packed: provided mapper configurators, scalar value casting, key remapping, new normalizer configurators, generics for PHP internal classes, default types for templates, and more. ⤵️
Release card titled Valinor 2.6.0 with the Valinor logo, describing the library as a PHP library that maps any input into a strongly-typed structure, and listing the highlights: provided mapper configurators, scalar value casting, mapping from a specific key, new normalizer configurators, generics of PHP internal classes, default types for templates, and overriding an unparseable type.
120
Romain Canon @romain-canon.com · 03/06/2026
The reason GitHub uptime is bad these days: they do a lot of renovation work.
A building under renovation, with a facade covered in green mosaics that looks like a GitHub contribution graph.
011
Romain Canon @romain-canon.com · 25/05/2026
Vendredi dernier avait lieu l'@afup.org Day : une journée de conférences en simultané à Bordeaux, Lille, Lyon et Paris. J'ai eu la chance de pouvoir présenter à Lille ma conférence « Test simplifié à moitié pardonné » — vous pouvez retrouver les slides ici : romm.github.io/test-simplif...
Photo de moi sur scène présentant la conférence « Test simplifié à moitié pardonné »
241
Romain Canon @romain-canon.com · 21/04/2026
Valinor — #PHP object mapping library — has recently crossed 10 million downloads on Packagist! I'm really proud of what it means: more and more #PHP developers are eager for stricter codebases, which is a great achievement. 🎉 Haven't heard of it yet? Check it out! github.com/CuyZ/Valinor
030
Romain Canon @romain-canon.com · 23/03/2026
✨ We also got you covered for when you want to enforce the key case… ⤵️
Code snippet that shows how to use Valinor's case restriction configurators
101
Romain Canon @romain-canon.com · 23/03/2026
✨ And the first configurators provided out of the box are the case conversion configurators: automatically convert source keys to `camelCase` or `snake_case` formats! ⤵️
Code snippet that shows how to use Valinor's case conversion configurators
101
Romain Canon @romain-canon.com · 23/03/2026
🔥 This release also brings support for mapper/normalizer configurators: reusable piece of configuration logic. This is useful when the same configuration needs to be applied in multiple places across an application, or when configuration logic needs to be distributed as a package. ⤵️
Code snippet that shows how to use Valinor's mapper configuratorsCode snippet that shows how to use Valinor's normalizer configurators
101
Romain Canon @romain-canon.com · 23/03/2026
The awesome @ocramius.mastodon.social.ap.brid.gy has been working on a native integration with Mezzio! This means being able to *very easily* map PSR-7 requests to strictly-typed objects! Look at the example below to see how trivial it becomes. More info: github.com/mezzio/mezzi... ⤵️
Code snippet that shows how to use HTTP request mapping with Mezzio
100
Romain Canon @romain-canon.com · 23/03/2026
The Symfony bundle has been updated to support this feature out of the box! More info: github.com/CuyZ/Valinor... ⤵️
Code snippet that shows how to use HTTP request mapping with Symfony
101
Romain Canon @romain-canon.com · 23/03/2026
🔔 #PHP object-mapper library Valinor v2.4.0 released! 🚀 This huge release brings exciting new features: - Out of the box HTTP request mapping - Mapper/normalizer configurators - CamelCase/snake_case keys conversion - Keys case restriction github.com/CuyZ/Valinor... ⤵️ see below for more details ⤵️
110
Romain Canon @romain-canon.com · 07/01/2026
Coucou Lille, on se voit le 22 mai pour parler de tests ? 🤗
031
Romain Canon @romain-canon.com · 10/10/2025
@dunglas.dev, @nicolasgrekas.bsky.social, @asgrim.dev and Gina Banyard talking about PHP, its future and @thephpf.bsky.social 🐘 Thank you @afup.org for this amazing event!
People on stage talking about PHP
011
Romain Canon @romain-canon.com · 23/07/2025
Keys coming from the input may differ from the target object properties and need to be renamed before mapping the values to the object. With the following converter example, keys will be renamed properly:
Keys renaming converter example
100
Romain Canon @romain-canon.com · 23/07/2025
When dealing with input data that is a string representation of an array, for instance a comma-separated list, a converter attribute can be used to convert the string into a list:
Explode converter example
100
Romain Canon @romain-canon.com · 23/07/2025
First example: boolean conversion. Values such as 'yes'/'no' can be used in malformatted external APIs, and need to be converted to a boolean value. This can be achieved by creating a custom converter that will convert these values to the expected type.
Boolean conversion converter example
100
Romain Canon @romain-canon.com · 23/07/2025
🔔 #PHP object-mapper library Valinor v2.1.0 released! This version introduces a powerful new feature: attribute converters, which provide more granular control over the mapping of properties. More info below ⤵️
Valinor 2.1 release banner
111
Romain Canon @romain-canon.com · 02/07/2025
How can people not want to get such a beautiful mug ☕️ Helps me write PHP everyday!
A mug with a logo referring to "Punk’s not dead" but "Punk" is replaced by "PHP"
100
Romain Canon @romain-canon.com · 27/06/2025
Things I've been up to over the last 30 days: - 👨‍🍼 Became a dad - 🎉 In between diaper changes, I worked on preparing the release of version 2.0 of Valinor, a PHP library that helps to map any input into a strongly-typed value object structure. Release notes: github.com/CuyZ/Valinor... Enjoy! 🥳
Banner for the release of version 2.0 of Valinor, a PHP library that helps to map any input into a strongly-typed value object structure.
232
Romain Canon @romain-canon.com · 21/05/2025
🐘 Big milestone incoming for #PHP OSS: Ondřej Mirtes (PHPStan) and Maks Rafalko (Infection) are joining forces to improve the integration of their tools when used together. Expect smoother integration, better mutation analysis, and less false-positive result for these two awesome projects!
PHPStan logo and Infection logo with a hearth in the middle
110
Romain Canon @romain-canon.com · 14/04/2025
💪
100
Romain Canon @romain-canon.com · 12/12/2024
On se retrouve ce soir au Meetup organisé par @lyon.afup.org pour parler de comment prendre soin de nos tests. 😊 Plus d'infos : www.meetup.com/afup-lyon-ph...
Première dispositive de la présentation « Test simplifié à moitié pardonné »
001