Not-circular interface detected as circular
ondrejmirtes opened this issue · 1 comments
Last minute changes to BetterReflection 6.0 before release around AlreadyVisitedClasses
brought a bug that was familiar to me.
This situation is now detected as circular but in fact it works in PHP:
<?php
interface CacheableDependencyInterface {
}
interface RefinableCacheableDependencyInterface extends CacheableDependencyInterface {
}
interface AccessibleInterface {
}
interface EntityInterface extends AccessibleInterface, CacheableDependencyInterface, RefinableCacheableDependencyInterface {
}
In the previous version that used references I accidentally introduced it to my fork and had to fix it too. This is how I introduced the bug: ondrejmirtes@258f60e#diff-c58f24d134490b09a18aa65366bc9ab2d5bf2dbf493bea9f12b365807a5b5e22L1654-R1673
This is how I had to fix it: ondrejmirtes@22ae7d2 + ondrejmirtes@8c24808
Because: It turns out it's hard to rewrite an arrow function to equivalent imperative code. Because an arrow function doesn't use outer scope variables by reference, the value is copied when array_map is called. And it's called only once so the callback always uses the initial variable value, it's not updated by reference.
The object version using AlreadyVisitedClasses in Roave/BetterReflection 6.0.0 has the same problem. The reference is now updated each time and breaks analysing legit code.
I'll submit a failing test PR too.
/cc @herndlm