Req #71842 [NEW]: Uniquely identifying \Closure instances

From: Date: Thu, 17 Mar 2016 07:59:34 +0000
Subject: Req #71842 [NEW]: Uniquely identifying \Closure instances
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199882@lists.php.net to get a copy of this message
From: kjarli at gmail dot com Operating system: PHP version: 7.0.4 Package: Class/Object related Bug Type: Feature/Change Request Bug description:Uniquely identifying \Closure instances Description: ------------ A lot of web applications feature controllers. A controller can be really anything in the form of: - A method in a class - An invokable class - A function - A closure Now what is being doing in Frameworks like Symfony, is that you can have arguments of the action methods injected with some reflection with some fancy resolving if you please. Even though using reflection during run-time, it's a feature that cannot be missed for the purpose of DX (Developer eXperience). To make this faster, I was thinking of caching away the arguments resolved by reflection, this includes name, type (compat between 5 and 7), variadic (false on 5.5), has default and default value. This works fine for pretty much everything _except_ anonymous functions. In order to identity a controller, I can save the class+method or function name. For closures this is not possible because everything is a \Closure and the object hash is no reliable across requests. This means that for anonymous functions I would still have to resolve run-time what the arguments of the function are. With php 7 supporting Anonymous classes will have the same issue. Would it be possible to generate a signature hash of somesort so you can detect the same anonymous class/function across requests? -- Edit bug report at https://bugs.php.net/bug.php?id=71842&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71842&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71842&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71842&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71842&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71842&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71842&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71842&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71842&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71842&r=support Expected behavior: https://bugs.php.net/fix.php?id=71842&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71842&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71842&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71842&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71842&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71842&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71842&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71842&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71842&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71842&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71842&r=mysqlcfg

« previous php.bugs (#199882) next »