-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feat: rename namespaces and provide aliases #1937
Conversation
7a1341b
to
177d69b
Compare
@@ -0,0 +1,29 @@ | |||
<?php | |||
|
|||
$classMap = [ |
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'm worried about this map falling out of date if we add new classes. Would be nice to test that all the classes in the src
folder within the Google\\
namespace have a mapping. Some combination of RecursiveDirectoryIterator
and FileReflector
maybe.
Also, maybe just my preference, but I'd reverse the keys and values of this array. Makes more sense to me that the real name is the key, and also corresponds better to the argument order of class_alias()
.
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'm worried about this map falling out of date if we add new classes
Stupid outsider question (apologies if this isn't appropriate here!): why would a new class still be relevant for the old non-namespaced version? Would this still be maintained in parallel … 🤔
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.
That's a good point, I suppose it's something that we'd need to consider. It would seem strange to have some classes without aliases, but maybe that's good, might be a nudge towards upgrading to use the namespace.
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 switched the order of aliases.php
I agree with @mfn that there'd be no reason to add an alias for a new class
I think I have a small preference for the |
@jdpedrie I think it makes things easier and simpler to autoload |
…ent into phpgen-2.0
Addresses #692:
Backwards-compatibility concerns
BC is preserved using
aliases.php
. This loads the (minimal) 20 classes in this library upfront and creates aliases for them.Another option is to define a custom
autoload.php
which lazy-loads theGoogle_
classes as they're requested:The problem with this is the
autoload.php
function is invoked on every class-exists. Which is preferred? Tell me your thoughts in the comment section and don't forget to smash that "subscribe" button!Note: this is independent of
google/apiclient-services