Skip to content
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

Fix infinite loop when indexing self referencing classes #670

Merged
merged 4 commits into from Nov 11, 2018
Merged

Fix infinite loop when indexing self referencing classes #670

merged 4 commits into from Nov 11, 2018

Conversation

d0x2f
Copy link
Contributor

@d0x2f d0x2f commented Aug 31, 2018

As the indexer attempts to parse the parent class, it adds itself to the array being iterated.

A simple check that the FQN isn't identical resolves the issue.

fixes #669

@felixfbecker
Copy link
Owner

felixfbecker commented Aug 31, 2018

What about a loop like this?

class A extends B {}
class B extends A {}

@codecov
Copy link

codecov bot commented Aug 31, 2018

Codecov Report

Merging #670 into master will increase coverage by 0.02%.
The diff coverage is 100%.

@@             Coverage Diff              @@
##             master     #670      +/-   ##
============================================
+ Coverage     82.16%   82.19%   +0.02%     
- Complexity      921      922       +1     
============================================
  Files            44       44              
  Lines          2148     2151       +3     
============================================
+ Hits           1765     1768       +3     
  Misses          383      383
Impacted Files Coverage Δ Complexity Δ
src/DefinitionResolver.php 87.45% <100%> (+0.06%) 332 <0> (+1) ⬆️

@d0x2f
Copy link
Contributor Author

d0x2f commented Aug 31, 2018

indeed that causes the same looping issue.

I'm not familiar enough with the codebase to know if there's a list of already processed FQN's we can lookup.

I'll think on it.

@d0x2f d0x2f changed the title Fix infinite loop when indexing self referencing classes WIP Fix infinite loop when indexing self referencing classes Aug 31, 2018
@d0x2f d0x2f changed the title WIP Fix infinite loop when indexing self referencing classes Fix infinite loop when indexing self referencing classes Sep 1, 2018
@d0x2f
Copy link
Contributor Author

d0x2f commented Sep 1, 2018

I've added a list of visited fqns and changed the check to prevent adding a parent fqn that's already been visited.

Let me know what you think.

@felixfbecker felixfbecker merged commit c7d25c7 into felixfbecker:master Nov 11, 2018
@felixfbecker
Copy link
Owner

🎉 This PR is included in version 5.4.4 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Files with classes that declare itself to be it's parent can cause an infinite loop when indexing.
2 participants