Skip to content
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

Referring to namespaced classes #9

Open
mudrd8mz opened this issue May 25, 2015 · 2 comments
Open

Referring to namespaced classes #9

mudrd8mz opened this issue May 25, 2015 · 2 comments
Assignees

Comments

@mudrd8mz
Copy link

Just for your information, Moodle coding guidelines have somewhat strict guidelines on how (not to) use the namespaced classes. Things like $this->user = new domain\user(); are explicitly discouraged at https://docs.moodle.org/dev/Coding_style#Namespaces
As with any coding style guidelines, this is something you may or may not agree with but it's a result of quite long discussions.
We do not strictly discriminate contributed plugins on the coding style. But I noticed you try to get in line with Moodle coding guidelines so I thought I would let you know here.

@markward
Copy link
Owner

Hi David,

Thanks for providing me with feedback.

Would this be resolved by adding a "use domain\user as user" line to the top of the file so that I can just refer to "user" inline?

Thanks again

Mark

@markward markward added this to the Release 2 on Moodle.org milestone May 29, 2015
@markward markward self-assigned this May 29, 2015
@mudrd8mz
Copy link
Author

mudrd8mz commented Jun 2, 2015

Would this be resolved by adding a "use domain\user as user"

Well, not really. Moodle coding style explicitly states:

Do not use named imports ("use XXX as YYY;") unless it is absolutely required to resolve a conflict.

I am just quoting https://docs.moodle.org/dev/Coding_style#Namespaces here. Please note this is really meant as a note. Of course, you can decide to ignore it (although we generally encourage the community to follow the Moodle coding style for plugins, too).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants