Roave/BetterReflection

ReflectionMethod Adapter: Calling setAccessible() shouldn't be needed for non-public methods as of PHP 8.1

ondrejmirtes opened this issue · 1 comments

https://www.php.net/manual/en/reflectionmethod.setaccessible.php

Note: As of PHP 8.1.0, calling this method has no effect; all methods are invokable by default.

But the adapter here still requires it before calling invoke():

if (! $this->isAccessible()) {
throw new CoreReflectionException('Method not accessible');
}

The options IMHO are:

  1. Remove the isAccessible() check and be done with it.
  2. Require it only when running on PHP 8 but not on PHP 8.1+.
  3. Remove the isAccessible() check and set PHP 8.1 as a new minimum version.

Originally reported: phpstan/phpstan#7429

We can just drop the check IMO.