Skip to content

Latest commit

 

History

History
159 lines (119 loc) · 3.02 KB

rules_overview.md

File metadata and controls

159 lines (119 loc) · 3.02 KB

Rules Overview

Foreword

Keywords in this file to indicate requirement levels are as defined in the RFC2119:

"MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL".

These keywords MUST always be capitalized to emphasize their importance.

ClassDocumentationIsRequiredRule

Rule: Every class MUST have a non empty top level documentation.
Error text: Class %s has no/an empty doc comment.
Class: Oneserv\PHPStan\Rules\Classes\ClassDocumentationIsRequiredRule

Invalid ❌

class SomeClass
{
    ...
}

Valid ✅

/**
 * Doc
 */
class SomeClass
{
    ...
}

ClassNameMustBeFirstInClassDocumentationRule

Rule: The top level documentation of a class MUST start with: "Class classname".
Error text: The doc comment of class %s must start with "Class %s".
Class: Oneserv\PHPStan\Rules\Classes\ClassNameMustBeFirstInClassDocumentationRule

Invalid ❌

/**
 * Some text 
 */
class SomeClass
{
    ...
}

Valid ✅

/**
 * Class SomeClass
 */
class SomeClass
{
    ...
}

ClassNameMustBeFirstInConstructMethodDocumentationRuleTest

Rule: The documentation of a __construct method MUST start with: "classname constructor.".
Error text: The doc comment of the __construct method of class %s must start with "%s constructor.".
Class: Oneserv\PHPStan\Rules\Methods\ClassNameMustBeFirstInConstructMethodDocumentationRule

Invalid ❌

class SomeClass
{
    public function __construct() {
    
    }
}

Valid ✅

class SomeClass
{
    /**
     * SomeClass constructor.
     */
    public function __construct() {
    
    }
}

FunctionDocumentationIsRequiredRule

Rule: A documentation MUST be provided for functions.
Error text: Function %s has no/an empty doc comment.
Class: Oneserv\PHPStan\Rules\Functions\FunctionDocumentationIsRequiredRule

Invalid ❌

function someFunction() {

}

Valid ✅

/**
 * Some documentation.
 */
 function someFunction() {
 
 }

MethodDocumentationIsRequiredRule

Rule: A documentation MUST be provided for methods.
Error text: Method %s has no/an empty doc comment.
Class: Oneserv\PHPStan\Rules\Methods\MethodDocumentationIsRequiredRule

Invalid ❌

class SomeClass
{
    function someFunction() {
    
    }
}

Valid ✅

class SomeClass
{
    /**
     * Some documentation.
     */
     function someFunction() {
    
    }
}