phpstan-drupal
phpstan-drupal copied to clipboard
Fatal error: Uncaught TypeError: is_link(): Argument #1 ($filename) must be of type string, Drush\Config\Environment given in /tmp/site/vendor/webflo/drupal-finder/src/DrupalFinder.php:153
Bug report
Phpstan is failing due to code updated in the webflo : https://github.com/webflo/drupal-finder/pull/65/files Phpstan is using the this module error : Fatal error: Uncaught TypeError: is_link(): Argument #1 ($filename) must be of type string, Drush\Config\Environment given in /tmp/site/vendor/webflo/drupal-finder/src/DrupalFinder.php:153
Code snippet that reproduces the problem
Hello team,
I have created the pR for the fix : https://github.com/mglaman/phpstan-drupal/pull/757
Oh, it dropped as a minor release. Okay, thanks for reporting and the PR
@DEVDESAGAR1 I'm curious what configuration you have? I'm not seeing it error this way, nor are the Drupal.org GitLab CI jobs
I can't reproduce the failures, but for now I'm merging https://github.com/mglaman/phpstan-drupal/pull/758 to accept the deprecations
I am facing this exact same issue where i just upgrading Drupal 10.1.14 to latest Drupal 10.2.6.
I can not run Drush updb and get the following error which is same as you guys are facing, whats the fix so far we have? Really blocked at this point on this error.
`PHP Fatal error: Uncaught TypeError: is_link(): Argument #1 ($filename) must be of type string, Drush\Config\Environment given in /var/www/html/vendor/webflo/drupal-finder/src/DrupalFinder.php:153 Stack trace: #0 /var/www/html/vendor/webflo/drupal-finder/src/DrupalFinder.php(153): is_link(Object(Drush\Config\Environment)) #1 /var/www/html/vendor/webflo/drupal-finder/src/DrupalFinder.php(75): DrupalFinder\DrupalFinder->discoverRoots(Object(Drush\Config\Environment)) #2 /var/www/html/vendor/drush/drush/src/Preflight/Preflight.php(310): DrupalFinder\DrupalFinder->__construct(Object(Drush\Config\Environment)) #3 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(58): Drush\Preflight\Preflight->preflight(Array) #4 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput)) #5 /var/www/html/vendor/drush/drush/drush.php(139): Drush\Runtime\Runtime->run(Array) #6 /var/www/html/vendor/drush/drush/drush(4): require('/var/www/html/v...') #7 /var/www/html/vendor/bin/drush(119): include('/var/www/html/v...') #8 {main} thrown in /var/www/html/vendor/webflo/drupal-finder/src/DrupalFinder.php on line 153
Fatal error: Uncaught TypeError: is_link(): Argument #1 ($filename) must be of type string, Drush\Config\Environment given in /var/www/html/vendor/webflo/drupal-finder/src/DrupalFinder.php:153 Stack trace: #0 /var/www/html/vendor/webflo/drupal-finder/src/DrupalFinder.php(153): is_link(Object(Drush\Config\Environment)) #1 /var/www/html/vendor/webflo/drupal-finder/src/DrupalFinder.php(75): DrupalFinder\DrupalFinder->discoverRoots(Object(Drush\Config\Environment)) #2 /var/www/html/vendor/drush/drush/src/Preflight/Preflight.php(310): DrupalFinder\DrupalFinder->__construct(Object(Drush\Config\Environment)) #3 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(58): Drush\Preflight\Preflight->preflight(Array) #4 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput)) #5 /var/www/html/vendor/drush/drush/drush.php(139): Drush\Runtime\Runtime->run(Array) #6 /var/www/html/vendor/drush/drush/drush(4): require('/var/www/html/v...') #7 /var/www/html/vendor/bin/drush(119): include('/var/www/html/v...') #8 {main} thrown in /var/www/html/vendor/webflo/drupal-finder/src/DrupalFinder.php on line 153 Failed to run drush updb -y: exit status 255`
This was Drush issue and i have solved it by creating a patch for Drush 12.
I was running into this issue when I upgraded to Drush 11.x to 12.x on a Drupal 10.1.x and 10.2.x
Found the issue fix on drush github create a patch and apply it to 12.x version from here: https://github.com/drush-ops/drush/pull/5755/files
Note: This issue is fixed and merged in Drush 13.x as per pull request conversation https://github.com/drush-ops/drush/pull/5755
I am not sure what i updated that is now causing this error:
Fatal error: Uncaught TypeError: is_link(): Argument #1 ($filename) must be of type string, Drush\Config\Environment given in E:\www\mysite\vendor\webflo\drupal-finder\src\DrupalFinder.php:153
but drush 12.5 and this patch: https://patch-diff.githubusercontent.com/raw/drush-ops/drush/pull/5755.patch does not fix it.
Ah, i had 12.5.0 (and the patch); but require drush 12.5.2 (maybe 12.5.1 would work) and the patch to fix.
I have drush 12.5.2 and the patch works.
Try to update drush to the version and let me know.
Drush 12.5.1 + patch does not work. Drush 12.5.2 + patch does work, thanks!
So, is this not an issue with phpstan-drupal? I'm guessing not, since the CI is passing for build integrations
@mglaman True, but there is a retro effect somewhere so you will have to tie it up with drush 12.5.1+
Understood, but it's not caused by this package. Just both share this same dependency
I had the same problem with Drush 12.4.3, it works 12.5.2 even without the patch.
I am using drush 12.5.2 When I use proposed patch : https://github.com/mglaman/phpstan-drupal/pull/757
I got this error:
RuntimeException thrown in /home/lob/www/fut/vendor/mglaman/phpstan-drupal/src/Drupal/DrupalAutoloader.php on line 109 while loading bootstrap file /home/lob/www/fut/vendor/mglaman/phpstan-drupal/drupal-autoloader.php: Unable to detect Drupal in /home/lob/www/fut/web
I missed the part related to drush patch. So, to fix all issues, you need this patch: https://github.com/drush-ops/drush/pull/5755/files
Updating to Drush 12.5.2 fixed this issue for me.
Updating to 12.5.2 fixed the issue. No patch needed.
I just updated my sites, and am being bitten by this problem.
Updating to 12.5.2 does not fix the issue for me. I tried patching Drupal with https://github.com/drush-ops/drush/pull/5755/files, to no avail.
FWIW, I don't understand why this is triggering, as my document root is not a symlink. My files directory (web/sites/default/files
) is a symlink, though.
Faced same issue on upgrading from Drupal 10.2.4 to 10.3.0
Updating Drush to 12.5.2 fixed the issue for me. No patch needed. Thanks!
Thank you @rf033 - your comment:https://github.com/mglaman/phpstan-drupal/issues/756#issuecomment-2138023157 worked in my case.
2 ways to update drush:
- On my local personal dev environment set up, using
ddev
, I updated drush by doing:
ddev composer require drush/drush
robdaviswork@192 ligc-staging % ddev composer require drush/drush
./composer.json has been updated
Running composer update drush/drush
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
- Upgrading drush/drush (12.5.1 => 12.5.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Downloading drush/drush (12.5.2)
- Upgrading drush/drush (12.5.1 => 12.5.2): Extracting archive
Generating autoload files
51 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found.
Using version ^12.5 for drush/drush
I now no longer get errors if doing ddev drush cr
or ddev drush updb
- on my server / and generally for the codebase I would do:
composer require drush/drush
Updating Drush to 12.5.2 fixed the issue for me. No patch needed.