From http://drupal.org/node/1497230#comment-5826480 we should establish a standard for function calls that pull "global" information (currently in global variables but soon from the drupal_container()) to be at the start of a given function so that we can improve readability.

Creating this a separate issue so that #1497230: Use Dependency Injection to handle object definitions can move forward.

Comments

Crell’s picture

Shouldn't we standardize on not using globals in the first place and leveraging dependency injection properly? :-) This seems like an unnecessary step.

pdrake’s picture

For OO code, leveraging dependency injection is probably sufficient, but for code which remains firmly procedural (of which I imagine there will be some in D8), the dependencies have to be explicitly instantiated or made available within scope of the function, correct?

cosmicdreams’s picture

@Crell, yes, the key of this issue is not the manner in which the information is passed to the function, just a standardization of where the information is passed from a outside of the class (when arguments are not used) to the inner scoping of a function.

I couldn't think of a better title and this issue only has a "title fail". If anyone has a proper description of the issue please rename it.

catch’s picture

Component: wscci » base system

I actually prefer the $GLOBALS syntax since it's more clear in context where the value is coming from - for example it makes it much more difficult to confuse global $user and $account and similar.

Also this is so not a wscci issue.

sun’s picture

sun’s picture

Issue tags: +Coding standards
wizonesolutions’s picture

Assigned: Unassigned » wizonesolutions
Issue tags: +tcdrupal2012

Gonna try taking a stab at this.

wizonesolutions’s picture

Assigned: wizonesolutions » Unassigned

Isn't $GLOBALS the PHP way to do it (when absolutely necessary)?

jhodgdon’s picture

Issue tags: -Novice, -tcdrupal2012

This issue is not ready for a patch yet. We first need to discuss and establish the standard.

jhodgdon’s picture

Project: Drupal core » Drupal Technical Working Group
Version: 8.0.x-dev »
Component: base system » Documentation
Issue summary: View changes
Issue tags: -Dependency Injection (DI)

Coding standards decisions are now supposed to be made by the TWG... and I don't think this is relevant to dependency injection any more?

Crell’s picture

I think this is in practice irrelevant now, per #1.

jhodgdon’s picture

Status: Active » Closed (works as designed)

OK, let's just close this.