php.net |  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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: corey dot taylor dot fl at gmail dot com
New email:
PHP Version: OS:

 

 [2021-05-26 05:55 UTC] corey dot taylor dot fl at gmail dot com
Description:
------------
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? 

https://3v4l.org/sVfS7/rfc#git.master


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-05-26 07:34 UTC] nikic@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC