Download the PHP package shipmonk/phpstan-rules without Composer

On this page you can find all versions of the php package shipmonk/phpstan-rules. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phpstan-rules

ShipMonk PHPStan strict rules

About 40 super-strict rules we found useful in ShipMonk. We tend to have PHPStan set up as strict as possible, but that still was not strict enough for us. This set of rules should fill the missing gaps we found.

If you find some rules opinionated, you can easily disable them.

Installation:

Use official extension-installer or enable all rules manually by:

Configuration:

You can easily disable or reconfigure any rule, for example:

Or you can disable all rules and enable only those you want:

When you try to configure any default array, PHPStan config is merged by default, so if you want to enforce only your values and not to include our defaults, use exclamation mark:

Few rules are enabled, but do nothing unless configured, those are marked with *.

Rules:

allowComparingOnlyComparableTypes

backedEnumGenerics *

classSuffixNaming *

enforceClosureParamNativeTypehint

enforceEnumMatchRule

Which someone might fix as:

Or even worse as:

We believe that this leads to more error-prone code since adding new enum case may not fail in tests. Very good approach within similar cases is to use match construct so that (ideally with forbidMatchDefaultArmForEnums enabled) phpstan fails once new case is added. PHPStan even adds tip about match in those cases since 1.10.11. For those reasons, this rule detects any always-true/false enum comparisons and forces you to rewrite it to match ($enum).

Since PHPStan 1.10.34, the behaviour is much better as it does not report error on the last elseif in case that it is followed by else with thrown exception. Such case raises exception in your tests if you add new enum case, but it is still silent in PHPStan. This leaves space for error being deployed to production. So we still believe this rule makes sense even in latest PHPStan.

enforceIteratorToArrayPreserveKeys

enforceListReturn

enforceNativeReturnTypehint

enforceReadonlyPublicProperty

forbidArithmeticOperationOnNonNumber

forbidCast

forbidCheckedExceptionInCallable

forbidCheckedExceptionInYieldingMethod

forbidCustomFunctions *

forbidEnumInFunctionArguments

forbidFetchOnMixed

forbidIdenticalClassComparison

forbidIncrementDecrementOnNonInteger

forbidMatchDefaultArmForEnums

forbidMethodCallOnMixed

forbidNotNormalizedType

forbidNullInAssignOperations

forbidNullInBinaryOperations

forbidNullInInterpolatedString

forbidPhpDocNullabilityMismatchWithNativeTypehint

forbidProtectedEnumMethod

forbidReturnValueInYieldingMethod

forbidUnsafeArrayKey

forbidVariableTypeOverwriting

forbidUnsetClassField

forbidUselessNullableReturn

forbidUnusedException

forbidUnusedMatchResult

requirePreviousExceptionPass

uselessPrivatePropertyDefaultValue:

Native PHPStan extra strictness

Some strict behaviour in PHPStan is not enabled by default, consider enabling extra strictness even there:

Contributing


All versions of phpstan-rules with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
phpstan/phpstan Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package shipmonk/phpstan-rules contains the following files

Loading the files please wait ....