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

[Bug] shouldExclude Argument #1 ($path) must be of type string #15

Open
RVxLab opened this issue Aug 5, 2023 · 0 comments
Open

[Bug] shouldExclude Argument #1 ($path) must be of type string #15

RVxLab opened this issue Aug 5, 2023 · 0 comments

Comments

@RVxLab
Copy link

RVxLab commented Aug 5, 2023

PHP: 8.2
Laravel: 10.15
Airdrop: 0.2.4


When running the airdrop:download or airdrop:upload commands, the following errors comes up:

   TypeError

  Hammerstone\Airdrop\FileSelection::shouldExclude(): Argument #1 ($path) must be of type string, Symfony\Component\Finder\SplFileInfo given, called in /var/www/html/vendor/hammerstone/airdrop/src/FileSelection.php on line 116

  at vendor/hammerstone/airdrop/src/FileSelection.php:152
    148▕             })
    149▕             ->toArray();
    150▕     }
    151▕
  ➜ 152▕     protected function shouldExclude(string $path): bool
    153▕     {
    154▕         foreach ($this->excludeFilesAndDirectories as $excludedPath) {
    155▕             if (Str::startsWith(realpath($path), $excludedPath)) {
    156▕                 return true;

      +1 vendor frames

  2   [internal]:0
      Hammerstone\Airdrop\FileSelection::yieldSelectedFiles()
      +22 vendor frames

  25  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()

This is caused by this line. The iterator is an iterator of Symfony\Component\Finder\SplFileInfo, not string.

The fix seems to be to pass the realpath from the Symfony object and remove the realpath function call in the shouldExclude function.

Doing this locally causes Airdrop to function as expected.

@RVxLab RVxLab changed the title [Bug] shouldExclude Argument $1 ($path) must be of type string [Bug] shouldExclude Argument #1 ($path) must be of type string Aug 11, 2023
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

No branches or pull requests

1 participant