New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding PHPDocs to templates #284
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there!
Thanks for this! I’ve started reviewing this. The big change that’s needed is that a lot of the documentation doesn’t add value. I’m +1 for adding docs that describes something that is not already obvious.
Could you remove the docs that are already obvious from existing type-hints, etc?
Thanks!
src/Resources/skeleton/authenticator/EmptyAuthenticator.tpl.php
Outdated
Show resolved
Hide resolved
Hi @weaverryan . Sorry, I was on PHPDD conference in Dresden and have no time to finish this PR. see you again on SymfonyCon this year ;) |
@@ -26,7 +23,7 @@ class <?= $class_name."\n" ?> | |||
/** | |||
* @return int|null | |||
*/ | |||
public function getId(): ?int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's php 7.0.8
defined in composer.json
But return type or null
come just in php 7.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make:entity requires PHP 7.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. Let's revert this change.
Hey @weaverryan I've refactor code, please make a code review before I'll fix tests (some tests depends on created templates) Few words about last commit:
have a good time while reviewing ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments about additions which are not necessary because IDEs can get the information from other ways. Thanks!
} | ||
|
||
/** | ||
* {@inheritdoc} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dislike these {@inheritdoc}
so much 😢 Isn't PhpStorm smart enough to do that without adding this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be nice indeed (I don't use PhpStorm, and I don't care about theses inheritdoc)
use TargetPathTrait; | ||
|
||
<?= $user_is_entity ? " private \$entityManager;\n" : null ?> | ||
<?= $user_is_entity ? " /** @var EntityManagerInterface */" . PHP_EOL . " private \$entityManager;" . PHP_EOL . PHP_EOL : null ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @var
annotations in these properties and the __cosntruct()
method's @param
are not needed because constructor arguments are type-hinted and IDEs can infer the types.
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$io = new SymfonyStyle($input, $output); | ||
$symfonyStyle = new SymfonyStyle($input, $output); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I like this variable name. First, we use $io
everywhere else in Symfony. Second, this object is not really a "Symfony style" but an "input + output object that displays things using the Symfony style".
{ | ||
/** | ||
* <?= ucwords($route_name) ?> index page |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please let's remove this generic comment because it doesn't add much value.
{ | ||
/** | ||
* <?= ucwords($route_name) ?> index page |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this method we can remove the generic comment, the @param
and the @return
because IDEs can infer all that with the arguments type hints and the return types.
Same in the other methods of this class.
@@ -26,7 +23,7 @@ class <?= $class_name."\n" ?> | |||
/** | |||
* @return int|null | |||
*/ | |||
public function getId(): ?int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. Let's revert this change.
* @method <?= $entity_class_name; ?>|null find($id, $lockMode = null, $lockVersion = null) | ||
* @method <?= $entity_class_name; ?>|null findOneBy(array $criteria, array $orderBy = null) | ||
* @method <?= $entity_class_name; ?>[] findAll() | ||
* @method <?= $entity_class_name; ?>[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||
*/ | ||
class <?= $class_name; ?> extends ServiceEntityRepository | ||
{ | ||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this entire PHPdoc block for the same reasons given for the other blocks.
|
||
use Symfony\Component\Validator\Constraint; | ||
|
||
/** | ||
* Class <?= $class_name . PHP_EOL ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this generic comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many PHP Doc could be removed
@@ -1,7 +1,7 @@ | |||
<?= "<?php\n" ?> | |||
<?= "<?php" . PHP_EOL ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be reverted. We use \n everywhere, every-time
} | ||
|
||
/** | ||
* {@inheritdoc} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be nice indeed (I don't use PhpStorm, and I don't care about theses inheritdoc)
<?= $user_needs_encoder ? " /** @var UserPasswordEncoderInterface */" . PHP_EOL . " private \$passwordEncoder;" . PHP_EOL : null ?> | ||
|
||
/** | ||
* <?= $class_name; ?> constructor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be deleted. it Does not not bind new information.
* | ||
<?= $user_is_entity ? " * @param EntityManagerInterface \$entityManager" . PHP_EOL : null ?> | ||
* @param RouterInterface $router | ||
* @param CsrfTokenManagerInterface $csrfTokenManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be deleted. it Does not not bind new information.
|
||
namespace <?= $namespace ?>; | ||
|
||
use <?= $entity_full_class_name ?>; | ||
use <?= $form_full_class_name ?>; | ||
<?php if (isset($repository_full_class_name)): ?> | ||
<?php if (!empty($repository_full_class_name)): ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
I'm going to close this. It needs to be updated, and while I think some changes are good, I think some changes are not needed. A smaller PR with individual changes would work really well I think :). Cheers! |
PR Changelog
99% of changes are adding PHPDocs
EmptyAuthenticator.tpl.php
src/Resources/skeleton/authenticator/EmptyAuthenticator.tpl.php
createAuthenticatedToken
fromSymfony\Component\Security\Guard\AuthenticatorInterface
EmptySecurityController.tpl.php
src/Resources/skeleton/authenticator/EmptySecurityController.tpl.php
LoginFormAuthenticator.tpl.php
src/Resources/skeleton/authenticator/LoginFormAuthenticator.tpl.php
use TargetPathTrait;
- it's already used in extended classCommand.tpl.php
src/Resources/skeleton/command/Command.tpl.php
Controller.tpl.php
src/Resources/skeleton/controller/Controller.tpl.php
Controller.tpl.php
src/Resources/skeleton/crud/controller/Controller.tpl.php
Entity.tpl.php
src/Resources/skeleton/doctrine/Entity.tpl.php
Fixtures.tpl.php
src/Resources/skeleton/doctrine/Fixtures.tpl.php
Repository.tpl.php
src/Resources/skeleton/doctrine/Repository.tpl.php
Subscriber.tpl.php
src/Resources/skeleton/event/Subscriber.tpl.php
Type.tpl.php
src/Resources/skeleton/form/Type.tpl.php
UserProvider.tpl.php
src/Resources/skeleton/security/UserProvider.tpl.php
Voter.tpl.php
src/Resources/skeleton/security/Voter.tpl.php
Encoder.tpl.php
src/Resources/skeleton/serializer/Encoder.tpl.php
Functional.tpl.php
src/Resources/skeleton/test/Functional.tpl.php
Unit.tpl.php
src/Resources/skeleton/test/Unit.tpl.php
Extension.tpl.php
src/Resources/skeleton/twig/Extension.tpl.php
Constraint.tpl.php
src/Resources/skeleton/validator/Constraint.tpl.php
Validator.tpl.php
src/Resources/skeleton/validator/Validator.tpl.php
Class.tpl.php
src/Resources/skeleton/Class.tpl.php