Req #71037 [Com]: Interfaces for Reflection API

From: Date: Sat, 05 Dec 2015 09:00:41 +0000
Subject: Req #71037 [Com]: Interfaces for Reflection API
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197614@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71037&edit=1 ID: 71037 Comment by: andreas at dqxtech dot net Reported by: andreas at dqxtech dot net Summary: Interfaces for Reflection API Status: Open Type: Feature/Change Request Package: Reflection related Operating System: Linux PHP Version: 7.0.0 Block user comment: N Private report: N New Comment: Of course I don't really care if it is IReflectionFunction or ReflectionFunctionInterface. But the latter pattern would give us ReflectionInterface vs ReflectionInterfaceInterface, which seems bad. Previous Comments: ------------------------------------------------------------------------ [2015-12-05 08:58:53] andreas at dqxtech dot net Description: ------------ The native Reflection API should provide interfaces like \IReflectionClass, which can then be used for type hinting. This way, libraries such as https://github.com/Roave/BetterReflection or https://github.com/Andrewsville/PHP-Token-Reflection don't need to extend or wrap core reflection classes, but can instead implement the interface. One problem with this is that some libraries might only want to implement some of the methods of e.g. \ReflectionFunction, but not all of them. To allow this, there would need to be partial interfaces - which could be a longer discussion. I think for a start it would be sufficient to just have one interface for each of the already existing classes of the Reflection API. More interfaces could be added in the future. Test script: --------------- class C {..} function foo(\IReflectionClass $reflectionClass) {..} foo(new \ReflectionClass('C')); class MyReflectionClass implements \IReflectionClass { .. } foo(new MyReflectionClass('C')); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71037&edit=1

« previous php.bugs (#197614) next »