Problem/Motivation
FILE: /var/www/html/my-drupal10-site/web/modules/contrib/twilio/twilio.module
------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 4 LINES
------------------------------------------------------------------------------------------
17 | WARNING | [ ] Global constants should not be used, move it to a class or interface
18 | WARNING | [ ] Global constants should not be used, move it to a class or interface
40 | WARNING | [x] There must be no blank line following an inline comment
40 | WARNING | [ ] There must be no blank line following an inline comment
107 | WARNING | [x] There must be no blank line following an inline comment
107 | WARNING | [ ] There must be no blank line following an inline comment
Steps to reproduce
You can use phpcs to see this warnings
Proposed resolution
1. Create in the folder of your module the 'src' folder.
2. Create the 'MymoduleInterface.php' file and put it into the 'src' folter.
/mymodule/src/MymoduleInterface.php
3. Insert into the 'MymoduleInterface.php' the code like this:
<?php
namespace Drupal\mymodule;
/**
* Provides an interface for mymodule constants.
*/
interface MymoduleInterface {
/**
* The description of the constant.
*/
const MYMODULE_CONST = 42;
}
4. Add this interface into the 'use' section of the 'mymodule.module' file:
use Drupal\mymodule\MymoduleInterface;
That's all, now you can use the constant in your module like this:
MymoduleInterface::MYMODULE_CONST;