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

Conversation

oliverklee
Copy link
Collaborator

No description provided.

@coveralls
Copy link

coveralls commented Mar 19, 2025

Coverage Status

coverage: 51.499%. remained the same
when pulling a054bb0 on task/types/linename
into 3572062 on main.

@oliverklee oliverklee force-pushed the task/types/linename branch from d3fd1c5 to a054bb0 Compare March 19, 2025 22:15
Copy link
Collaborator

@JakeQZ JakeQZ left a comment

Choose a reason for hiding this comment

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

I have a query about array<Type>. I had assumed that they keys would default to array-key, but can't find anything in the PHPStan docs.

@@ -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.

@oliverklee
Copy link
Collaborator Author

I had assumed that they keys would default to array-key

Yes, that's my assumption, too. (array<string|int, Thing>, array<Thing>, Thing[] and array<array-key, Thing> are technically equivalent AFAFIK.)

@@ -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.

OK.

@JakeQZ JakeQZ merged commit 43b8afa into main Mar 19, 2025
21 checks passed
@JakeQZ JakeQZ deleted the task/types/linename branch March 19, 2025 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants