Skip to content

fix: mark Ds\Queue::pop() as impure#2550

Merged
ondrejmirtes merged 1 commit intophpstan:1.10.xfrom
simPod:impure
Jul 25, 2023
Merged

fix: mark Ds\Queue::pop() as impure#2550
ondrejmirtes merged 1 commit intophpstan:1.10.xfrom
simPod:impure

Conversation

@simPod
Copy link
Copy Markdown
Contributor

@simPod simPod commented Jul 25, 2023

Resolves #9682

@phpstan-bot
Copy link
Copy Markdown
Collaborator

You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x.

@simPod simPod changed the base branch from 1.11.x to 1.10.x July 25, 2023 10:05
@ondrejmirtes
Copy link
Copy Markdown
Member

Can you please check other similar methods that might have the same problem? The key is that the method returns a value AND changes the underlying collection.

Such an example: Stack::pop()

If it does not return a value (it's void) then such a method is already understood as impure by PHPStan.

@simPod
Copy link
Copy Markdown
Contributor Author

simPod commented Jul 25, 2023

I tried to mark all eligible I know of.

@ondrejmirtes
Copy link
Copy Markdown
Member

I don't think that first/last and peek are impure.

@simPod
Copy link
Copy Markdown
Contributor Author

simPod commented Jul 25, 2023

ok i missed "changes" in The key is that the method returns a value AND changes the underlying collection.

@ondrejmirtes ondrejmirtes merged commit 25f390f into phpstan:1.10.x Jul 25, 2023
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Asserting instance of first item popped from Queue<I> makes phpstan assume following popped items are of the same type

3 participants