1

I am trying to check for errors via phpcs and PHPCompatibility standard on a laravel project, here is the command:

phpcs -psvw app --extensions=php --standard=PHPCompatibility --runtime-set testVersion 8.0

The command works fine. However, I am supposed to receive following error but I am not:

Deprecated: Method ReflectionParameter::getClass() is deprecated in somefile.php on line 838

The actual code where PHP8 fails but PHPCS does not inform:

$results[] = is_null($dependency->getClass()) ? $this->resolvePrimitive($dependency) : $this->resolveClass($dependency);

The reason PHPCompatibility standard should tell me about this error is that when I try to run my app in PHP 8 I get above error, however PHPCS with PHPCompatibility does not report above error.

Any idea how can I make PHPCompatibility report above error ?

2
  • When posting a question, please show us a concrete and actual example of your issue instead of telling us to "ignore that and imagine if". Commented Sep 12, 2021 at 8:56
  • 1
    @MagnusEriksson: Here is problematic code: $results[] = is_null($dependency->getClass()) ? $this->resolvePrimitive($dependency) : $this->resolveClass($dependency);. Updated in question too. Commented Sep 12, 2021 at 8:59

1 Answer 1

0

After some investigation it seems the standard is, for whatever reason, not aware of this particular deprecation.

ReflectionParameter::getClass() is not yet removed (even in PHP 8.4), so we don't get a removal error from the sniffer, either.

Even so, I think the sniffer will still always give plenty of warning of a function being fully removed, so there is no huge cause for concern here. Make sure to take note of runtime deprecation errors as well, as part of a complete strategy for preparing for a PHP upgrade.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.