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

Use SplFileInfo #5

Closed
wants to merge 8 commits into from
Closed

Use SplFileInfo #5

wants to merge 8 commits into from

Conversation

webflo
Copy link
Owner

@webflo webflo commented Nov 15, 2016

No description provided.

Matthias Lünemann and others added 6 commits November 15, 2016 17:46
@luenemam
Copy link

luenemam commented Nov 16, 2016

Looks great! Thanks.
Though there is no need to use SplFileInfo for this too work... https://github.com/luenemam/drupal-finder/blob/simplify-locateRoot/src/DrupalFinder.php#L30
I have no idea whats better...

When i went to SplFileInfo i was searching for an Iterator to walk up the FileSystem.

Something like this:

$paths = new WalkupFilesystemToRootIncludingSymlinksIterator($startpath);
foreach (paths as $path => $file_info) {
  if ($this->isValidRoot($path)) {
    return TRUE;
  }
}

Didn't find anything like that.

Copy link

@luenemam luenemam left a comment

Choose a reason for hiding this comment

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

The first call to $path->getRealPath() clears all symlinks. see SplFileInfo::getRealPath
So for $follow_symlinks = TRUE we will not finde any more symlinks. No need to check for a link in the loop.

What are the use cases for not following symlinks?

  • shared modules

any more?

We should add explicit tests for this use cases.

Copy link

@luenemam luenemam left a comment

Choose a reason for hiding this comment

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

The test are good, my idea of the simplification was wrong...

}
}
while (($path = $path->getPathInfo()) && ($path->getFilename() != '.'));

Choose a reason for hiding this comment

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

This works only with a streamwrapper... not a real FS... it get's into a loop at fs-root.

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.

2 participants