symbiote / silverstripe-phpstan

Extend PHPStan (PHP Static Analysis) to support SilverStripe projects
BSD 3-Clause "New" or "Revised" License
12 stars 13 forks source link

Reflection error when using Silverstripe 4 #25

Open jamsea opened 2 years ago

jamsea commented 2 years ago

I'm trying to get this working with Silverstripe 4 and Visual Studio Code. I went through and followed the guides, made sure to install the shim of phpstan too but I'm still getting this error:

PHP Fatal error:  Declaration of SilbinaryWolf\SilverstripePHPStan\Reflection\MethodClassReflectionExtension::setBroker(PHPStan\Broker\Broker $broker) must be compatible with PHPStan\Reflection\BrokerAwareExtension::setBroker(PHPStan\Broker\Broker $broker): void in /Users/jamsea/git/tinyhouse/vendor/symbiote/silverstripe-phpstan/src/Reflection/MethodClassReflectionExtension.php on line 53

Fatal error: Declaration of SilbinaryWolf\SilverstripePHPStan\Reflection\MethodClassReflectionExtension::setBroker(PHPStan\Broker\Broker $broker) must be compatible with PHPStan\Reflection\BrokerAwareExtension::setBroker(PHPStan\Broker\Broker $broker): void in /Users/jamsea/git/tinyhouse/vendor/symbiote/silverstripe-phpstan/src/Reflection/MethodClassReflectionExtension.php on line 53

# Spawn error
Unexpected token F in JSON at position 1

My phpstan.neon file looks like this:

includes:
    - vendor/symbiote/silverstripe-phpstan/phpstan.neon
parameters:
    level: 5
    paths:
        - app
        - _modules/*/src
        - _modules/*/tests

The require-dev block in composer.json looks like this:

    "require-dev": {
        "squizlabs/php_codesniffer": "3.*",
        "friendsofphp/php-cs-fixer": "*",
        "lekoala/silverstripe-debugbar": "^2.0",
        "symbiote/silverstripe-phpstan": "2.0.0",
        "phpstan/phpstan-shim": "~0.11.0"
    },

Any ideas?

mleutenegger commented 2 years ago

The version of the symbiote/silverstripe-phpstan is incorrect, it should be ^4.0. This is wrongly documented in the readme as it seems.