Core currently uses two different wording styles of getter docblocks, "Gets the..." and "Returns the..."
Examples:
/**
* Gets the context value.
*
* @return mixed
* The currently set context value, or NULL if it is not set.
*/
public function getContextValue();
/**
* Returns the asset libraries attached to the current response.
*
* @return string[]
*/
public function getLibraries();
This is a small but annoying inconsistency, impacting DX because it's not obvious what the "right way" is purely from looking at code.
The outside PHP world prefers "Gets...", newer core code does as well. I've spoken to Alex Pott at the dev days and he has agreed that we should standardize on "Gets..."
So, plan of action:
1) We create a bunch of issues with patches. Smaller patches == less chance of conflicts.
2) We update the drupal.org page on docblocks, and document the preferred style.
I will reroll any core patch broken by these changes. Just list them in this issue or one of the child ones.
Comments
Comment #1
jhodgdonWe have many many many more important issues than this, where documentation is actually unclear. This is just a minor thing -- both "Gets" and "Returns" are clear, and if we pick one or the other, someone is going to bikeshed it. So to me this seems like a waste of time and effort... There are pages and pages of actual issues in docs where the docs are wrong or unclear. Can we fix these instead of spending time on things like this?
Comment #2
bojanz commentedI have created the first two patches, let's see how they go.
Drupal\Component is our most outward facing code, and Drupal\Core\Entity is the biggest offender with the most effect on contrib.
As I said on IRC, I truly believe this issue is important, because a developer must be able to understand the recommended way of doing things by reading core code. If core is internally inconsistent, that creates a DX impact.
Comment #3
googletorp commentedI added a task for the node module, think this make sense as I believe the node module often is used as an example module / best practice module for how to do stuff, as it's a very complete module.
Comment #4
bojanz commentedComment #5
dawehner.
Comment #19
quietone commentedThis is really about a coding standard for the summary line of a getter. Moving to Coding Standard project.
Comment #20
quietone commentedThere is an older issue about standardizing the getters and setters. Therefor I am closing this so there is one place to discuss a solution.