Skip to content

Commit

Permalink
Merge pull request #55 from anomiex/fix/missing-node-provider
Browse files Browse the repository at this point in the history
Catch more "There should be a node type provider" exceptions
  • Loading branch information
kkmuffme authored Feb 29, 2024
2 parents 8fd59d6 + 7da3130 commit 0130a4e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,11 @@ public static function afterEveryFunctionCallAnalysis( AfterEveryFunctionCallAna

if ( ! $call_args[0]->value instanceof String_ ) {
$statements_source = $event->getStatementsSource();
$union = $statements_source->getNodeTypeProvider()->getType( $call_args[0]->value );
try {
$union = $statements_source->getNodeTypeProvider()->getType( $call_args[0]->value );
} catch (UnexpectedValueException $e) {
$union = null;
}
if ( ! $union ) {
$union = static::getTypeFromArg( $call_args[0]->value, $event->getContext(), $statements_source );
}
Expand Down Expand Up @@ -821,7 +825,11 @@ public static function getFunctionParams( FunctionParamsProviderEvent $event ) :
}

if ( ! $call_args[0]->value instanceof String_ ) {
$union = $statements_source->getNodeTypeProvider()->getType( $call_args[0]->value );
try {
$union = $statements_source->getNodeTypeProvider()->getType( $call_args[0]->value );
} catch (UnexpectedValueException $e) {
$union = null;
}
if ( ! $union ) {
$union = static::getTypeFromArg( $call_args[0]->value, $event->getContext(), $statements_source );
}
Expand Down Expand Up @@ -1112,7 +1120,11 @@ public static function getFunctionReturnType( FunctionReturnTypeProviderEvent $e
// only apply_filters left to handle
if ( ! $call_args[0]->value instanceof String_ ) {
$statements_source = $event->getStatementsSource();
$union = $statements_source->getNodeTypeProvider()->getType( $call_args[0]->value );
try {
$union = $statements_source->getNodeTypeProvider()->getType( $call_args[0]->value );
} catch (UnexpectedValueException $e) {
$union = null;
}
if ( ! $union ) {
$union = static::getTypeFromArg( $call_args[0]->value, $event->getContext(), $statements_source );
}
Expand Down

0 comments on commit 0130a4e

Please sign in to comment.