Req #79768 [Opn->Wfx]: LSP BC break in 8.0.0 issues no warning in 7.x

From: Date: Thu, 02 Jul 2020 07:37:11 +0000
Subject: Req #79768 [Opn->Wfx]: LSP BC break in 8.0.0 issues no warning in 7.x
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227772@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79768&edit=1 ID: 79768 Updated by: nikic@php.net Reported by: eric at ericstern dot com Summary: LSP BC break in 8.0.0 issues no warning in 7.x -Status: Open +Status: Wont fix Type: Feature/Change Request Package: *General Issues Operating System: n/a PHP Version: 7.4.7 Block user comment: N Private report: N New Comment: Sorry, backporting such a warning to PHP 7.4 is forbidden by policy. Automated tooling will be able to diagnose this change in the future. I think it is a bit early to expect static analyzers to have complete PHP 8 support at this point in time. If you do encounter this issue, there is an extremely simple quick fix: Just comment the abstract method. (Usually making using classes compatible would be the proper fix, but it may be more involved.) Previous Comments: ------------------------------------------------------------------------ [2020-07-02 01:41:03] eric at ericstern dot com 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 this bug report at https://bugs.php.net/bug.php?id=79768&edit=1

« previous php.bugs (#227772) next »