File tree Expand file tree Collapse file tree 4 files changed +36
-13
lines changed
Expand file tree Collapse file tree 4 files changed +36
-13
lines changed Original file line number Diff line number Diff line change 122122
123123 <rule ref =" SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator" />
124124 <rule ref =" SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses" />
125+ <!-- Allow global names with backslash like \Drupal. -->
126+ <rule ref =" SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly" >
127+ <properties >
128+ <property name =" allowFullyQualifiedGlobalClasses" value =" true" />
129+ <property name =" allowFullyQualifiedGlobalFunctions" value =" true" />
130+ <property name =" allowFullyQualifiedGlobalConstants" value =" true" />
131+ <property name =" allowFallbackGlobalFunctions" value =" true" />
132+ <property name =" allowFallbackGlobalConstants" value =" true" />
133+ </properties >
134+ </rule >
135+ <rule ref =" SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName" >
136+ <exclude-pattern >*.api.php</exclude-pattern >
137+ </rule >
138+ <rule ref =" SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedNameWithoutNamespace" >
139+ <severity >0</severity >
140+ </rule >
125141 <rule ref =" SlevomatCodingStandard.PHP.ShortList" />
126142
127143 <rule ref =" Squiz.Arrays.ArrayDeclaration" />
298314 <exclude-pattern >*/\.svn/*</exclude-pattern >
299315 <exclude-pattern >*/\.hg/*</exclude-pattern >
300316 <exclude-pattern >*/\.bzr/*</exclude-pattern >
301-
317+
302318 <!-- Ignore minified CSS files.-->
303319 <exclude-pattern >*\.min\.css$</exclude-pattern >
304320</ruleset >
Original file line number Diff line number Diff line change 88 * without them.
99 * phpcs:disable Drupal.Commenting
1010 */
11-
1211use Foo\Bar;
1312
1413/**
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Drupal \mymodule ;
4+
5+ /**
6+ * Some fluffy comment about the class.
7+ */
8+ class GoodNamespace {
9+
10+ /**
11+ * Using \Drupal without a use statement is fine.
12+ */
13+ public static function version (): string {
14+ return \Drupal::VERSION . phpversion () . \phpversion ();
15+ }
16+
17+ }
Original file line number Diff line number Diff line change @@ -1397,17 +1397,6 @@ public function test() {
13971397
13981398}
13991399
1400- // Namespaced function call is allowed because PHP 5.5 and lower do not support
1401- // use statements for functions.
1402- $ default_config = [
1403- 'verify ' => TRUE ,
1404- 'timeout ' => 30 ,
1405- 'headers ' => [
1406- 'User-Agent ' => 'Drupal/ ' . \Drupal::VERSION . ' (+https://www.drupal.org/) ' . \GuzzleHttp \default_user_agent (),
1407- ],
1408- 'handler ' => $ stack ,
1409- ];
1410-
14111400// camelCase and snake_case variables are allowed.
14121401$ snake_case = 1 ;
14131402$ camelCase = 1 ;
@@ -1819,3 +1808,5 @@ public function attributes(): void {
18191808 }
18201809
18211810}
1811+
1812+ $ version = \Drupal::VERSION ;
You can’t perform that action at this time.
0 commit comments