Skip to content

[CLEANUP] Improve type annotations in LineName #1198

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

Merged
merged 1 commit into from
Mar 19, 2025
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
5 changes: 4 additions & 1 deletion src/Value/LineName.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class LineName extends ValueList
{
/**
* @param array<int, Value|string> $components
* @param array<Value|string> $components
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this weaken the type specification, also allowing strings as array keys?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it does. As far as I can see, the array keys are not used, and hence it doesn't matter if string or int array keys are passed in.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

* @param int<0, max> $lineNumber
*/
public function __construct(array $components = [], int $lineNumber = 0)
Expand Down Expand Up @@ -49,6 +49,9 @@ public static function parse(ParserState $parserState): LineName
return new LineName($names, $parserState->currentLine());
}

/**
* @return non-empty-string
*/
public function render(OutputFormat $outputFormat): string
{
return '[' . parent::render(OutputFormat::createCompact()) . ']';
Expand Down