phpstan / phpstan-strict-rules

Extra strict and opinionated rules for PHPStan
MIT License
592 stars 46 forks source link

Disable all rules does not work #201

Closed mairo744 closed 1 year ago

mairo744 commented 1 year ago

Hi,

I tried to disable all rules but did not work for every rule. It looks like some rules are not configurable.

phpstan.neon.dist:

includes:
    - phpstan-baseline.neon

parameters:
    level: max
    paths:
        - packages
    strictRules:
        allRules: false

Result:

...
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  Line   ObjectType.php
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  21     Parameter #1 $value (string|Object|null) of method ObjectType::convertToDatabaseValue() should be contravariant with
         parameter $value (mixed) of method Doctrine\DBAL\Types\Type::convertToDatabaseValue()
  31     Parameter #1 $value (string) of method ObjectType::convertToPHPValue() should be contravariant with parameter $value (mixed) of method
         Doctrine\DBAL\Types\Type::convertToPHPValue()
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 [ERROR] Found 333 errors

My goal was disable this rule should be contravariant with parameter $value (mixed) ... because it is doctrine custom type which extends general string type Doctrine\DBAL\Types\StringType. Unfortunately doctrine string type use mixed type but I want to be more strict.

<?php

namespace Doctrine\DBAL\Types;

use Doctrine\DBAL\Platforms\AbstractPlatform;

/**
 * Type that maps an SQL VARCHAR to a PHP string.
 */
class StringType extends Type
{
    /**
     * Gets the SQL declaration snippet for a column of this type.
     *
     * @param mixed[]          $column   The column definition
     * @param AbstractPlatform $platform The currently used database platform.
     *
     * @return string
     */
    public function getSQLDeclaration(array $column, AbstractPlatform $platform)
    {
        return $platform->getStringTypeDeclarationSQL($column);
    }

    public function getName()
    {
        return Types::STRING;
    }
}
ondrejmirtes commented 1 year ago

Some things here in rules.neon aren't about new custom rules, but also about changing default options from PHPStan core. Looking at https://github.com/phpstan/phpstan-strict-rules/blob/1.5.x/rules.neon they're at the beginning in the parameters section.

And they're documented on the website: https://phpstan.org/config-reference#stricter-analysis

I think the option you want to turn off is reportMaybesInMethodSignatures.

mairo744 commented 1 year ago

Wow, this was fast response.

Some things here in rules.neon aren't about new custom rules, but also about changing default options from PHPStan core.

Thank you, I do not know about that.

I think the option you want to turn off is reportMaybesInMethodSignatures.

Yeah, it is reportMaybesInMethodSignatures, thanks.

github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.