Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/DrupalFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* @file
* Contains \DrupalFinder\DrupalFinder.
*/

namespace DrupalFinder;

/**
Expand Down Expand Up @@ -51,6 +50,13 @@ class DrupalFinder
*/
private $vendorDir;

/**
* Starting path.
*
* @var string
*/
private $start_path_string;

/**
* Initialize finder.
*
Expand All @@ -62,9 +68,10 @@ class DrupalFinder
* @throws \Exception
* @todo Make $start_path mandatory in v2.
*/
public function __construct($start_path = null) {
public function __construct($start_path_string = null) {
// Initialize path variables to false, indicating their locations are
// not yet known.
$this->start_path_string = $start_path_string;
$this->drupalRoot = false;
$this->composerRoot = false;
$this->vendorDir = false;
Expand Down Expand Up @@ -150,7 +157,7 @@ protected function discoverRoots($start_path) {

foreach (array(true, false) as $follow_symlinks) {
$path = $start_path;
if ($follow_symlinks && is_link($path)) {
if ($follow_symlinks && is_string($path) && is_link((string) $path)) {
$path = realpath($path);
}

Expand Down Expand Up @@ -184,8 +191,8 @@ protected function discoverRoots($start_path) {
*/
protected function findAndValidateRoots($path)
{

if (!empty($path) && is_dir($path) && file_exists($path . '/autoload.php') && file_exists($path . '/' . $this->getComposerFileName())) {
$pathString = $path;
if (!empty($pathString) && is_dir($pathString) && file_exists($pathString . '/autoload.php') && file_exists($pathString . '/' . $this->getComposerFileName())) {
// Additional check for the presence of core/composer.json to
// grant it is not a Drupal 7 site with a base folder named "core".
$candidate = 'core/includes/common.inc';
Expand Down