|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81082 PDO::getAttribute() requires mixed return type
Submitted: 2021-05-26 05:55 UTC Modified: 2021-05-26 14:55 UTC
From: corey dot taylor dot fl at gmail dot com Assigned:
Status: Closed Package: PDO Core
PHP Version: master-Git-2021-05-26 (Git) OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
47 + 20 = ?
Subscribe to this entry?

 [2021-05-26 05:55 UTC] corey dot taylor dot fl at gmail dot com
With the addition of tentative return types for PDO, we saw this new deprecation show up in generated mock code.

Declaration of Mock_PDO_f5cc810f::getAttribute(int $attribute) should be compatible with PDO::getAttribute(int $attribute): mixed

This requires the use of the new `mixed` return type available in php 8 only.

Isn't the return type `mixed` when omitted and therefore compatible with the declared tentative return type?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-05-26 07:34 UTC]
An no type is considered the same as a hypothetical "mixed|void", no type is not considered covariantly compatible with mixed.

In this case it's necessary to either generate the ": mixed" type, or to generate a "#[ReturnTypeWillChange]" attribute.
 [2021-05-26 14:55 UTC] corey dot taylor dot fl at gmail dot com
-Status: Open +Status: Closed
 [2021-05-26 14:55 UTC] corey dot taylor dot fl at gmail dot com
Ah, I was not aware of the attribute. That will have to be the work around if no return is mixed|void.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Nov 29 16:01:27 2023 UTC