👓 Provides additional rules for phpstan/phpstan.
Switch branches/tags
Nothing to show
Clone or download
localheinz Merge pull request #61 from localheinz/feature/phpunit
Enhancement: Update phpunit/phpunit
Latest commit 255a918 Dec 9, 2018

README.md

phpstan-rules

Build Status codecov Latest Stable Version Total Downloads

Provides additional rules for phpstan/phpstan.

Installation

Run

$ composer require --dev localheinz/phpstan-rules

Usage

All of the rules provided (and used) by this library are included in rules.neon. The easiest way to use these rules in your project is to include rules.neon in your phpstan.neon:

includes:
	- vendor/localheinz/phpstan-rules/rules.neon

💡 You probably want to use these rules on top of the rules provided by:

Rules

This package provides the following rules for use with phpstan/phpstan:

Classes

Classes\FinalRule

This rule reports an error when a non-anonymous class is not final.

Disallowing abstract classes

This rule allows to declare abstract classes. If you want to disallow abstract classes, you can set the allowAbstractClasses parameter to false:

parameters: 
	allowAbstractClasses: false
Excluding classes from inspection

If you want to exclude classes from being inspected by this rule, you can set the classesNotRequiredToBeAbstractOrFinal to a list of class names:

parameters: 
	classesNotRequiredToBeAbstractOrFinal:
		- Foo\Bar\NeitherAbstractNorFinal
		- Bar\Baz\NeitherAbstractNorFinal

Closures

Closures\NoNullableReturnTypeDeclarationRule

This rule reports an error when a closure uses a nullable return type declaration.

Closures\NoParameterWithNullableTypeDeclarationRule

This rule reports an error when a closure has a parameter with a nullable type declaration.

Closures\NoParameterWithNullDefaultValueRule

This rule reports an error when a closure has a parameter with null as default value.

Functions

Functions\NoNullableReturnTypeDeclarationRule

This rule reports an error when a function uses a nullable return type declaration.

Functions\NoParameterWithNullableTypeDeclarationRule

This rule reports an error when a function has a parameter with a nullable type declaration.

Functions\NoParameterWithNullDefaultValueRule

This rule reports an error when a function has a parameter with null as default value.

Methods

Methods\NoConstructorParameterWithDefaultValueRule

This rule reports an error when a constructor declared in

  • an anonymous class
  • a class

has a default value.

Methods\NoNullableReturnTypeDeclarationRule

This rule reports an error when a method declared in

  • an anonymous class
  • a class
  • an interface

uses a nullable return type declaration.

Methods\NoParameterWithNullableTypeDeclarationRule

This rule reports an error when a method declared in

  • an anonymous class
  • a class
  • an interface

has a parameter with a nullable type declaration.

Methods\NoParameterWithNullDefaultValueRule

This rule reports an error when a method declared in

  • an anonymous class
  • a class
  • an interface

has a parameter with null as default value.

Changelog

Please have a look at CHANGELOG.md.

Contributing

Please have a look at CONTRIBUTING.md.

Code of Conduct

Please have a look at CODE_OF_CONDUCT.md.

License

This package is licensed using the MIT License.