Req #65119 [Com]: provide a way to inherit a final class or overriding final methods

From: Date: Tue, 29 Oct 2019 14:27:51 +0000
Subject: Req #65119 [Com]: provide a way to inherit a final class or overriding final methods
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223504@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65119&edit=1 ID: 65119 Comment by: ayg at aryeh dot name Reported by: knight at kopernet dot org Summary: provide a way to inherit a final class or overriding final methods Status: Open Type: Feature/Change Request Package: Reflection related PHP Version: Irrelevant Block user comment: N Private report: N New Comment: This causes a significant limitation in PHPUnit (and presumably other unit-testing frameworks). It is not possible to mock final classes or methods: <https://phpunit.readthedocs.io/en/8.3/test-doubles.html>. (Mocking a class subclasses it and overrides the methods to be mocked, which doesn't work if they're final.) This makes it difficult to write unit tests for code that uses final classes or methods. Someone went so far as to write a library that strips "final" from all PHP code to work around this problem: <https://github.com/dg/bypass-finals> This feature would be useful for MediaWiki, see discussion (we actually want to try using that final-stripping library for test runs to work around the problem): https://lists.wikimedia.org/pipermail/wikitech-l/2019-August/092432.html https://phabricator.wikimedia.org/T231419 Previous Comments: ------------------------------------------------------------------------ [2013-06-25 08:04:10] knight at kopernet dot org Description: ------------ Please provide a way to make possible to bypass the final keyword restriction in similar way the ReflectionAPI makes possible to call private or protected members. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65119&edit=1

« previous php.bugs (#223504) next »