Closed (fixed)
Project:
WSCCI
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
2 Oct 2011 at 09:38 UTC
Updated:
25 Oct 2011 at 01:10 UTC
Jump to comment: Most recent file
As discussed in #1100198: Context caching causes clearing problems, comments from #31 to #38
Changing the:
HandlerInterface::getValue(array $args = array())
method signature to:
Handler::Interface::getValue(array $args = array(), ContextInterface $context = null)
Also remove the ContextInterface parameter from the HandlerAbstract::__construct() will allow us to:
HandlerInterface, HandlerAbstract and context handler manipulation altogether| Comment | File | Size | Author |
|---|---|---|---|
| #7 | handler-flyweight-2.patch | 6.17 KB | pounard |
| #1 | handler-flyweight.patch | 6.35 KB | pounard |
Comments
Comment #1
pounardNotice: this patch is dependent of http://drupal.org/node/1290476#comment-5064832
Comment #2
Crell commentedWhy remove the leading \? That's not relevant to this patch.
I think this looks sane otherwise, but holding on #1290476-16: METAISSUE - Param and variable name consistency since it's a dependency.
Comment #3
pounardDoing it by reflex and convention: Zend 2 and Symfony also does it. By the PHP error messages in error log I can safely assume that internally the leading slash does not exists: there is no notion of relative namespace.
I always leave the leading slash on SPL stuff only, also by convention: identify those directly. There probably is a technical reason of doing it since Zend 2 does it a lot in git code I read. I guess that Sympfony prefers to use \SomeClass directly in their code:, IMHO it's best to declaring all dependencies using the use statement. Seems a good thing to do: it creates a natural dependency index in your file header and the developers can see all of them at once at first sight when they open the file.
These conventions are extensively good for DX IMHO: it's a discussion that should happen for core and whatever is the result should lead to a coding standard modification.
Comment #4
Crell commentedThe leading \ on global classes is to ensure that the autoloader doesn't try to find it in the current namespace, I believe. That's a performance question.
We should probably open another issue in core for namespace usage. In general, absent an existing standard we should probably follow Symfony's lead unless there's a specific reason not to since that way we're more consistent. I'll do that in a little bit.
Comment #5
pounardFrom you:
From http://php.net/manual/en/language.namespaces.rules.php
Fully qualified names, for all objects are resolved at compile time (a fully qualified name is a name using a leading slash).
As soon as you have import rules (the use statement) your names are resolved at compile time, which means you have no impact at all at runtime.
However,
What I read here (but I can misinterpret it) is that if you use
new Some\Class;somewhere without importing it, you delay the class name resolution at runtime: this has a performance impact on runtime. Everything else you imported using the use statement will be resolved at compile time.Autoloading cannot suffer from the lack of leading slash, if you read well the first comment on the PHP manual page, every resolution attempt (at compile or at runtime) is relative either to global either to the specific namespace you are and end up by one possibility only.
So my conclusion is:
In all cases, it cannot impact autoloading at all, only name resolution before autoloading.
As soon as you use the use statement, resolution is done at compile time, which makes no difference at all at runtime, I guess especially when using an OPcode cache.
I will ask some questions on StackOverflow about this, it's an interesting topic, but to answer your question, no, it doesn't affect performances (except for compile time which basically is saved thanks to OPcodes, and that seems really insignifiant anyway).
No, it's only a matter of standard. Personally, I'm lazy and the slash does not have a nice finger position on french keyboard: I'd be glad to save a slash to type.
The only case where it matters is for SPL classes, because they basically are really common name (potential conflicts and your namespace will override SPL) and they all are in global scope.
Comment #6
pounardYou are right about opening a core issue for this anyway. I will restore the leading slash for this patch in particular. I cannot promise you doing it before a few day though.
Comment #7
pounardFixed and pushed in 1297114-handlers-flyweight branch.
This branch was branched upon the 1290476-variables-naming: the merge will be seamless.
Comment #8
Crell commentedBranch merged. Thanks!
Comment #9.0
(not verified) commentedTypo