PHPStan Rules for Rector developers

Overview

Rector PHPStan Rules

PHPStan rules for Rector and projects that maintain Rector rulesets.

Install

composer require rector/phpstan-rules --dev

Do you use PHPStan extension installer? The config is added automatically.

If not, add it to phpstan.neon:

includes:
    - vendor/rector/phpstan-rules/config/config.neon
Comments
  • Fix CI build

    Fix CI build

    Current test build got the following error:

    There were 43 errors:
    
    1) Rector\PHPStanRules\Tests\Rule\CallConfigureWithArrayRule\CallConfigureWithArrayRuleTest::testRule with data set #0 ('/home/runner/work/phpstan-rul...ig.php', array())
    
    _PHPStan_76800bfb5\Nette\DI\ServiceCreationException: Service of type Rector\PHPStanRules\Rule\ForbiddenComplexArrayConfigInSetRule: Service of type Symplify\PHPStanRules\Symfony\NodeAnalyzer\SymfonyPhpConfigClosureAnalyzer needed by $symfonyPhpConfigClosureAnalyzer in __construct() not found. Did you add it to configuration file?
    

    This PR patch it.

    opened by samsonasik 5
  • Fix CI: remove ForbiddenComplexFuncCallRule

    Fix CI: remove ForbiddenComplexFuncCallRule

    symplify 10.1.3 seems removed ForbiddenComplexFuncCallRule, that cause error :

    _PHPStan_ae8980142\Nette\DI\ServiceCreationException: Service (Symplify\PHPStanRules\Rules\ForbiddenComplexFuncCallRule::__construct()): Class 'Symplify\PHPStanRules\Rules\ForbiddenComplexFuncCallRule' not found.
    

    in CI, this PR try to solve it.

    opened by samsonasik 4
  • Fix TypeAndNameAnalyzer service not found

    Fix TypeAndNameAnalyzer service not found

    Ref https://github.com/rectorphp/rector-src/pull/950#issuecomment-932791658 due new symplify release which remove the service https://github.com/symplify/symplify/compare/9.4.69...9.4.70#diff-82e0501b5cae5f14a934c7179e008e789e5160e4cadca9bc75e80d7919714edc

    opened by samsonasik 2
  • [PHPStanRules] Allow native ReflectionFunction on PreferredClassRule

    [PHPStanRules] Allow native ReflectionFunction on PreferredClassRule

    It can be used for native reflection usage, ref

    https://github.com/rectorphp/rector-src/pull/466/files#diff-08a6fd7d71db5a18ed50027eaf1bc3ab26eb70e6ab0a6349a0885b4fb767e35dR39-R43

    as PHPStan's NativeParameterReflection cannot get default value.

    opened by samsonasik 2
  • Configure ForbiddenFuncCallRule to suggest alternatives in errors

    Configure ForbiddenFuncCallRule to suggest alternatives in errors

    use more contributor friendly errors messages

    before: Function "preg_replace()" cannot be used/left in the code after: Function "preg_replace()" cannot be used/left in the code: use Strings::replace() instead`

    opened by staabm 1
Rector upgrades rules for Nette

Rector Rules for Nette See available Nette rules Install composer require rector/rector-nette Use Sets To add a set to your config, use Rector\Nette\S

RectorPHP 21 Nov 7, 2022
Rector rules for Nette to Symfony migration

Rector Nette to Symfony Do you need to migrate from Nette to Symfony? You can ↓ How we Migrated 54 357-lines Application from Nette to Symfony in 2 Pe

Rector 8 May 30, 2022
Rector upgrades rules for Symfony Framework

Rector Rules for Symfony See available Symfony rules Install This package is already part of rector/rector package, so it works out of the box. All yo

Rector 107 Dec 31, 2022
Rector upgrades rules for Laravel

Rector Rules for Laravel See available Laravel rules Install This package is already part of rector/rector package, so it works out of the box. All yo

Rector 185 Dec 30, 2022
phpcs-security-audit is a set of PHP_CodeSniffer rules that finds vulnerabilities and weaknesses related to security in PHP code

phpcs-security-audit v3 About phpcs-security-audit is a set of PHP_CodeSniffer rules that finds vulnerabilities and weaknesses related to security in

Floe design + technologies 655 Jan 3, 2023
Phpstan-dba - database handling related class reflection extension for PHPStan & framework-specific rules

database handling class reflection extension for PHPStan This extension provides following features: PDO->query knows the array shape of the returned

Markus Staab 175 Dec 29, 2022
Rector upgrades rules for CakePHP

Rector Rules for CakePHP See available CakePHP rules Install composer require rector/rector-cakephp Use Sets To add a set to your config, use Rector\C

RectorPHP 19 Oct 27, 2022
Rector upgrades rules for Nette

Rector Rules for Nette See available Nette rules Install composer require rector/rector-nette Use Sets To add a set to your config, use Rector\Nette\S

RectorPHP 21 Nov 7, 2022
Rector upgrades rules for PHPUnit

Rector Rules for PHPUnit See available PHPUnit rules Install composer require rector/rector-phpunit Use Sets To add a set to your config, use Rector\P

RectorPHP 34 Dec 27, 2022
Rector rules for Nette to Symfony migration

Rector Nette to Symfony Do you need to migrate from Nette to Symfony? You can ↓ How we Migrated 54 357-lines Application from Nette to Symfony in 2 Pe

Rector 8 May 30, 2022
Rector upgrades rules for Doctrine

Rector Rules for Doctrine See available Doctrine rules Install This package is already part of rector/rector package, so it works out of the box.

Rector 37 Nov 7, 2022
Rector upgrades rules for Symfony Framework

Rector Rules for Symfony See available Symfony rules Install This package is already part of rector/rector package, so it works out of the box. All yo

Rector 107 Dec 31, 2022
Rector upgrades rules for Laravel

Rector Rules for Laravel See available Laravel rules Install This package is already part of rector/rector package, so it works out of the box. All yo

Rector 185 Dec 30, 2022
Rector Rules for BEAR.Sunday

Rector Rules for BEAR.Sunday The rector/rector rules for BEAR.Sunday.

BEAR.Sunday 2 Mar 30, 2022
Custom PHPStan rules

phpstan-rules Provides additional rules for phpstan/phpstan. Installation Run $ composer require --dev alister/phpstan-rules Usage All of the rules pr

Alister Bulman 1 Nov 4, 2021
PHPStan Symfony Framework extensions and rules

PHPStan Symfony Framework extensions and rules PHPStan This extension provides following features: Provides correct return type for ContainerInterface

PHPStan 564 Dec 30, 2022
PHPStan PHPUnit extensions and rules

PHPStan PHPUnit extensions and rules PHPStan PHPUnit This extension provides following features: createMock(), getMockForAbstractClass() and getMockFr

PHPStan 359 Dec 28, 2022
PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.

Rules for detecting usage of deprecated classes, methods, properties, constants and traits. PHPStan Installation To use this extension, require it in

PHPStan 247 Jan 2, 2023
Various PHPStan rules we found useful in ShipMonk.

ShipMonk PHPStan rules Various rules we found useful in ShipMonk. You may found some of them opinionated, so we recommend picking only those fitting y

ShipMonk R&D 31 Dec 22, 2022
Repository containing all the PHPStan rules from the book "Recipes for Decoupling"

PHPStan rules from the book "Recipes for Decoupling" by Matthias Noback In the book "Recipes for Decoupling" we discuss how to decouple from web and C

Matthias Noback 19 Sep 21, 2022