Skip to content

Use SplFileInfo#5

Closed
webflo wants to merge 8 commits intomasterfrom
SplFileInfo
Closed

Use SplFileInfo#5
webflo wants to merge 8 commits intomasterfrom
SplFileInfo

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...

return TRUE;
}
}
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