php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #73976 getClosure() always returning the same object?
Submitted: 2017-01-23 06:45 UTC Modified: 2017-01-23 07:54 UTC
From: nobotsplease at example dot org Assigned:
Status: Wont fix Package: Reflection related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nobotsplease at example dot org
New email:
PHP Version: OS:

 

 [2017-01-23 06:45 UTC] nobotsplease at example dot org
Description:
------------
Would it be possible if ReflectionMethod and ReflectionFunction's getClosure() methods always returned the same Closure object? e.g:

class Foo{ function bar(){} }
$a = new ReflectionMethod('Foo', 'bar');
$b = new ReflectionMethod('Foo', 'bar');
$foo = new Foo();
$aa = $a->getClosure($foo);
$bb = $b->getClosure($foo);
assert($aa == $bb);
assert($aa === $bb);

Object that would have the same lifetime of the object the variable $this is set to ($foo, in previous example). It would be nice if we were allowed to use === operator for comparison. Similarly

$aa = $a->getClosure($foo)->bindTo($foo, 'static');
$bb = $b->getClosure($foo)->bindTo($foo, 'static');
assert($aa == $bb);
assert($aa === $bb);

might also be valid, but I imagine this would complicate things enormously.

Thank you in advance.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-23 07:54 UTC] krakjoe@php.net
-Status: Open +Status: Wont fix
 [2017-01-23 07:54 UTC] krakjoe@php.net
This is not possible. It is possible to return the same static closure, but not bound closures.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 00:01:27 2024 UTC