From 6841bcc409bdcbdff5db96ee93974df4e9203c48 Mon Sep 17 00:00:00 2001 From: akhanam_a Date: Sun, 26 May 2024 14:34:29 +0530 Subject: [PATCH] PHP Fatal error: Uncaught TypeError: is_link(): Argument #1 ($filename) must be of type string --- src/DrupalFinder.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/DrupalFinder.php b/src/DrupalFinder.php index 9ca870f..8da8a74 100644 --- a/src/DrupalFinder.php +++ b/src/DrupalFinder.php @@ -4,7 +4,6 @@ * @file * Contains \DrupalFinder\DrupalFinder. */ - namespace DrupalFinder; /** @@ -51,6 +50,13 @@ class DrupalFinder */ private $vendorDir; + /** + * Starting path. + * + * @var string + */ + private $start_path_string; + /** * Initialize finder. * @@ -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; @@ -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); } @@ -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';