coding-standard
coding-standard copied to clipboard
phpcbf breaks /** @var ... */
--- a/system/BaseModel.php
+++ b/system/BaseModel.php
@@ -299,7 +299,9 @@ abstract class BaseModel
$this->tempUseSoftDeletes = $this->useSoftDeletes;
$this->tempAllowCallbacks = $this->allowCallbacks;
- /** @var Validation $validation */
+ /**
+ * @var Validation $validation
+*/
$validation = $validation ?? Services::validation(null, false);
$this->validation = $validation;
$ vendor/bin/phpcs --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 --encoding=utf-8 system/BaseModel.php
FILE: /Users/kenji/work/codeigniter/CodeIgniter4/system/BaseModel.php
---------------------------------------------------------------------------------
FOUND 32 ERRORS AND 3 WARNINGS AFFECTING 31 LINES
---------------------------------------------------------------------------------
10 | ERROR | [ ] Missing @package tag in class comment
10 | ERROR | [ ] Missing @author tag in class comment
10 | ERROR | [ ] Missing @license tag in class comment
46 | ERROR | [ ] Missing @package tag in class comment
302 | ERROR | [x] The open comment tag must be the only content on the line
302 | ERROR | [ ] Missing short description in doc comment
302 | ERROR | [x] The close comment tag must be the only content on the line
327 | ERROR | [ ] Comment missing for @throws tag in function comment
371 | WARNING | [ ] Line exceeds 120 characters; contains 133 characters
395 | ERROR | [ ] Comment missing for @throws tag in function comment
397 | WARNING | [ ] Line exceeds 120 characters; contains 134 characters
408 | ERROR | [ ] Comment missing for @throws tag in function comment
478 | ERROR | [ ] Comment missing for @throws tag in function comment
534 | ERROR | [ ] Comment missing for @throws tag in function comment
644 | ERROR | [ ] Comment missing for @throws tag in function comment
701 | ERROR | [ ] Comment missing for @throws tag in function comment
775 | ERROR | [ ] Parameter comment must start with a capital letter
782 | ERROR | [ ] Comment missing for @throws tag in function comment
843 | ERROR | [ ] Comment missing for @throws tag in function comment
912 | ERROR | [ ] Comment missing for @throws tag in function comment
913 | ERROR | [ ] Comment missing for @throws tag in function comment
974 | ERROR | [ ] Comment missing for @throws tag in function comment
1166 | ERROR | [ ] Comment missing for @throws tag in function comment
1198 | ERROR | [ ] Comment missing for @throws tag in function comment
1217 | ERROR | [ ] Parameter comment must start with a capital letter
1221 | ERROR | [ ] Comment missing for @throws tag in function comment
1246 | ERROR | [ ] Parameter comment must start with a capital letter
1465 | ERROR | [ ] Parameter comment must start with a capital letter
1496 | ERROR | [ ] Comment missing for @throws tag in function comment
1560 | ERROR | [ ] Comment missing for @throws tag in function comment
1591 | ERROR | [ ] Comment missing for @throws tag in function comment
1627 | ERROR | [ ] Comment missing for @throws tag in function comment
1628 | ERROR | [ ] Comment missing for @throws tag in function comment
1629 | ERROR | [ ] Comment missing for @throws tag in function comment
1635 | WARNING | [ ] Line exceeds 120 characters; contains 122 characters
---------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------
Time: 613ms; Memory: 16MB
Can you please paste me a simplified example of the original file so I can create a unit test for it?
<?php
namespace CodeIgniter;
abstract class Sample
{
public function test()
{
/** @var Validation $validation */
$validation = Services::validation(null, false);
}
}
$ ./vendor/bin/phpcs --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 system/Sample.php
FILE: /Users/kenji/work/codeigniter/CodeIgniter4/system/Sample.php
----------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 4 LINES
----------------------------------------------------------------------------
2 | ERROR | [ ] Missing file doc comment
5 | ERROR | [ ] Missing class doc comment
5 | ERROR | [ ] Missing doc comment for class Sample
7 | ERROR | [ ] Missing doc comment for function test()
9 | ERROR | [x] The open comment tag must be the only content on the line
9 | ERROR | [ ] Missing short description in doc comment
9 | ERROR | [x] The close comment tag must be the only content on the line
----------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------
Time: 196ms; Memory: 10MB
It seems the rules are:
- Generic.Commenting.DocComment.ContentAfterOpen
- Generic.Commenting.DocComment.ContentBeforeClose
Should the comment like /** @var Validation $validation */ be not permitted in CI4 coding standard?
I don't think so...
We definitely want to support single-line comment. This is becoming a standard for inline annotations.