Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch more "There should be a node type provider" exceptions #55

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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