-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Encourage use of constants #10308
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
Encourage use of constants #10308
Conversation
Function should be static and we should also encourage the use of constants
Sorry, it shouldn't be static as that method comes from Doctrine and differs to Symfony's event subscriber. Updated that and just kept the constants. |
@trsteel88 thanks for this contribution! However, I think the new code is different than the existing code. Is this a bug fix, an improvement or both? We'll need help from Doctrine experts to verify this proposal. Thanks! |
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.
@javiereguiluz this doesn't change the existing code. You can see from the doctrine source that event constants are the same as the original strings.
Also the doctrine documentation recommends using the event constants:
<?php
use Doctrine\ORM\Events;
echo Events::preUpdate;
'postPersist', | ||
'postUpdate', | ||
\Doctrine\ORM\Events::postPersist => 'postPersist', | ||
\Doctrine\ORM\Events::postUpdate => 'postUpdate', |
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 think we should import Doctrine\ORM\Events
and use Events::postPersist
and Events::postUpdate
here instead.
Thank you for this change @trsteel88. I have merged your changes into the |
* 2.8: [symfony#10308] add use statement and fix array Encourage use of constants delete var_dump() functions in examples
* 3.4: [symfony#10308] add use statement and fix array Encourage use of constants Update code-splitting.rst delete var_dump() functions in examples Update image to reflect given state machine example configuration
* 4.1: [symfony#10308] add use statement and fix array Encourage use of constants Update code-splitting.rst delete var_dump() functions in examples Update image to reflect given state machine example configuration
No worries. Sorry I fell off the face of the earth. Been a bit hectic. |
Function should be static and we should also encourage the use of constants