-
Bug
-
Resolution: Deferred
-
Minor
-
None
-
3.9
-
None
-
MOODLE_39_STABLE
This is about to enforce the following policy decided recently (MDLSITE-6087).
Policy: Require formal namespaces for any new PHP files
Since 19th June 2020, this rule applies:
- Formal namespaces are required for any new classes in Moodle. The following exceptions apply:
- there is no requirement to move existing non-namespaced classes to a namespace; and
- where an existing mechanism exists for loading a class, and that mechanism does not support the use of a namespaced class, the existing pseudo-namespaced prefix on the class name will be allowed.
- The use of a pseudo-namespace prefix on classnames is deprecated and should only be used in the above situations.
- The use of namespaces must conform to the following rules:
- Classes belonging to a namespace must be created in a classes directory inside a plugin (e.g. mod/forum/classes), or for core code, in lib/classes or subsystemdir/classes.
- The classname and filename for all namespaced classes must conform to the automatic class loading rules. The use of formal PHP namespaces in all new code is required.
Valid examples:
namespace mod_forum;
|
class example { |
}
|
|
namespace mod_forum\external;
|
class example { |
}
|
|
namespace core_user;
|
class example { |
}
|
No longer valid:
class mod_forum_example { |
}
|
|
class mod_forum_external_invalid { |
}
|
|
class core_user_example { |
}
|
This issue is about to verify these details in the codechecker. Nothing more, nothing less.
- has been marked as being related by
-
MDLSITE-6087 Require formal namespaces for any new PHP files
- Closed