Req #79768 [NEW]: LSP BC break in 8.0.0 issues no warning in 7.x
From: eric at ericstern dot com
Operating system: n/a
PHP version: 7.4.7
Package: *General Issues
Bug Type: Feature/Change Request
Bug description:LSP BC break in 8.0.0 issues no warning in 7.x
Description:
------------
Both abstract trait method validation and promotion of warnings to fatal
errors for LSP violation have been implemented in PHP 8. Yay!
Unfortunately due to the timing of these two changes, it can result in a
new fatal error where previously there was no warning/notice issued at
all. This can catch people upgrading by surprise, and is rather
difficult to track down in any sort of automated way.
https://www.reddit.com/r/PHP/comments/hj61po/php_8_class_inheritance_method_signature/fwmc93e/
and https://php.watch/versions/8.0/lsp-errors#trait
provide more context
and examples.
Test script:
---------------
trait MyTrait {
abstract protected function foo(): string;
}
class MyClass {
use MyTrait;
protected function foo()
{
}
}
Expected result:
----------------
Some sort of warning/notice/etc for abstract trait validation is
back-ported from 8.0.0, so that the (expected) fatal error the same code
would produce under 8 isn't a complete surprise for projects running on
modern 7.x.
I recognize this would go against normal conventions and RFC processes
for new warnings/errors/deprecations, but given the impact it can have
when trying to upgrade, I think it's well worth considering making a
process exception.
Actual result:
--------------
7.4.7: no warning, error, notice, etc.
8.0.0-alpha1: fatal error
--
Edit bug report at https://bugs.php.net/bug.php?id=79768&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79768&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79768&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79768&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79768&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79768&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79768&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79768&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79768&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79768&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79768&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79768&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79768&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79768&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79768&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79768&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79768&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79768&r=mysqlcfg
Thread (2 messages)
- eric at ericstern dot com