Valinor is a must-have library for #PHP + PSR-15 based development.

It lives at the edge of your graph, between user input and your DTOs, and runs circles around all other (de-)serialization libraries out there: it's just built with @phpstan / @psalm types at its core, reducing mapping code massively, keeping type safety central.

Glad to see this getting a new major release!

https://mastodon.social/@Romm/114754020085694743

See also
https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/

Parse, don’t validate

@ocramius @phpstan @psalm

I've not used valinor but did end up going with another object hydrator because it used attributes to markup DTO properties instead of annotations.

I'm not sure it's that big of a deal but really that should be the default now right?

@pieceofthepie valinor does not use annotation nor attributes: only type inference :-)

You can use attributes, but I would discourage that.

@ocramius oh, the type reference docs page suggests otherwise?

@pieceofthepie ah, just a misunderstanding in what we define as annotations.

* `@ validate("some-rule")` would be an annotation
* `#[Validate("some-rule")]` would be an attribute
* `@ param list<int<5, 25>>` is a type declaration (not an annotation)

@ocramius @phpstan @psalm I’d be interested in seeing how that compares to spatie/laravel-data
@Synchro @phpstan @psalm I find laravel-data completely unusable: actually put a strong veto on its introduction in a codebase a couple months ago, as it pushes for god object design.

@ocramius @Synchro @phpstan @psalm what a difference an "o" makes... 🙈

I initially read "good object design" and was scratching my head. Until I reread.... 🤣

@ocramius @phpstan @psalm OK, I found LD really quick and easy to use (could do almost everything by adding attributes, no code needed), but don't need the ties to Laravel. But I'm having trouble understanding Valinor, seems much more complex...

@Synchro @phpstan @psalm it's waaaaaaay simpler: you want a T, you get a T 😋

Your objects just have to have well formed constructors