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

Uncaught UnexpectedValueException on psalm --init #5013

Closed
wnedoe opened this issue Jan 14, 2021 · 8 comments
Closed

Uncaught UnexpectedValueException on psalm --init #5013

wnedoe opened this issue Jan 14, 2021 · 8 comments

Comments

@wnedoe
Copy link

wnedoe commented Jan 14, 2021

When trying to run the init psalm crashes :-(

windows 10 php 7.4.13

Calculating best config level based on project files
Calculating best config level based on project files
Scanning files...
Uncaught UnexpectedValueException: File Z:\www.example.com\vendor\verot\class.upload.php is a directory in Z:\www.example.com\vendor\vimeo\psalm\src\Psalm\Internal\Provider\FileProvider.php:39
Stack trace:
#0 Z:\www.example.com\vendor\vimeo\psalm\src\Psalm\Internal\Codebase\Scanner.php(547): Psalm\Internal\Provider\FileProvider->getContents('Z:\www.terraris...')
#1 Z:\www.example.com\vendor\vimeo\psalm\src\Psalm\Internal\Codebase\Scanner.php(321): Psalm\Internal\Codebase\Scanner->scanFile('Z:\www.terraris...', Array, true)
#2 Z:\www.example.com\vendor\vimeo\psalm\src\Psalm\Internal\Codebase\Scanner.php(433): Psalm\Internal\Codebase\Scanner->Psalm\Internal\Codebase{closure}(548, 'Z:\www.terraris...')
#3 Z:\www.example.com\vendor\vimeo\psalm\src\Psalm\Internal\Codebase\Scanner.php(285): Psalm\Internal\Codebase\Scanner->scanFilePaths(1)
#4 Z:\www.example.com\vendor\vimeo\psalm\src\Psalm\Codebase.php(463): Psalm\Internal\Codebase\Scanner->scanFiles(Object(Psalm\Internal\Codebase\ClassLikes), 1)
#5 Z:\www.example.com\vendor\vimeo\psalm\src\Psalm\Internal\Analyzer\ProjectAnalyzer.php(588): Psalm\Codebase->scanFiles(1)
#6 Z:\www.example.com\vendor\vimeo\psalm\src\psalm.php(676): Psalm\Internal\Analyzer\ProjectAnalyzer->check('Z:\www.terraris...', true)
#7 Z:\www.example.com\vendor\vimeo\psalm\psalm(2): require_once('Z:\www.terraris...')
#8 {main}
(Psalm 4.4.0@ef4afd72bca50a0aff61599d3e433c9ee64287ac crashed due to an uncaught Throwable)

@psalm-github-bot
Copy link

Hey @wnedoe, can you reproduce the issue on https://psalm.dev ?

@wnedoe
Copy link
Author

wnedoe commented Jan 14, 2021

Of yourse not, dear bot. ;-)

@weirdan
Copy link
Collaborator

weirdan commented Jan 14, 2021

Can you reproduce in a separate public repo?

@wnedoe
Copy link
Author

wnedoe commented Jan 14, 2021

When i run it in the repo vendor\verot\class.upload.php where the error occurs, then the --init works perfectly.

mybe my composer.json has a problem?

This is the content of it:

`{
"require": {
"maxmind/minfraud": "~1.0",
"league/iso3166": "^3.0",
"geoip2/geoip2": "~2.0",
"phpmailer/phpmailer": "^6.1",
"maximebf/debugbar": ">=1.0.0",
"monolog/monolog": "^2.2",
"verot/class.upload.php": "",
"ext-gettext": "
",
"ext-mysqli": "",
"ext-json": "
",
"ext-pdo": "*"
},

"config": {

"platform": {
    "php": "7.40.13"

}

},
"require-dev": {
"vimeo/psalm": "^4.4"
}
}
`

@wnedoe
Copy link
Author

wnedoe commented Jan 14, 2021

I run --debug and have a suspicion:

The exception happens at the processing of vendor/installed.php

**and here it MOST PROBABLY parses the directory

verot/class.upload.php

as a file and then the file parsing throws that exeption.**

installed.php snippet 

 'aliases' => 
      array (
      ),
      'reference' => '13e7e882eaa55863faa7c4ad7c60f12f1a8b5089',
    ),
    'verot/class.upload.php' => 
    array (
      'pretty_version' => '2.1.0',
      'version' => '2.1.0.0',
      'aliases' => 
      array (
      ),
      'reference' => '4d9aae875245948d21e42ade332fb45f897f28bb',
    ),
    'vimeo/psalm' => 
    array (
      'pretty_version' => '4.4.0',
      'version' => '4.4.0.0',
      'aliases' => 

###############################
[...]
Parsing Z:\www.example.com\vendor\composer\installed.php
Deep scanning Z:\www.example.com\vendor\composer\installed.php
Uncaught UnexpectedValueException: File Z:\www.example.com\vendor\verot\class.upload.php is a directory in Z:\www.example.com\vendor\vimeo\psalm\src\Psalm\Internal\Provider\FileProvider.php:39
Stack trace:
#0 Z:\www.example.com\vendor\vimeo\psalm\src\Psalm\Internal\Codebase\Scanner.php(547): Psalm\Internal\Provider\FileProvider->getContents('Z:\www.examp...')
#1 Z:\www.example.com\vendor\vimeo\psalm\src\Psalm\Internal\Codebase\Scanner.php(321): Psalm\Internal\Codebase\Scanner->scanFile('Z:\www.examp...', Array, true)
#2 Z:\www.example.com\vendor\vimeo\psalm\src\Psalm\Internal\Codebase\Scanner.php(433): Psalm\Internal\Codebase\Scanner->Psalm\Internal\Codebase{closure}(548, 'Z:\www.examp...')
#3 Z:\www.example.com\vendor\vimeo\psalm\src\Psalm\Internal\Codebase\Scanner.php(285): Psalm\Internal\Codebase\Scanner->scanFilePaths(1)
#4 Z:\www.example.com\vendor\vimeo\psalm\src\Psalm\Codebase.php(463): Psalm\Internal\Codebase\Scanner->scanFiles(Object(Psalm\Internal\Codebase\ClassLikes), 1)
#5 Z:\www.example.com\vendor\vimeo\psalm\src\Psalm\Internal\Analyzer\ProjectAnalyzer.php(588): Psalm\Codebase->scanFiles(1)
#6 Z:\www.example.com\vendor\vimeo\psalm\src\psalm.php(676): Psalm\Internal\Analyzer\ProjectAnalyzer->check('Z:\www.examp...', true)
#7 Z:\www.example.com\vendor\vimeo\psalm\psalm(2): require_once('Z:\www.examp...')
#8 {main}

@orklah
Copy link
Collaborator

orklah commented Oct 12, 2021

:o There is actually a repo name class.upload.php: https://github.com/verot/class.upload.php

No surprise Psalm was confused. This is probably coming from the module that detects php files to analyze. This should be pretty simple to fix by looking at the stack trace and adding a is_file() check somewhere...

Do you mind pushing a PR?

@robchett
Copy link
Contributor

I believe this issue may be resolved now as I've done the following steps without the Exception being thrown.

  • created a new composer project
  • run composer require verot/class.upload.php vimeo/psalm
  • run psalm --init

@orklah
Copy link
Collaborator

orklah commented Apr 18, 2023

I think the error was in a repo using verot/class.upload.php, not in the repo itself, as the author said earlier "When i run it in the repo vendor\verot\class.upload.php where the error occurs, then the --init works perfectly."

But yeah, I'll close this anyway. It should be easy to ignore this directory in config while it may take a lot of resources in Psalm to check that every .php is indeed a file and not a directory

@orklah orklah closed this as completed Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants