[php-src] PR #14167: Make `ReflectionGenerator::getFunction()` legal after generator termination
| From: | TimWolla | Date: | Tue, 07 May 2024 14:11:04 +0000 |
| Subject: | [php-src] PR #14167: Make `ReflectionGenerator::getFunction()` legal after generator termination | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-26068@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/14167
Author: TimWolla
Currently after termination, a
Generator loses all its information, except for the
return value (if any). This makes it hard to impossible to introspect where that return value is
coming from, for example in debuggers.
This PR adds an explicit zend_function* to the struct _zend_generator to
allow the retrieval of the function even after termination. This new pointer allows
ReflectionGenerator::getFunction() to work correctly at all times. As a side-benefit I
was able to add the function name to the __debugInfo(), making it more easily available
without going through Reflection, allowing users to distinguish different Generators at a glance.