spaze / phpstan-disallowed-calls

PHPStan rules to detect disallowed method & function calls, constant, namespace, attribute & superglobal usages
MIT License
255 stars 17 forks source link

allowExceptParams fails on v2.11.3 when concatenation with object param #166

Closed simivar closed 1 year ago

simivar commented 1 year ago

I had this PHPStan rule specified in my configuration:

parameters:
    disallowedFunctionCalls:
        -
            function: 'env()'
            allowIn:
                - 'src/AllowedIn.php'
            allowExceptParams:
                -
                    position: 1
                    name: 'key'
                    value: 'SOME_ENV'

and it worked perfectly fine until upgrading to version v2.11.3. In the version v2.11.3 and v2.11.4 code snippet from below fails even though it shouldn't:

<?php

class WithProperty {
    /** @var string */
    public string $property;
}

class Test {
    public function __construct() {
        $withProperty = new WithProperty();
        env($withProperty->property . '_OTHER');
    }
}
spaze commented 1 year ago

Hey @simivar, thanks for the issue and sorry for the trouble. That was indeed a regression introduced in 2.11.3 (in #159). I've fixed it now and released it in 2.11.5. Hope that helps :-)