Open
Description
A file containing the following code causes a There must be no blank lines before the file comment error when running phpcs --standard="$HOME/.config/phpcs_rulesets/Backdrop" ./myclass.class.inc
.
<?php
/**
* @file
* Contains \MyModule\MyClass.
*/
/**
* Class description.
*/
class MyClass implements MyClassInterface {
/**
* A protected property.
*
* @var int
*/
protected $property;
}
The full report is the following. (I just changed the full filename to relative and made the separation lines shorter.)
FILE: ./myclass.class.inc
-----------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------
1 | ERROR | There must be no blank lines before the file comment
| | (Backdrop.Commenting.FileComment.SpacingAfterOpen)
-----------------
Adding a namespace, as in the following example code, that error is not anymore reported.
<?php
/**
* @file
* Contains \MyModule\MyClass.
*/
namespace MyModule;
/**
* Class description.
*/
class MyClass implements MyClassInterface {
/**
* A protected property.
*
* @var int
*/
protected $property;
}
FILE: ./myclass.class.inc
-----------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------
3 | ERROR | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
| | (Backdrop.Commenting.FileComment.NamespaceNoFileDoc)
-----------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------
I tried changing what follow Contains (just the class name, the class name and the namespace without the \
at the beginning), but phpcs
still does not report that error, when a namespace is used.
I edited the code to show a more complete class definition.
Metadata
Metadata
Assignees
Labels
No labels