Skip to content

Mark EntityManagerInterface::isOpen() as impure#739

Merged
ondrejmirtes merged 1 commit into
phpstan:2.0.xfrom
denis-korchagin95:entitymanager-isopen-impure
Mar 13, 2026
Merged

Mark EntityManagerInterface::isOpen() as impure#739
ondrejmirtes merged 1 commit into
phpstan:2.0.xfrom
denis-korchagin95:entitymanager-isopen-impure

Conversation

@denis-korchagin95

@denis-korchagin95 denis-korchagin95 commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

The result of isOpen() depends on the internal state of the EntityManager
and may change during execution (for example after an exception during flush()).

This change follows the existing approach used for other Doctrine methods
that depend on mutable internal state.

Fixes #738

Comment thread stubs/EntityManager.stub Outdated
Comment thread stubs/EntityManagerDecorator.stub Outdated
Comment thread stubs/EntityManagerInterface.stub Outdated
Comment thread .gitignore Outdated
@denis-korchagin95
denis-korchagin95 force-pushed the entitymanager-isopen-impure branch from 86e598a to 0f140ec Compare March 13, 2026 12:59
@denis-korchagin95
denis-korchagin95 force-pushed the entitymanager-isopen-impure branch from 0f140ec to c205368 Compare March 13, 2026 13:00
@VincentLanglet
VincentLanglet requested a review from staabm March 13, 2026 13:10
@staabm

staabm commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

since ondrej had the impression this fix might not work, I think we should back it by a test

@ondrejmirtes

Copy link
Copy Markdown
Member

It’s fine, it will work.

@ondrejmirtes

Copy link
Copy Markdown
Member

I was confused in the original issue 😊

@ondrejmirtes

Copy link
Copy Markdown
Member

But more work is necessary here - EntityManagerInterface also has the declaration.

@VincentLanglet

Copy link
Copy Markdown
Contributor

EntityManagerInterface

This file is already updated in the PR.

There is

  • EntityManager
  • EntityManagerDecorator
  • EntityManagerInterface

@ondrejmirtes

Copy link
Copy Markdown
Member

Perfect, thank you. I was checking it out on my phone, wanted to provide as fast feedback as possible.

@ondrejmirtes
ondrejmirtes merged commit 72f4f7a into phpstan:2.0.x Mar 13, 2026
50 of 51 checks passed
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.

PHPStan assumes deterministic result for EntityManagerInterface::isOpen() within same scope

4 participants