mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-31 00:10:51 +00:00
[Reflection] Avoid error Call to a member function getType() on null on ReflectionResolver (#334)
This commit is contained in:
parent
9bd39bd18c
commit
8cdd122c87
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Tests\Php71\Rector\FuncCall\RemoveExtraParametersRector\Fixture;
|
||||
|
||||
final class OnCannotGetScopeOfFunctionCall
|
||||
{
|
||||
public static function streamSupports(string $function, $ret, $resource): bool
|
||||
{
|
||||
define('ENVIRONMENT', 'testing');
|
||||
|
||||
if (ENVIRONMENT === 'testing') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return function_exists($function, 'abc') && @$function($resource);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Tests\Php71\Rector\FuncCall\RemoveExtraParametersRector\Fixture;
|
||||
|
||||
final class OnCannotGetScopeOfFunctionCall
|
||||
{
|
||||
public static function streamSupports(string $function, $ret, $resource): bool
|
||||
{
|
||||
define('ENVIRONMENT', 'testing');
|
||||
|
||||
if (ENVIRONMENT === 'testing') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return function_exists($function) && @$function($resource);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -204,6 +204,10 @@ final class ReflectionResolver
|
|||
return null;
|
||||
}
|
||||
|
||||
if (! $scope instanceof Scope) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// fallback to callable
|
||||
$funcCallNameType = $scope->getType($funcCall->name);
|
||||
return $this->typeToCallReflectionResolverRegistry->resolve($funcCallNameType, $scope);
|
||||
|
|
Loading…
Reference in New Issue
Block a user