php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81192 "Declaration should be compatible with" gives incorrect line number with traits
Submitted: 2021-06-22 21:44 UTC Modified: 2021-06-29 01:53 UTC
From: iggyvolz at gmail dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 8.1.0alpha1 OS: Ubuntu 20.04.2 LTS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: iggyvolz at gmail dot com
New email:
PHP Version: OS:

 

 [2021-06-22 21:44 UTC] iggyvolz at gmail dot com
Description:
------------
When encountering a "Declaration of x must be compatible with y" error with a function used by a trait, the file number references the class while the line number references the trait.

Additionally tested this on PHP 7.4 and the error persists.

Test script:
---------------
https://gist.github.com/iggyvolz/c1d34e3e0997d9c0b2d9d37512d872ff

Expected result:
----------------
Fatal error: Declaration of myTrait::foo(): string must be compatible with a::foo(): int in .../b.php on line 5

Or:

Fatal error: Declaration of myTrait::foo(): string must be compatible with a::foo(): int in .../myTrait.php on line 19

Or:
Fatal error: Declaration of myTrait::foo(): string must be compatible with a::foo(): int in .../b.php on line 5, from trait on .../myTrait.php on line 19

Actual result:
--------------
Fatal error: Declaration of myTrait::foo(): string must be compatible with a::foo(): int in .../b.php on line 19

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-29 01:53 UTC] twosee@php.net
-Status: Open +Status: Verified
 [2021-08-12 12:36 UTC] git@php.net
Automatic comment on behalf of nikic
Revision: https://github.com/php/php-src/commit/1c6df2dffda301f6c458bd291eb2f4bf12906dd9
Log: Fixed bug #81192
 [2021-08-12 12:36 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC