Skip to content

Fix parameter type hints in EntityManager methods#6

Open
mhucik wants to merge 7 commits intomasterfrom
fix/php-84-compatibility
Open

Fix parameter type hints in EntityManager methods#6
mhucik wants to merge 7 commits intomasterfrom
fix/php-84-compatibility

Conversation

@mhucik
Copy link

@mhucik mhucik commented Feb 7, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 7, 2026 22:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to adjust method parameter typing/optionality in Kdyby\Doctrine\EntityManager to better reflect intended usage and improve type hints.

Changes:

  • Modifies EntityManager::flush() signature (currently making the parameter mandatory).
  • Modifies EntityManager::create() signature to use a nullable EventManager type (currently making the parameter mandatory and omitting a default).
  • Changes the lazy-initialization check in safePersist() (currently introducing a syntax error).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

* @return EntityManager
*/
public function flush($entity = null)
public function flush($entity )
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

flush() now requires an argument ($entity) even though the docblock and Doctrine API allow calling flush() with no args. This is a backwards-incompatible change and will break callers that do $em->flush(). Restore the default value (e.g., $entity = NULL) so the parameter remains optional; you can still keep/improve type information via PHPDoc.

Suggested change
public function flush($entity )
public function flush($entity = NULL)

Copilot uses AI. Check for mistakes.
public function safePersist($entity)
{
if ($this->nonLockingUniqueInserter === NULL) {
if ($this->nonLockingUniqueInserter ==) {
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

This if condition is a PHP parse error (== without a right-hand operand). It should compare $this->nonLockingUniqueInserter against NULL (and ideally use strict comparison) so the lazy initialization works as intended.

Suggested change
if ($this->nonLockingUniqueInserter ==) {
if ($this->nonLockingUniqueInserter === null) {

Copilot uses AI. Check for mistakes.
Comment on lines 224 to 225
public static function create($conn, Doctrine\ORM\Configuration $config, ?Doctrine\Common\EventManager $eventManager )
{
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

create() previously allowed omitting $eventManager (default NULL), but it is now a required parameter and the signature is missing a default. This is backwards-incompatible and also inconsistent with the implementation which treats it as optional ($eventManager ?: new ...). Add a default = NULL (and keep ?Doctrine\\Common\\EventManager if you want nullability). Also consider updating the PHPDoc to reflect that it can be null.

Copilot uses AI. Check for mistakes.
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.

2 participants