Req #73976 [Opn->Wfx]: getClosure() always returning the same object?

From: Date: Mon, 23 Jan 2017 07:54:18 +0000
Subject: Req #73976 [Opn->Wfx]: getClosure() always returning the same object?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206871@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73976&edit=1

 ID:                 73976
 Updated by:         krakjoe@php.net
 Reported by:        nobotsplease at example dot org
 Summary:            getClosure() always returning the same object?
-Status:             Open
+Status:             Wont fix
 Type:               Feature/Change Request
 Package:            Reflection related
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

This is not possible. It is possible to return the same static closure, but not bound closures.


Previous Comments:
------------------------------------------------------------------------
[2017-01-23 06:45:18] 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.



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=73976&edit=1


Thread (2 messages)

« previous php.bugs (#206871) next »