-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Use PHP 5.5's ::class notation everywhere #7187
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
Conversation
'Doctrine\Common' => __DIR__.'/vendor/doctrine/common/lib', | ||
'Doctrine\DBAL\Migrations' => __DIR__.'/vendor/doctrine/migrations/lib', | ||
'Doctrine\DBAL' => __DIR__.'/vendor/doctrine/dbal/lib', | ||
'Doctrine' => __DIR__.'/vendor/doctrine/orm/lib', |
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.
decided not to update this one, as these are not real classes. It does work in PHP, but it can confuse people.
👍 Status: Reviewed |
Should we apply changes that are applicable in 2.7 too? |
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.
👍
@wouterj as always, you did a great and amazing work here. I love what you did in the create_framework
docs. I've left some minor comments.
|
||
return new DoctrineOrmMappingsPass( | ||
$driver, | ||
array('Full\Namespace'), | ||
array(Model::class), |
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.
Is this change correct?
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.
Yes, decided to use a more real example than Full\Namespace
. Also, because ::class
always is a full namespace.
3, | ||
false, | ||
true, | ||
|
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.
Extra blank line here.
@@ -32,11 +32,11 @@ There are some helpful methods for working with the service definitions:: | |||
$definition = $container->findDefinition($serviceId); | |||
|
|||
// add a new "app.number_generator" definitions | |||
$definition = new Definition('AppBundle\NumberGenerator'); | |||
$definition = new Definition(\AppBundle\NumberGenerator::class); |
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 looks a bit strange
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.
Adding a use
statement could make this more readable, right?
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.
Yes ... right now the ::class
is redundant in this example
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 not redundant. Using ::class
in this situation keeps support for IDE refactoring tools (while string representations don't). So using ::class
is always better.
I decided to do it this way to make the code block more readable. It contains a lot of methods to interact with definitions. Having a use statement at top of this code block doesn't make much sense and adding the use statement directly above this seemed even more redundant.
$container->setDefinition('app.number_generator', $definition); | ||
|
||
// shortcut for the previous method | ||
$container->register('app.number_generator', 'AppBundle\NumberGenerator'); | ||
$container->register('app.number_generator', \AppBundle\NumberGenerator::class); |
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.
and this line looks strange too.
This PR was submitted for the 2.8 branch but it was merged into the 2.7 branch instead (closes #7187). Discussion ---------- Use PHP 5.5's ::class notation everywhere While updating to use the `::class` notation, I also fixed quite a few error's in the PHP code block, reformatted things a bit and updated some articles to use the AppBundle. /fixes #7186 Commits ------- 7892a6a Use PHP 5.5's ::class notation
This PR was merged into the 2.8 branch. Discussion ---------- Use PHP 5.5's ::class notation everywhere While updating to use the `::class` notation, I also fixed quite a few error's in the PHP code block, reformatted things a bit and updated some articles to use the AppBundle. /fixes #7186 Commits ------- cd1406f Use PHP 5.5's ::class notation
Great work Wouter! I have merged it and also backported most of the changes into the |
While updating to use the
::class
notation, I also fixed quite a few error's in the PHP code block, reformatted things a bit and updated some articles to use the AppBundle./fixes #7186