Skip to content

RecursiveDirectoryIterator opens excluded folders #7525

Closed

Description

@spaanse

Bug report

My project folder contains a folder that is not accecible by phpstan because it doens't have the right permissions.
This folder is added to the exludePahts::analyseAndScan of phpstan.neon:

...
parameters:
  ...
  excludePaths:
    analyseAndScan:
      - .../excluded_folder/
...

However, I still get the following error:

RecursiveDirectoryIterator::__construct( .../excluded_folder/.../folder ): Failed to open directory: Permission denied 

I expect phpstan to not even try to look into the excluded_folder directory.

Code snippet that reproduces the problem

Expected output

Did PHPStan help you today? Did it make you happy in any way?

Activity

  1. mergeable commented on Jun 24, 2022

    @mergeable

    This bug report is missing a link to reproduction at phpstan.org/try.

    It will most likely be closed after manual review.

  2. ondrejmirtes commented on Jun 24, 2022

    @ondrejmirtes
    Member

    Hello, why do you have a directory in your project with wrong permissions?

    First and foremost, PHPStan would have to have a reason to access the directory for you to have a reason to exclude it - so what happens if you remove the directory from excludePaths? Can you avoid this problem a different way?

  3. spaanse commented on Jun 24, 2022

    @spaanse
    Author

    It is a cache directory used by the webserver, there is no code in there.
    The permissions of files/folders there are owned by www-data
    However all checked code is owned by my user.
    It should be possible to only include paths that are not the cache directory.
    However, that doesn't solve my expectation that the crawler doesn't explore folders it doesn't need for analysis.

  4. ondrejmirtes commented on Jun 24, 2022

    @ondrejmirtes
    Member

    Hard to say without the rest of phpstan.neon what are you trying to achieve. You can write your paths and scanDirectories in a way that .../excluded_folder/ is completely avoided.

  5. github-actions commented on Oct 23, 2022

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  6. locked as resolved and limited conversation to collaborators on Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions