file_provider->getContents($statements_analyzer->getFilePath()); // Find opening paren $first_argument = $stmt->args[0] ?? null; $first_argument_character = $first_argument !== null ? $first_argument->getStartFilePos() : $stmt->getEndFilePos(); $method_name_and_first_paren_source_code_length = $first_argument_character - $stmt->getStartFilePos(); // FIXME: There are weird ::__construct calls in the AST for `extends` if ($method_name_and_first_paren_source_code_length <= 0) { return; } $method_name_and_first_paren_source_code = substr( $file_content, $stmt->getStartFilePos(), $method_name_and_first_paren_source_code_length ); $method_name_and_first_paren_tokens = token_get_all('getStartFilePos()) { return; } // Record ranges of the source code that need to be tokenized to find commas /** @var array{0: int, 1: int}[] $ranges */ $ranges = []; // Add range between opening paren and first argument $first_argument = $stmt->args[0] ?? null; $first_argument_starting_position = $first_argument !== null ? $first_argument->getStartFilePos() : $stmt->getEndFilePos(); $first_range_starting_position = $opening_paren_position + 1; if ($first_range_starting_position !== $first_argument_starting_position) { $ranges[] = [$first_range_starting_position, $first_argument_starting_position]; } // Add range between arguments foreach ($stmt->args as $i => $argument) { $range_start = $argument->getEndFilePos() + 1; $next_argument = $stmt->args[$i + 1] ?? null; $range_end = $next_argument !== null ? $next_argument->getStartFilePos() : $stmt->getEndFilePos(); if ($range_start !== $range_end) { $ranges[] = [$range_start, $range_end]; } } $commas = []; foreach ($ranges as $range) { $position = $range[0]; $length = $range[1] - $position; if ($length > 0) { $range_source_code = substr($file_content, $position, $length); $range_tokens = token_get_all('analyzer->addNodeArgument( $statements_analyzer->getFilePath(), $argument_start_position, $comma, $function_reference, $argument_number ); ++$argument_number; $argument_start_position = $comma + 1; } $codebase->analyzer->addNodeArgument( $statements_analyzer->getFilePath(), $argument_start_position, $stmt->getEndFilePos(), $function_reference, $argument_number ); } }