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 template param for SplDoublyLinkedList #8579

Merged
merged 1 commit into from Oct 15, 2022
Merged

Conversation

ADmad
Copy link
Contributor

@ADmad ADmad commented Oct 13, 2022

It's key is always an integer.

@ADmad ADmad force-pushed the patch-2 branch 2 times, most recently from ee46087 to 142c9a4 Compare October 13, 2022 13:36
@orklah
Copy link
Collaborator

orklah commented Oct 13, 2022

Hey!

There's a few failures on CI because you're still using TKey in methods.

But aside from that, do you have any control over the keys in a SplDoublyLinkedList?

For example, can I decide to have one with only negative keys? Because if I can, then you don't want to remove TKey altogether, you just want to have an upper bound (like @template Tkey as int) instead of removing it altogether. Because if you leave it, someone could do a SplDoublyLinkedList<int<-5, 5>, string> for example

@ADmad ADmad force-pushed the patch-2 branch 2 times, most recently from 8d7eb29 to c3ff3ed Compare October 14, 2022 01:26
@ADmad
Copy link
Contributor Author

ADmad commented Oct 14, 2022

There's a few failures on CI because you're still using TKey in methods.

Fixed.

But aside from that, do you have any control over the keys in a SplDoublyLinkedList?

Nope, it's always sequential integer starting at 0. Doing (new SplDoublyLinkedList())->add(1, 'foo') for e.g. will throw a OutOfBoundsException.

phpstan's stub too uses only one template variable https://github.com/phpstan/phpstan-src/blob/fe198fb3a4f3e2791f77e7671e3e7a6e7fd114ad/stubs/spl.stub#L6.

@orklah
Copy link
Collaborator

orklah commented Oct 14, 2022

Ok :)

It could be interesting to document int<0, max> then to describe that negative int can't be returned.

Could you target master? It will prevent people having to change their templates on a minor version

@ADmad ADmad changed the base branch from 4.x to master October 14, 2022 06:23
It's key is always an integer.
@ADmad
Copy link
Contributor Author

ADmad commented Oct 14, 2022

Re-targeted to master.

@orklah orklah added the release:fix The PR will be included in 'Fixes' section of the release notes label Oct 15, 2022
@orklah
Copy link
Collaborator

orklah commented Oct 15, 2022

Thanks!

@orklah orklah merged commit 61ef140 into vimeo:master Oct 15, 2022
@ADmad ADmad deleted the patch-2 branch October 15, 2022 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix The PR will be included in 'Fixes' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants