Skip to content

Conversation

@rela589n
Copy link
Contributor

@rela589n rela589n commented Aug 5, 2025

This PR fixes a possible bug introduced after #429

If the client code had called addPaths() after the instance creation, it would've been ignored (without any warning or so), and paths would not have been used. This commit fixes that. Retroactively added paths will be taken into account as well as $sourceFilePathNames.

@rela589n rela589n force-pushed the fix-colocated-mapping-driver-iterable-files-shadowing-paths branch from 9a1346b to 2d6de3d Compare August 5, 2025 12:51
@greg0ire
Copy link
Member

greg0ire commented Aug 5, 2025

Please make sure the subject of your commit message are no longer than 50 chars, and please wrap the body of your commit messages at 72 chars.

@rela589n rela589n force-pushed the fix-colocated-mapping-driver-iterable-files-shadowing-paths branch from 2d6de3d to 518bad4 Compare August 6, 2025 11:21
@rela589n
Copy link
Contributor Author

rela589n commented Aug 6, 2025

Please make sure the subject of your commit message are no longer than 50 chars, and please wrap the body of your commit messages at 72 chars.

Could you please check it right now? I've shortened the commit messages, but the last commit message is not quite up to par. If needed, I can try to shorten it even more, but it would lose the context then.

@greg0ire
Copy link
Member

greg0ire commented Aug 6, 2025

Why do you say you would lose the context? Can't you move it from the commit message subject to the commit message body? You did read that I asked to wrap the commit message body at 72 chars? Wrap, not truncate.

After github.com/doctrine/pull/429/ was merged,
it could introduce subtle bugs during migration toward the new
`$sourceFilePathNames` approach. If client code called
`addPaths()` after instance creation, it would be ignored
(without any warning), and paths would not be used. The current
commit fixes that. Retroactively added paths will be taken
into account along with the `$sourceFilePathNames` iterable.
 When checking $includedFiles for an included file,
 the previous `in_array()` approach, executed in a loop,
 is very expensive. Basically, it results in performance
 of O(N * M), where N - number of declared classes,
 M - number of included classes. The current approach
 is O(N), since `isset()` check has constant `O(1)` time.
@rela589n rela589n force-pushed the fix-colocated-mapping-driver-iterable-files-shadowing-paths branch from 518bad4 to d0e7922 Compare August 6, 2025 13:36
@rela589n
Copy link
Contributor Author

rela589n commented Aug 6, 2025

Wrap, not truncate.

Sorry, didn't get your point.
What do you mean by "wrap"?
I thought I've wrapped exactly how you'd asked me to.

@greg0ire
Copy link
Member

greg0ire commented Aug 6, 2025

Wrapping just means adding a newline/carriage return every 72 chars.

@greg0ire
Copy link
Member

greg0ire commented Aug 7, 2025

Now that I am on desktop, it does look wrapped just fine 👍

So why do you say you would lose the context? Can't you move it from the commit message subject to the commit message body?

@rela589n
Copy link
Contributor Author

rela589n commented Aug 7, 2025

So why do you say you would lose the context? Can't you move it from the commit message subject to the commit message body?

Done

greg0ire
greg0ire previously approved these changes Aug 7, 2025
This change makes it easy for the depending libraries to use
iterable of `SplFileInfo`, adapted to the format of `ColocatedMappingDriver`.
For example, one could pass in Symfony Finder, adapted with `PathNameIterator`
into `AttributeDriver` without having to reinvent it in every particular case.
* @template T
*/
private function pathNameIterator(iterable $filesIterator): Generator
private function mergeIterables(iterable $iterable1, iterable $iterable2): Generator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rather appending $iterable2 to $iterable1 than merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you propose naming it as concatIterables()?

"Appending" sounds with the tone of modifying the iterable, while it's actually combining them into a single iterable, doing no modification to the original.

Dictionary-wise, "merge" looks good as it means "combine or cause to combine to form a single entity."

@greg0ire
Copy link
Member

greg0ire commented Aug 8, 2025

Closing in favor of a better incoming PR

@greg0ire greg0ire closed this Aug 8, 2025
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.

3 participants