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

Fixed issue with duplicate checker by using array_count_values() to determine if a node has the same name #13

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Sammyjo20
Copy link

Hi @vyuldashev πŸ‘‹

Thank you for this great little package, it's helped me massively with a project we've had to built quickly. I ran into a small issue however which was with some of the XML I was processing. One section of the XML had the following child nodes:

<Products>
<Products>
<ProductCount>

I found an issue where the sameName variable wouldn't be true because of the last <ProductCount> child node causing the isHomogenous method to return false.

I have solved this issue by using array_count_values which will count up all of the occurrences of each of the duplicated nodes, and when it checks to see if a node already exists, we check the $sameNamesOccurrences array for duplicates.

All tests are passing fine and it seems to work for my solution too. I hope you get a chance to review and potentially accept this PR! πŸ€“

Have a great day. β˜€οΈ

@Sammyjo20
Copy link
Author

Ah, I just figured out another potential bug with the keys. For example if you have two different nodes that both have child nodes, the keys aren't reset so you get the following:

Screen Shot 2021-05-09 at 17 09 56

@Sammyjo20
Copy link
Author

With the latest commit:

Screen Shot 2021-05-09 at 17 15 31

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.

None yet

1 participant