The amount of discussions I have to hold because #Laravel devs don't want to write a read-only DTO somewhere, but instead add a dynamic property on some ActiveRecord contraption.

It's so exhausting, and it could be so simple, if it wasn't that the framework promotes terrifyingly bad software practices everywhere. #php

@ocramius I am literally right now introduce DTOs into an Laravel app to get rid of dynamic properties. So I don’t think it’s only the framework responsible, but also missing knowledge and not using PHPStan and alike.
@Konafets @ocramius out of curiosity: does the framework enforce any of those anti patterns or is it just bad documentation and tutorials?

@alexanderschnitzler PHP gave you the possibility to add properties to an object w/o declaring them. This is deprecated since 8.2 but can be overwritten by `#[AllowDynamicProperties]` or used by implementing `__set ` and `__get`.

Laravel does the latter to provide syntax sugar but does not encourage in the docs to add a property after retrieval nor blocks you from creating and using DTOs.

https://php.watch/versions/8.2/dynamic-properties-deprecated

@ocramius

PHP 8.2: Dynamic Properties are deprecated

PHP 8.2: Dynamic Properties are deprecated

PHP.Watch