DowngradeReflectionMethodHasPrototypeRector
Downgrade ReflectionMethod::hasPrototype() by emulating it with getPrototype()
class SomeClass
{
public function run(ReflectionMethod $reflectionMethod): bool
{
- return $reflectionMethod->hasPrototype();
+ return (function (\ReflectionMethod $reflectionMethod2): bool {
+ try {
+ $reflectionMethod2->getPrototype();
+ return true;
+ } catch (\ReflectionException) {
+ return false;
+ }
+ })($reflectionMethod);
}
}
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\DowngradePhp82\Rector\MethodCall\DowngradeReflectionMethodHasPrototypeRector;
return RectorConfig::configure()
->withRules([
DowngradeReflectionMethodHasPrototypeRector::class,
]);