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

Fix language server first-class callable crashes #9336

Merged
merged 2 commits into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -471,6 +471,7 @@ private static function handleNamedFunction(
= $function_call_info->is_stubbed || $function_call_info->in_call_map || $namespaced_function_exists;

if ($function_call_info->function_exists
&& !$stmt->isFirstClassCallable()
&& $codebase->store_node_types
&& !$context->collect_initializations
&& !$context->collect_mutations
Expand Down
Expand Up @@ -95,6 +95,7 @@ public static function analyze(
}

if ($codebase->store_node_types
&& !$stmt->isFirstClassCallable()
&& !$context->collect_initializations
&& !$context->collect_mutations
) {
Expand Down Expand Up @@ -226,6 +227,7 @@ public static function analyze(
}

if ($codebase->store_node_types
&& !$stmt->isFirstClassCallable()
&& !$context->collect_initializations
&& !$context->collect_mutations
) {
Expand Down
Expand Up @@ -322,6 +322,7 @@ private static function handleNamedCall(
$cased_method_id = $fq_class_name . '::' . $stmt_name->name;

if ($codebase->store_node_types
&& !$stmt->isFirstClassCallable()
&& !$context->collect_initializations
&& !$context->collect_mutations
) {
Expand Down
1 change: 1 addition & 0 deletions tests/Traits/InvalidCodeAnalysisTestTrait.php
Expand Up @@ -73,6 +73,7 @@ public function testInvalidCode(
$this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/');

$codebase = $this->project_analyzer->getCodebase();
$codebase->enterServerMode();
$codebase->config->visitPreloadedStubFiles($codebase);

$this->addFile($file_path, $code);
Expand Down
1 change: 1 addition & 0 deletions tests/Traits/ValidCodeAnalysisTestTrait.php
Expand Up @@ -68,6 +68,7 @@ public function testValidCode(
$this->project_analyzer->setPhpVersion($php_version, 'tests');

$codebase = $this->project_analyzer->getCodebase();
$codebase->enterServerMode();
$codebase->config->visitPreloadedStubFiles($codebase);

$file_path = self::$src_dir_path . 'somefile.php';
Expand Down