You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to be able to detect missing/badly typed properties with static analysis.
So the __construct(array $rawModelDataInput = []) is not ideal in that regards since dev will see their error at runtime.
Would it be possible, maybe via a config option, to generate constructor of the form __construct(string $propA, int $propB)?
With php 8.1 we would also be able to use named arguments to avoid unreadable constructors.
The text was updated successfully, but these errors were encountered:
Explicit arguments aren't intended by design. They would require the developer, especially for nested objects, to set up the whole object structure manually and pass initialized nested objects to outer objects (eg. if you have a customer and the customer has a address object you'd need to initialize the address object first).
Additionally to the manual initialization of each nested object this would disable collecting all errors from the provided data (eg. invalid address data would throw an error before invalid customer data is detected).
The intention of the objects is, to handle data from a source where you don't pass single variables to the object (eg. you process data via an API).
What you could do if you really want to have the functionality, is to implement a post processor which adds a static factory method which wraps the constructor and provides the arguments.
I'd like to be able to detect missing/badly typed properties with static analysis.
So the
__construct(array $rawModelDataInput = [])
is not ideal in that regards since dev will see their error at runtime.Would it be possible, maybe via a config option, to generate constructor of the form
__construct(string $propA, int $propB)
?With php 8.1 we would also be able to use named arguments to avoid unreadable constructors.
The text was updated successfully, but these errors were encountered: