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
minor #799 [DX] [ResetPassword] lets stop abusing input arguments (jrushlow)
This PR was merged into the 1.0-dev branch.
Discussion
----------
[DX] [ResetPassword] lets stop abusing input arguments
We're currently abusing input arguments by using them as data stores internally. This PR is the first of many to refactor makers to replace input argument with proper class properties, add method return types where possible, and general housekeeping to improve code readability.
The first maker to use this approach was `make:docker:database` found [here](https://github.com/symfony/maker-bundle/blob/main/src/Maker/MakeDockerDatabase.php).
One decision we should make now before proceeding with refactoring additional makers is in regards to the docBlock format we should use for properties. Symfony uses the expanded format - but this can lead to reduced readability with a class that has multiple properties. As a solution to this we could break tradition and use single line docBlocks strictly for internal maker properties.
```php
// Traditional expanded properties
/**
* @var string type of database selected by the user
*/
private $databaseChoice;
/**
* @var string Service identifier to be set in docker-compose.yaml
*/
private $serviceName = 'database';
/**
* @var string Version set in docker-compose.yaml for the service. e.g. latest
*/
private $serviceVersion = 'latest';
```
```php
// Single line
/** @var string The "FROM" email address to be used in email template. */
private $fromEmailAddress;
/** @var string The "FROM" name used in the email template. */
private $fromEmailName;
/** @var string Redirect route to be used after a successful password reset. Route does not have to exist. */
private $controllerResetSuccessRedirect;
```
Another consideration to be made is `types` and `descriptions`. When the minimum supported PHP version for Symfony reaches `7.4`, we will be able to use typed properties. Until then I think we could omit types declared in property docBlocks unless we actually need a docBlock to begin with. Which leads me to, should we include descriptions for all properties as shown above (not included in the actual PR) or only when describing the property can not be done clearly with the property name itself.
*Disclaimer - All of the above is scoped strictly to Makers and input argument replacements. It should not be taken out of context for the public API or generated code.
Commits
-------
322ccfe lets stop abusing input arguments
$closing[] = sprintf(' 1) Run <fg=yellow>"php bin/console make:migration"</> to generate a migration for the new <fg=yellow>"%s"</> entity.', $requestClassName);
0 commit comments