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

SQLSrv\LastInsertId::getId() is not used anywhere #4512

Closed
morozov opened this issue Feb 27, 2021 · 1 comment · Fixed by #4514
Closed

SQLSrv\LastInsertId::getId() is not used anywhere #4512

morozov opened this issue Feb 27, 2021 · 1 comment · Fixed by #4514

Comments

@morozov
Copy link
Member

morozov commented Feb 27, 2021

Psalm level 2:

ERROR: MissingConstructor - lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php:13:13 - Doctrine\DBAL\Driver\SQLSrv\LastInsertId has an uninitialized property Doctrine\DBAL\Driver\SQLSrv\LastInsertId::$id, but no constructor (see https://psalm.dev/073)
    private $id;

Fixing this issue requires understanding how the value of $id is used by the consumers but it isn't. SQLSrv\Connection::lastInsertId() doesn't use it:

public function lastInsertId($name = null)
{
if ($name !== null) {
$stmt = $this->prepare('SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?');
$stmt->execute([$name]);
} else {
$stmt = $this->query('SELECT @@IDENTITY');
}
if ($stmt instanceof Result) {
return $stmt->fetchOne();
}
return $stmt->fetchColumn();
}

The class and all its usages are internal and can be safely removed in 3.1.0. Removing it in 2.12.x is undesired since not all class usages have been marked as such since 2.0.0.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 27, 2022
@morozov morozov modified the milestones: 4.0.0, 3.1.0 Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant