-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Circular dependency between ReflectionMethod
and ReflectionClass
#1417
Comments
This is also true for reflection itself: the PHP engine has We did try (as much as possible) to remove all AST from the library memory profile, and then we tried making all reflection symbols as immutable as possible. Making the graph without references requires to keep all references in the reflector, and making the API of all symbols a bit awkward to use (must pass the reflector at every call). |
I think the initial problem I found will be fixed with sebastianbergmann/phpunit#5774
I wonder whether there is a way, which would help to get an idea whether the idea is worth exploring. |
The general problem is API. Before: This effectively completely breaks the internal references, which are instead asked to the This set of problems is similar to what you'd encounter with In a pure functional world, the reflector would contain the I/O, and the reflected symbols wouldn't have any I/O. I think it's worth exploring this idea for a new major version, but we'd need to identify all methods that perform this sort of traversal, such as (for example):
We'd then be able to also declare many of our classes completely /** @immutable */
final class ReflectionClass
{
// this is pure, by object definition
public function getName(): string { /* nothing magic here */ }
// this is not pure, but also not really part of the object
public static function getParent(self $self, Reflector $reflector): ReflectionClass { /* use the reflector for lookups here */ } |
BTW, the reflection adapters that keep BC with |
today I was looking into why the unit test-suite requires 3-4GB of RAM on my windows machine.
phpunit is getting inefficient because it needs to export/serialize all data of data-providers.
while looking deeper I noticed that the current class hierarchy contains a Circular dependency between
ReflectionMethod
andReflectionClass
.my thesis is, that a circular reference in this repos classes will also translate to inefficiences at PHP runtime, because the garbage collector need to do some extra work to free memory.
I want to leave this issue here to discuss whether we can do something about that.
The text was updated successfully, but these errors were encountered: