2023-06-06 17:27:22 +02:00
include::../rule.adoc[]
2023-05-03 11:06:20 +02:00
2023-06-06 17:27:22 +02:00
For example, with the default provided regular expression ``++^[a-z][a-zA-Z0-9]*$++``, the function:
2020-06-30 14:49:38 +02:00
2024-08-09 14:06:26 +02:00
[source,php,diff-id=1,diff-type=noncompliant]
2020-06-30 10:16:44 +02:00
----
2023-06-06 17:27:22 +02:00
function DoSomething(){ // Noncompliant
// ...
}
2020-06-30 10:16:44 +02:00
----
2023-06-06 17:27:22 +02:00
should be renamed to
2020-06-30 10:16:44 +02:00
2024-08-09 14:06:26 +02:00
[source,php,diff-id=1,diff-type=compliant]
2020-06-30 10:16:44 +02:00
----
2023-06-06 17:27:22 +02:00
function doSomething(){
// ...
}
2020-06-30 10:16:44 +02:00
----
2024-08-09 14:06:26 +02:00
In case the Drupal framework is detected and the default regex is not replaced, it will follow the PHP coding standards for Drupal.
[source,php,diff-id=2,diff-type=noncompliant]
----
function doSomething(){ // Noncompliant
// ...
}
----
should be renamed to
[source,php,diff-id=2,diff-type=compliant]
----
function do_something(){
// ...
}
----
2023-05-03 11:06:20 +02:00
=== Exceptions
2020-06-30 10:16:44 +02:00
2021-01-28 15:53:33 +01:00
Methods with an ``++@inheritdoc++`` annotation, as well as magic methods (``++__construct()++``, ``++__destruct()++``, ``++__call()++``, ``++__callStatic()++``, ``++__get()++``, ``++__set()++``, ``++__isset()++``, ``++__unset()++``, ``++__sleep()++``, ``++__wakeup()++``, ``++__toString()++``, ``++__invoke()++``, ``++__set_state()++``, ``++__clone()++``, ``++__debugInfo()++``) are ignored.
2020-06-30 10:16:44 +02:00
2021-02-02 15:02:10 +01:00
2023-05-25 14:18:12 +02:00
[source,php]
2020-06-30 10:16:44 +02:00
----
2023-06-06 17:27:22 +02:00
function __construct(){...} // Compliant by exception
function __destruct(){...} // Compliant by exception
2020-06-30 10:16:44 +02:00
/**
* {@inheritdoc}
*/
2023-06-06 17:27:22 +02:00
function myFunc(){...} // Compliant by exception
2020-06-30 10:16:44 +02:00
----
2021-06-02 20:44:38 +02:00
2024-08-09 14:06:26 +02:00
== References
* https://www.drupal.org/docs/develop/standards/php/php-coding-standards#s-functions-and-variables[Drupal - Naming Conventions - Functions and variables]
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-09-20 15:38:42 +02:00
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
2023-05-25 14:18:12 +02:00
=== Parameters
.format
****
----
^[a-z][a-zA-Z0-9]*$
----
Regular expression used to check the [method|function|subroutine] names against
****
2021-09-20 15:38:42 +02:00
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
2023-06-22 10:38:01 +02:00
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]